diff options
Diffstat (limited to 'engines/kyra/sound.h')
-rw-r--r-- | engines/kyra/sound.h | 245 |
1 files changed, 3 insertions, 242 deletions
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index edacdb0411..eb40e40ab9 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -45,13 +45,9 @@ #include "kyra/kyra_v1.h" #include "common/scummsys.h" -#include "common/file.h" -#include "common/mutex.h" -#include "common/ptr.h" +#include "common/str.h" -#include "sound/midiparser.h" #include "sound/mixer.h" -#include "sound/softsynth/ym2612.h" namespace Audio { class AudioStream; @@ -74,7 +70,8 @@ public: kMidiMT32, kMidiGM, kTowns, - kPC98 + kPC98, + kPCSpkr }; virtual kType getMusicType() const = 0; @@ -261,242 +258,6 @@ private: static const SpeechCodecs _supportedCodecs[]; }; -class AdlibDriver; - -/** - * AdLib implementation of the sound output device. - * - * It uses a special sound file format special to - * Dune II, Kyrandia 1 and 2. While Dune II and - * Kyrandia 1 are using exact the same format, the - * one of Kyrandia 2 slightly differs. - * - * See AdlibDriver for more information. - * @see AdlibDriver - */ -class SoundAdlibPC : public Sound { -public: - SoundAdlibPC(KyraEngine_v1 *vm, Audio::Mixer *mixer); - ~SoundAdlibPC(); - - kType getMusicType() const { return kAdlib; } - - bool init(); - void process(); - - void loadSoundFile(uint file); - void loadSoundFile(Common::String file); - - void playTrack(uint8 track); - void haltTrack(); - bool isPlaying(); - - void playSoundEffect(uint8 track); - - void beginFadeOut(); -private: - void internalLoadFile(Common::String file); - - void play(uint8 track); - - void unk1(); - void unk2(); - - AdlibDriver *_driver; - - bool _v2; - uint8 _trackEntries[500]; - uint8 *_soundDataPtr; - int _sfxPlayingSound; - - Common::String _soundFileLoaded; - - uint8 _sfxPriority; - uint8 _sfxFourthByteOfSong; - - int _numSoundTriggers; - const int *_soundTriggers; - - static const int _kyra1NumSoundTriggers; - static const int _kyra1SoundTriggers[]; -}; - -class MidiOutput; - -/** - * MIDI output device. - * - * This device supports both MT-32 MIDI, as used in - * Kyrandia 1 and 2, and GM MIDI, as used in Kyrandia 2. - */ -class SoundMidiPC : public Sound { -public: - SoundMidiPC(KyraEngine_v1 *vm, Audio::Mixer *mixer, MidiDriver *driver); - ~SoundMidiPC(); - - kType getMusicType() const { return _nativeMT32 ? kMidiMT32 : kMidiGM; } - - bool init(); - - void updateVolumeSettings(); - - void loadSoundFile(uint file); - void loadSoundFile(Common::String file); - void loadSfxFile(Common::String file); - - void playTrack(uint8 track); - void haltTrack(); - bool isPlaying(); - - void playSoundEffect(uint8 track); - void stopAllSoundEffects(); - - void beginFadeOut(); - - void hasNativeMT32(bool nativeMT32); -private: - static void onTimer(void *data); - - // Our channel handling - int _musicVolume, _sfxVolume; - - uint32 _fadeStartTime; - bool _fadeMusicOut; - - // Midi file related - Common::String _mFileName, _sFileName; - byte *_musicFile, *_sfxFile; - - MidiParser *_music; - MidiParser *_sfx[3]; - - // misc - bool _nativeMT32; - bool _useC55; - MidiDriver *_driver; - MidiOutput *_output; - - Common::Mutex _mutex; -}; - -class Towns_EuphonyDriver; -class TownsPC98_OpnDriver; - -class SoundTowns : public MidiDriver, public Sound { -public: - SoundTowns(KyraEngine_v1 *vm, Audio::Mixer *mixer); - ~SoundTowns(); - - kType getMusicType() const { return kTowns; } - - bool init(); - void process(); - - void loadSoundFile(uint file); - void loadSoundFile(Common::String) {} - - void playTrack(uint8 track); - void haltTrack(); - - void playSoundEffect(uint8); - - void beginFadeOut(); - - //MidiDriver interface implementation - int open(); - void close(); - void send(uint32 b); - void metaEvent(byte type, byte *data, uint16 length) {} - - void setTimerCallback(void *timerParam, void (*timerProc)(void *)) { } - uint32 getBaseTempo(void); - - //Channel allocation functions - MidiChannel *allocateChannel() { return 0; } - MidiChannel *getPercussionChannel() { return 0; } - - static float calculatePhaseStep(int8 semiTone, int8 semiToneRootkey, - uint32 sampleRate, uint32 outputRate, int32 pitchWheel); - -private: - bool loadInstruments(); - void playEuphonyTrack(uint32 offset, int loop); - - static void onTimer(void *data); - - int _lastTrack; - Audio::AudioStream *_currentSFX; - Audio::SoundHandle _sfxHandle; - - uint _sfxFileIndex; - uint8 *_sfxFileData; - - Towns_EuphonyDriver * _driver; - MidiParser * _parser; - - Common::Mutex _mutex; - - const uint8 *_sfxBTTable; - const uint8 *_sfxWDTable; -}; - -class SoundPC98 : public Sound { -public: - SoundPC98(KyraEngine_v1 *vm, Audio::Mixer *mixer); - ~SoundPC98(); - - virtual kType getMusicType() const { return kPC98; } - - bool init(); - - void process() {} - void loadSoundFile(uint file) {} - void loadSoundFile(Common::String) {} - - void playTrack(uint8 track); - void haltTrack(); - void beginFadeOut(); - - int32 voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, bool isSfx) { return -1; } - void playSoundEffect(uint8); - -protected: - int _lastTrack; - uint8 *_musicTrackData; - uint8 *_sfxTrackData; - TownsPC98_OpnDriver *_driver; -}; - -class SoundTownsPC98_v2 : public Sound { -public: - SoundTownsPC98_v2(KyraEngine_v1 *vm, Audio::Mixer *mixer); - ~SoundTownsPC98_v2(); - - kType getMusicType() const { return _vm->gameFlags().platform == Common::kPlatformFMTowns ? kTowns : kPC98; } - - bool init(); - void process(); - - void loadSoundFile(uint file) {} - void loadSoundFile(Common::String file); - - void playTrack(uint8 track); - void haltTrack(); - void beginFadeOut(); - - int32 voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volume, bool isSfx); - void playSoundEffect(uint8 track); - -protected: - Audio::AudioStream *_currentSFX; - int _lastTrack; - bool _useFmSfx; - - uint8 *_musicTrackData; - uint8 *_sfxTrackData; - TownsPC98_OpnDriver *_driver; -}; - class MixedSoundDriver : public Sound { public: MixedSoundDriver(KyraEngine_v1 *vm, Audio::Mixer *mixer, Sound *music, Sound *sfx) : Sound(vm, mixer), _music(music), _sfx(sfx) {} |