diff options
author | Paul Gilbert | 2007-09-16 04:06:49 +0000 |
---|---|---|
committer | Paul Gilbert | 2007-09-16 04:06:49 +0000 |
commit | b2e97060adf93760f7e4bce97e691e34fc258922 (patch) | |
tree | c646b990c339d55578600fcf33b608802d185366 /engines/lure/sound.h | |
parent | 041bb546c652d301bc68630f309b623d89471bab (diff) | |
download | scummvm-rg350-b2e97060adf93760f7e4bce97e691e34fc258922.tar.gz scummvm-rg350-b2e97060adf93760f7e4bce97e691e34fc258922.tar.bz2 scummvm-rg350-b2e97060adf93760f7e4bce97e691e34fc258922.zip |
Initial sound implementation
svn-id: r28917
Diffstat (limited to 'engines/lure/sound.h')
-rw-r--r-- | engines/lure/sound.h | 92 |
1 files changed, 89 insertions, 3 deletions
diff --git a/engines/lure/sound.h b/engines/lure/sound.h index 95cb5f6f88..cfe0739298 100644 --- a/engines/lure/sound.h +++ b/engines/lure/sound.h @@ -26,37 +26,123 @@ #include "lure/luredefs.h" #include "lure/disk.h" #include "lure/memory.h" + #include "common/singleton.h" +#include "sound/mididrv.h" +#include "sound/mixer.h" + +class MidiParser; namespace Lure { -#define NUM_CHANNELS 8 +#define NUM_CHANNELS_OUTER 8 +#define NUM_CHANNELS_INNER 16 + +struct ChannelEntry { + MidiChannel *midiChannel; + byte volume; +}; + +class MidiMusic: public MidiDriver { +private: + uint8 _soundNumber; + uint8 _channelNumber; + uint8 _numChannels; + byte _volume; + MemoryBlock *_decompressedSound; + uint8 *_soundData; + uint8 _soundSize; + MidiDriver *_driver; + MidiParser *_parser; + ChannelEntry *_channels; + bool _isPlaying; + bool _nativeMT32; + + void queueUpdatePos(); + uint8 randomQueuePos(); + uint32 songOffset(uint16 songNum) const; + uint32 songLength(uint16 songNum) const; + + bool _passThrough; + +public: + MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS_INNER], + uint8 channelNum, uint8 soundNum, void *soundData, uint32 size); + ~MidiMusic(); + void setVolume(int volume); + int getVolume() { return _volume; } + + void hasNativeMT32(bool b) { _nativeMT32 = b; } + void playSong(uint16 songNum); + void stopSong() { stopMusic(); } + void playMusic(); + void stopMusic(); + void queueTuneList(int16 tuneList); + bool queueSong(uint16 songNum); + void setPassThrough(bool b) { _passThrough = b; } + void toggleVChange(); + + //MidiDriver interface implementation + int open(); + void close(); + void send(uint32 b); + void onTimer(); + + void metaEvent(byte type, byte *data, uint16 length); + + void setTimerCallback(void *timerParam, void (*timerProc)(void *)) { } + uint32 getBaseTempo(void) { return _driver ? _driver->getBaseTempo() : 0; } + + //Channel allocation functions + MidiChannel *allocateChannel() { return 0; } + MidiChannel *getPercussionChannel() { return 0; } + + uint8 channelNumber() { return _channelNumber; } + uint8 soundNumber() { return _soundNumber; } + bool isPlaying() { return _isPlaying; } +}; class SoundManager: public Common::Singleton<SoundManager> { private: + // Outer sound interface properties MemoryBlock *_descs; + MemoryBlock *_soundData; + uint8 _soundsTotal; int _numDescs; SoundDescResource *soundDescs() { return (SoundDescResource *) _descs->data(); } + MidiDriver *_driver; ManagedList<SoundDescResource *> _activeSounds; - byte _channels[NUM_CHANNELS]; + ManagedList<MidiMusic *> _playingSounds; + ChannelEntry _channelsInner[NUM_CHANNELS_INNER]; + bool _channelsInUse[NUM_CHANNELS_OUTER]; + bool _isPlaying; + bool _nativeMT32; + // Internal support methods void bellsBodge(); + void musicInterface_TidySounds(); + static void onTimer(void *data); public: SoundManager(); + ~SoundManager(); + void loadSection(uint16 sectionId); void killSounds(); void addSound(uint8 soundIndex, bool tidyFlag = true); void addSound2(uint8 soundIndex); void stopSound(uint8 soundIndex); void killSound(uint8 soundNumber); void setVolume(uint8 soundNumber, uint8 volume); + void setVolume(uint8 volume); void tidySounds(); SoundDescResource *findSound(uint8 soundNumber); void removeSounds(); void restoreSounds(); + void fadeOut(); // The following methods implement the external sound player module - void musicInterface_Play(uint8 soundNumber, bool isEffect, uint8 channelNumber); + void musicInterface_Initialise(); + void musicInterface_Play(uint8 soundNumber, uint8 channelNumber); void musicInterface_Stop(uint8 soundNumber); bool musicInterface_CheckPlaying(uint8 soundNumber); void musicInterface_SetVolume(uint8 channelNum, uint8 volume); |