make even more use of Scumm::_musicEngine; added MusicEngine::setMasterVolume
svn-id: r10097
This commit is contained in:
parent
07cfd2d0ee
commit
90ec1dc34e
9 changed files with 62 additions and 85 deletions
|
@ -364,76 +364,63 @@ bool ScummDebugger::Cmd_Restart(int argc, const char **argv) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ScummDebugger::Cmd_IMuse (int argc, const char **argv) {
|
||||
bool ScummDebugger::Cmd_IMuse(int argc, const char **argv) {
|
||||
if (!_s->_imuse && !_s->_playerV2) {
|
||||
Debug_Printf ("No iMuse engine is active.\n");
|
||||
Debug_Printf("No iMuse engine is active.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
if (!strcmp (argv[1], "panic")) {
|
||||
if (_s->_imuse)
|
||||
_s->_imuse->stopAllSounds();
|
||||
if (_s->_playerV2)
|
||||
_s->_playerV2->stopAllSounds();
|
||||
Debug_Printf ("AAAIIIEEEEEE!\n");
|
||||
Debug_Printf ("Shutting down all music tracks\n");
|
||||
if (!strcmp(argv[1], "panic")) {
|
||||
_s->_musicEngine->stopAllSounds();
|
||||
Debug_Printf("AAAIIIEEEEEE!\n");
|
||||
Debug_Printf("Shutting down all music tracks\n");
|
||||
return true;
|
||||
} else if (!strcmp (argv[1], "multimidi")) {
|
||||
if (argc > 2 && (!strcmp (argv[2], "on") || !strcmp (argv[2], "off"))) {
|
||||
if (argc > 2 && (!strcmp(argv[2], "on") || !strcmp(argv[2], "off"))) {
|
||||
if (_s->_imuse)
|
||||
_s->_imuse->property (IMuse::PROP_MULTI_MIDI, !strcmp (argv[2], "on"));
|
||||
Debug_Printf ("MultiMidi mode switched %s.\n", argv[2]);
|
||||
_s->_imuse->property(IMuse::PROP_MULTI_MIDI, !strcmp(argv[2], "on"));
|
||||
Debug_Printf("MultiMidi mode switched %s.\n", argv[2]);
|
||||
} else {
|
||||
Debug_Printf ("Specify \"on\" or \"off\" to switch.\n");
|
||||
Debug_Printf("Specify \"on\" or \"off\" to switch.\n");
|
||||
}
|
||||
return true;
|
||||
} else if (!strcmp (argv[1], "play")) {
|
||||
if (argc > 2 && (!strcmp (argv[2], "random") || atoi (argv[2]) != 0)) {
|
||||
int sound = atoi (argv[2]);
|
||||
if (!strcmp (argv[2], "random")) {
|
||||
Debug_Printf ("Selecting from %d songs...\n", _s->getNumSounds());
|
||||
sound = _s->_rnd.getRandomNumber (_s->getNumSounds());
|
||||
} else if (!strcmp(argv[1], "play")) {
|
||||
if (argc > 2 && (!strcmp(argv[2], "random") || atoi(argv[2]) != 0)) {
|
||||
int sound = atoi(argv[2]);
|
||||
if (!strcmp(argv[2], "random")) {
|
||||
Debug_Printf("Selecting from %d songs...\n", _s->getNumSounds());
|
||||
sound = _s->_rnd.getRandomNumber(_s->getNumSounds());
|
||||
}
|
||||
_s->ensureResourceLoaded(rtSound, sound);
|
||||
if (_s->_imuse)
|
||||
_s->_imuse->startSound(sound);
|
||||
if (_s->_playerV2) {
|
||||
_s->_playerV2->startSound(sound);
|
||||
}
|
||||
_s->_musicEngine->startSound(sound);
|
||||
|
||||
Debug_Printf ("Attempted to start music %d.\n", sound);
|
||||
Debug_Printf("Attempted to start music %d.\n", sound);
|
||||
} else {
|
||||
Debug_Printf ("Specify a music resource # from 1-255.\n");
|
||||
Debug_Printf("Specify a music resource # from 1-255.\n");
|
||||
}
|
||||
return true;
|
||||
} else if (!strcmp (argv[1], "stop")) {
|
||||
if (argc > 2 && (!strcmp (argv[2], "all") || atoi (argv[2]) != 0)) {
|
||||
if (!strcmp (argv[2], "all")) {
|
||||
if (_s->_imuse)
|
||||
_s->_imuse->stopAllSounds();
|
||||
if (_s->_playerV2)
|
||||
_s->_playerV2->stopAllSounds();
|
||||
Debug_Printf ("Shutting down all music tracks.\n");
|
||||
} else if (!strcmp(argv[1], "stop")) {
|
||||
if (argc > 2 && (!strcmp(argv[2], "all") || atoi(argv[2]) != 0)) {
|
||||
if (!strcmp(argv[2], "all")) {
|
||||
_s->_musicEngine->stopAllSounds();
|
||||
Debug_Printf("Shutting down all music tracks.\n");
|
||||
} else {
|
||||
if (_s->_imuse)
|
||||
_s->_imuse->stopSound(atoi (argv[2]));
|
||||
if (_s->_playerV2)
|
||||
_s->_playerV2->stopSound(atoi (argv[2]));
|
||||
Debug_Printf ("Attempted to stop music %d.\n", atoi (argv[2]));
|
||||
_s->_musicEngine->stopSound(atoi(argv[2]));
|
||||
Debug_Printf("Attempted to stop music %d.\n", atoi(argv[2]));
|
||||
}
|
||||
} else {
|
||||
Debug_Printf ("Specify a music resource # or \"all\".\n");
|
||||
Debug_Printf("Specify a music resource # or \"all\".\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Debug_Printf ("Available iMuse commands:\n");
|
||||
Debug_Printf (" panic - Stop all music tracks\n");
|
||||
Debug_Printf (" multimidi on/off - Toggle dual MIDI drivers\n");
|
||||
Debug_Printf (" play # - Play a music resource\n");
|
||||
Debug_Printf (" stop # - Stop a music resource\n");
|
||||
Debug_Printf("Available iMuse commands:\n");
|
||||
Debug_Printf(" panic - Stop all music tracks\n");
|
||||
Debug_Printf(" multimidi on/off - Toggle dual MIDI drivers\n");
|
||||
Debug_Printf(" play # - Play a music resource\n");
|
||||
Debug_Printf(" stop # - Stop a music resource\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -536,10 +536,9 @@ void OptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
|
|||
|
||||
if (_scumm->_imuse) {
|
||||
_scumm->_imuse->set_music_volume(_soundVolumeMusic);
|
||||
_scumm->_imuse->setMasterVolume(_soundVolumeMaster);
|
||||
}
|
||||
if (_scumm->_playerV2) {
|
||||
_scumm->_playerV2->setMasterVolume(_soundVolumeMaster);
|
||||
if (_scumm->_musicEngine) {
|
||||
_scumm->_musicEngine->setMasterVolume(_soundVolumeMaster);
|
||||
}
|
||||
|
||||
_scumm->_mixer->setVolume(_soundVolumeSfx * _soundVolumeMaster / 255);
|
||||
|
|
|
@ -1752,7 +1752,7 @@ void IMuse::pause(bool paused) { in(); _target->pause(paused); out(); }
|
|||
int IMuse::save_or_load(Serializer *ser, Scumm *scumm) { in(); int ret = _target->save_or_load(ser, scumm); out(); return ret; }
|
||||
int IMuse::set_music_volume(uint vol) { in(); int ret = _target->set_music_volume(vol); out(); return ret; }
|
||||
int IMuse::get_music_volume() { in(); int ret = _target->get_music_volume(); out(); return ret; }
|
||||
int IMuse::setMasterVolume(uint vol) { in(); int ret = _target->setMasterVolume(vol); out(); return ret; }
|
||||
void IMuse::setMasterVolume(int vol) { in(); _target->setMasterVolume(vol); out(); }
|
||||
int IMuse::get_master_volume() { in(); int ret = _target->get_master_volume(); out(); return ret; }
|
||||
void IMuse::startSound(int sound) { in(); _target->startSound(sound); out(); }
|
||||
void IMuse::stopSound(int sound) { in(); _target->stopSound(sound); out(); }
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
int save_or_load(Serializer *ser, Scumm *scumm);
|
||||
int set_music_volume(uint vol);
|
||||
int get_music_volume();
|
||||
int setMasterVolume(uint vol);
|
||||
void setMasterVolume(int vol);
|
||||
int get_master_volume();
|
||||
void startSound(int sound);
|
||||
void stopSound(int sound);
|
||||
|
|
|
@ -689,11 +689,11 @@ static byte *readCreativeVocFile(byte *ptr, int32 &size, int &rate) {
|
|||
return ret_sound;
|
||||
}
|
||||
|
||||
static void imus_digital_handler(void *engine) {
|
||||
void IMuseDigital::timer_handler(void *engine) {
|
||||
// Avoid race condition
|
||||
Scumm *scumm = (Scumm *)engine;
|
||||
if (scumm && scumm->_imuseDigital)
|
||||
scumm->_imuseDigital->handler();
|
||||
scumm->_imuseDigital->musicTimer();
|
||||
}
|
||||
|
||||
IMuseDigital::IMuseDigital(Scumm *scumm)
|
||||
|
@ -702,19 +702,19 @@ IMuseDigital::IMuseDigital(Scumm *scumm)
|
|||
for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
|
||||
_channel[l]._mixerChannel = 0;
|
||||
}
|
||||
_scumm->_timer->installProcedure(imus_digital_handler, 200000);
|
||||
_scumm->_timer->installProcedure(timer_handler, 200000);
|
||||
_pause = false;
|
||||
}
|
||||
|
||||
IMuseDigital::~IMuseDigital() {
|
||||
_scumm->_timer->releaseProcedure(imus_digital_handler);
|
||||
_scumm->_timer->releaseProcedure(timer_handler);
|
||||
|
||||
for (int l = 0; l < MAX_DIGITAL_CHANNELS; l++) {
|
||||
_scumm->_mixer->stopChannel(_channel[l]._mixerChannel);
|
||||
}
|
||||
}
|
||||
|
||||
void IMuseDigital::handler() {
|
||||
void IMuseDigital::musicTimer() {
|
||||
int l = 0;
|
||||
|
||||
if (_pause)
|
||||
|
|
|
@ -63,10 +63,15 @@ private:
|
|||
Scumm *_scumm;
|
||||
bool _pause;
|
||||
|
||||
static void timer_handler(void *engine);
|
||||
void musicTimer();
|
||||
|
||||
public:
|
||||
IMuseDigital(Scumm *scumm);
|
||||
~IMuseDigital();
|
||||
void handler();
|
||||
|
||||
void setMasterVolume(int vol) {}
|
||||
|
||||
void startSound(int sound);
|
||||
void stopSound(int sound);
|
||||
void stopAllSounds();
|
||||
|
|
|
@ -30,7 +30,7 @@ class MusicEngine {
|
|||
public:
|
||||
virtual ~MusicEngine() {}
|
||||
|
||||
// virtual void setMasterVolume(int vol) = 0;
|
||||
virtual void setMasterVolume(int vol) = 0;
|
||||
|
||||
virtual void startSound(int sound) = 0;
|
||||
virtual void stopSound(int sound) = 0;
|
||||
|
|
|
@ -700,7 +700,7 @@ Scumm::Scumm (GameDetector *detector, OSystem *syst)
|
|||
} else if ((_features & GF_AMIGA) && (_version == 3)) {
|
||||
_musicEngine = _playerV3A = new Player_V3A(this);
|
||||
} else if ((_features & GF_AMIGA) && (_version < 5)) {
|
||||
_playerV2 = NULL;
|
||||
_musicEngine = NULL;
|
||||
} else if (((_midiDriver == MD_PCJR) || (_midiDriver == MD_PCSPK)) && ((_version > 2) && (_version < 5))) {
|
||||
_musicEngine = _playerV2 = new Player_V2(this);
|
||||
} else if (_version > 2) {
|
||||
|
@ -787,10 +787,7 @@ Scumm::~Scumm () {
|
|||
delete _confirmExitDialog;
|
||||
|
||||
delete _sound;
|
||||
delete _imuse;
|
||||
delete _imuseDigital;
|
||||
delete _playerV2;
|
||||
delete _playerV3A;
|
||||
delete _musicEngine;
|
||||
free(_languageBuffer);
|
||||
free(_audioNames);
|
||||
|
||||
|
|
|
@ -672,17 +672,8 @@ int Sound::isSoundRunning(int sound) const {
|
|||
if (!_scumm->isResourceLoaded(rtSound, sound))
|
||||
return 0;
|
||||
|
||||
if (_scumm->_imuseDigital)
|
||||
return _scumm->_imuseDigital->getSoundStatus(sound);
|
||||
|
||||
if (_scumm->_imuse)
|
||||
return _scumm->_imuse->getSoundStatus(sound);
|
||||
|
||||
if (_scumm->_playerV2)
|
||||
return _scumm->_playerV2->getSoundStatus(sound);
|
||||
|
||||
if (_scumm->_playerV3A)
|
||||
return _scumm->_playerV3A->getSoundStatus(sound);
|
||||
if (_scumm->_musicEngine)
|
||||
return _scumm->_musicEngine->getSoundStatus(sound);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -770,23 +761,21 @@ void Sound::stopAllSounds() {
|
|||
stopCD();
|
||||
}
|
||||
|
||||
if (_scumm->_imuse) {
|
||||
_scumm->_imuse->stopAllSounds();
|
||||
_scumm->_imuse->clear_queue();
|
||||
} else if (_scumm->_playerV2) {
|
||||
_scumm->_playerV2->stopAllSounds();
|
||||
} else if (_scumm->_playerV3A) {
|
||||
_scumm->_playerV3A->stopAllSounds();
|
||||
}
|
||||
|
||||
// Clear the (secondary) sound queue
|
||||
_soundQue2Pos = 0;
|
||||
memset(_soundQue2, 0, sizeof(_soundQue2));
|
||||
|
||||
if (_scumm->_musicEngine) {
|
||||
_scumm->_musicEngine->stopAllSounds();
|
||||
}
|
||||
if (_scumm->_imuse) {
|
||||
// FIXME: Maybe we could merge this call to clear_queue()
|
||||
// into IMuse::stopAllSounds() ?
|
||||
_scumm->_imuse->clear_queue();
|
||||
}
|
||||
|
||||
// Stop all SFX
|
||||
if (_scumm->_imuseDigital) {
|
||||
_scumm->_imuseDigital->stopAllSounds();
|
||||
} else {
|
||||
if (!_scumm->_imuseDigital) {
|
||||
_scumm->_mixer->stopAll();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue