diff options
author | Max Horn | 2006-02-11 22:45:04 +0000 |
---|---|---|
committer | Max Horn | 2006-02-11 22:45:04 +0000 |
commit | 26ee630756ebdd7c96bccede0881a8c8b98e8f2b (patch) | |
tree | 26e378d5cf990a2b81c2c96e9e683a7f333b62e8 /engines/simon/midi.h | |
parent | 2a9a0d4211b1ea5723f1409d91cb95de8984429e (diff) | |
download | scummvm-rg350-26ee630756ebdd7c96bccede0881a8c8b98e8f2b.tar.gz scummvm-rg350-26ee630756ebdd7c96bccede0881a8c8b98e8f2b.tar.bz2 scummvm-rg350-26ee630756ebdd7c96bccede0881a8c8b98e8f2b.zip |
Moved engines to the new engines/ directory
svn-id: r20582
Diffstat (limited to 'engines/simon/midi.h')
-rw-r--r-- | engines/simon/midi.h | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/engines/simon/midi.h b/engines/simon/midi.h new file mode 100644 index 0000000000..bc903f9d17 --- /dev/null +++ b/engines/simon/midi.h @@ -0,0 +1,127 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001-2006 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef SIMON_MIDI_H +#define SIMON_MIDI_H + +#include "sound/mididrv.h" +#include "sound/midiparser.h" +#include "common/mutex.h" + +namespace Common { + class File; +} + +namespace Simon { + +struct MusicInfo { + MidiParser *parser; + byte * data; + byte num_songs; // For Type 1 SMF resources + byte * songs[16]; // For Type 1 SMF resources + uint32 song_sizes[16]; // For Type 1 SMF resources + + MidiChannel *channel[16]; // Dynamic remapping of channels to resolve conflicts + byte volume[16]; // Current channel volume + + MusicInfo() { clear(); } + void clear() { + parser = 0; data = 0; num_songs = 0; + memset (songs, 0, sizeof (songs)); + memset (song_sizes, 0, sizeof (song_sizes)); + memset (channel, 0, sizeof (channel)); + } +}; + +class MidiPlayer : public MidiDriver { +protected: + Common::Mutex _mutex; + MidiDriver *_driver; + bool _map_mt32_to_gm; + bool _passThrough; + + MusicInfo _music; + MusicInfo _sfx; + MusicInfo *_current; // Allows us to establish current context for operations. + + // These are maintained for both music and SFX + byte _masterVolume; // 0-255 + bool _paused; + + // These are only used for music. + byte _currentTrack; + bool _loopTrack; + byte _queuedTrack; + bool _loopQueuedTrack; + +protected: + static void onTimer (void *data); + void clearConstructs(); + void clearConstructs (MusicInfo &info); + void resetVolumeTable(); + +public: + bool _enable_sfx; + +public: + MidiPlayer (OSystem *system); + virtual ~MidiPlayer(); + + void loadSMF (Common::File *in, int song, bool sfx = false); + void loadMultipleSMF (Common::File *in, bool sfx = false); + void loadXMIDI (Common::File *in, bool sfx = false); + void loadS1D (Common::File *in, bool sfx = false); + + void mapMT32toGM (bool map); + void setLoop (bool loop); + void startTrack(int track); + void queueTrack (int track, bool loop); + bool isPlaying (bool check_queued = false) { return (_currentTrack != 255 && (_queuedTrack != 255 || !check_queued)); } + + void stop(); + void pause (bool b); + + int get_volume() { return _masterVolume; } + void set_volume (int volume); + void set_driver (MidiDriver *md); + +public: + // MidiDriver interface implementation + int open(); + void close(); + void send(uint32 b); + + void metaEvent (byte type, byte *data, uint16 length); + void setPassThrough(bool b) { _passThrough = b; } + + // Timing functions - MidiDriver now operates timers + void setTimerCallback (void *timer_param, void (*timer_proc) (void *)) { } + uint32 getBaseTempo (void) { return _driver ? _driver->getBaseTempo() : 0; } + + // Channel allocation functions + MidiChannel *allocateChannel() { return 0; } + MidiChannel *getPercussionChannel() { return 0; } +}; + +} // End of namespace Simon + +#endif |