mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
- Fix some valgrind warnings
- Added MIDI SFX support for Kyra2 svn-id: r35178
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -121,10 +121,16 @@ 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.
|
||||
*
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user