diff options
-rw-r--r-- | engines/kyra/sound.cpp | 7 | ||||
-rw-r--r-- | engines/kyra/sound.h | 9 | ||||
-rw-r--r-- | engines/kyra/sound_midi.cpp | 23 |
3 files changed, 37 insertions, 2 deletions
diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp index 63a97185c8..5699cce5db 100644 --- a/engines/kyra/sound.cpp +++ b/engines/kyra/sound.cpp @@ -166,6 +166,13 @@ void KyraEngine_v1::snd_playTheme(int file, int track) { _curSfxFile = _curMusicTheme = file; _sound->loadSoundFile(_curMusicTheme); + + // Kyrandia 2 uses a special file for + // MIDI sound effects, so we load + // this here + if (_flags.gameID == GI_KYRA2) + _sound->loadSfxFile("K2SFX"); + if (track != -1) _sound->playTrack(track); } diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h index 93dc085136..5b8e82bcc4 100644 --- a/engines/kyra/sound.h +++ b/engines/kyra/sound.h @@ -121,11 +121,17 @@ public: /** * Load a sound file for playing music - * and sound effects from. + * (and somtimes sound effects) from. */ virtual void loadSoundFile(Common::String file) = 0; /** + * Load a sound file for playing sound + * effects from. + */ + virtual void loadSfxFile(Common::String file) { } + + /** * Plays the specified track. * * @param track track number @@ -321,6 +327,7 @@ public: void loadSoundFile(uint file); void loadSoundFile(Common::String file); + void loadSfxFile(Common::String file); void playTrack(uint8 track); void haltTrack(); diff --git a/engines/kyra/sound_midi.cpp b/engines/kyra/sound_midi.cpp index 606d849221..d611f4b1e2 100644 --- a/engines/kyra/sound_midi.cpp +++ b/engines/kyra/sound_midi.cpp @@ -157,8 +157,10 @@ MidiOutput::MidiOutput(OSystem *system, MidiDriver *output, bool isMT32, bool de sendIntern(0xC0, i, defaultPrograms[i-1], 0x00); } - for (int i = 0; i < 4; ++i) + for (int i = 0; i < 4; ++i) { + _sources[i].volume = 0xFF; initSource(i); + } } @@ -458,6 +460,7 @@ SoundMidiPC::SoundMidiPC(KyraEngine_v1 *vm, Audio::Mixer *mixer, MidiDriver *dri } _musicVolume = _sfxVolume = 0; + _fadeMusicOut = false; } SoundMidiPC::~SoundMidiPC() { @@ -566,6 +569,24 @@ void SoundMidiPC::loadSoundFile(Common::String file) { } } +void SoundMidiPC::loadSfxFile(Common::String file) { + Common::StackLock lock(_mutex); + + file += _useC55 ? ".C55" : ".XMI"; + if (!_vm->resource()->exists(file.c_str())) + return; + + if (_sfxFile != _musicFile) + delete[] _sfxFile; + + _sfxFile = _vm->resource()->fileData(file.c_str(), &_sfxFileSize); + for (int i = 0; i < 3; ++i) { + _output->setSoundSource(i+1); + _sfx[i]->loadMusic(_sfxFile, _sfxFileSize); + _sfx[i]->stopPlaying(); + } +} + void SoundMidiPC::playTrack(uint8 track) { Common::StackLock lock(_mutex); _output->initSource(0); |