diff options
author | Willem Jan Palenstijn | 2013-04-14 01:32:37 +0200 |
---|---|---|
committer | Willem Jan Palenstijn | 2013-12-31 13:52:15 +0100 |
commit | 857d2e7beff46fcd5d26e8590c9891a4959b8d1f (patch) | |
tree | 489e46f9222f91d7d59da1a64779d0aaa5a27a6a /engines/sci/sound/music.h | |
parent | f777e54df291d1f39aefdc40d1d966e50d261efb (diff) | |
download | scummvm-rg350-857d2e7beff46fcd5d26e8590c9891a4959b8d1f.tar.gz scummvm-rg350-857d2e7beff46fcd5d26e8590c9891a4959b8d1f.tar.bz2 scummvm-rg350-857d2e7beff46fcd5d26e8590c9891a4959b8d1f.zip |
SCI: Rewrite MIDI channel remapping
This adds MIDI state tracking to allow channels to be temporarily
unmapped and later re-mapped when there are free device channels
available again.
Diffstat (limited to 'engines/sci/sound/music.h')
-rw-r--r-- | engines/sci/sound/music.h | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h index 40236c8445..23a072cb26 100644 --- a/engines/sci/sound/music.h +++ b/engines/sci/sound/music.h @@ -52,6 +52,17 @@ class SegManager; typedef Common::Array<uint16> SignalQueue; + +struct MusicEntryChannel { + // Channel info + int8 _prio; // 0 = essential; lower is higher priority + int8 _voices; + bool _dontRemap; + bool _dontMap; + bool _mute; +}; + + class MusicEntry : public Common::Serializable { public: // Do not get these directly for the sound objects! @@ -90,6 +101,8 @@ public: Audio::Mixer::SoundType soundType; + int _usedChannels[16]; + MusicEntryChannel _chan[16]; MidiParser_SCI *pMidiParser; // this is used for storing signals, when the current signal is not yet @@ -114,6 +127,27 @@ public: virtual void saveLoadWithSerializer(Common::Serializer &ser); }; +struct DeviceChannelUsage { + MusicEntry *_song; + int _channel; + bool operator==(const DeviceChannelUsage& other) const { return _song == other._song && _channel == other._channel; } + bool operator!=(const DeviceChannelUsage& other) const { return !(*this == other); } +}; + +struct ChannelRemapping { + DeviceChannelUsage _map[16]; + int _prio[16]; + int _voices[16]; + bool _dontRemap[16]; + int _freeVoices; + + void clear(); + void swap(int i, int j); + void evict(int i); + ChannelRemapping& operator=(ChannelRemapping& other); + int lowestPrio() const; +}; + typedef Common::Array<MusicEntry *> MusicList; typedef Common::Array<uint32> MidiCommandQueue; @@ -198,9 +232,6 @@ public: // where a deadlock can occur Common::Mutex _mutex; - int16 tryToOwnChannel(MusicEntry *caller, int16 bestChannel); - void freeChannels(MusicEntry *caller); - protected: void sortPlayList(); @@ -213,6 +244,11 @@ protected: // If true and a sound has a digital track, the sound from the AdLib track is played bool _useDigitalSFX; + // remapping: + void remapChannels(); + ChannelRemapping *determineChannelMap(); + void resetDeviceChannel(int devChannel); + private: MusicList _playList; bool _soundOn; @@ -221,6 +257,8 @@ private: int8 _channelRemap[16]; int8 _globalReverb; + DeviceChannelUsage _channelMap[16]; + MidiCommandQueue _queuedCommands; MusicType _musicType; |