diff options
author | Filippos Karapetis | 2010-01-23 14:39:03 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-01-23 14:39:03 +0000 |
commit | d6e0276119265f825bbd5ab4a418cf234d48ed82 (patch) | |
tree | 042125625524feeda486cd29bfeda12b35b5d89d /engines/sci/sound | |
parent | 18a18701f7dbe9ffeaf9d0c67003090fa8d68534 (diff) | |
download | scummvm-rg350-d6e0276119265f825bbd5ab4a418cf234d48ed82.tar.gz scummvm-rg350-d6e0276119265f825bbd5ab4a418cf234d48ed82.tar.bz2 scummvm-rg350-d6e0276119265f825bbd5ab4a418cf234d48ed82.zip |
Added song manipulation debug commands: songinfo, startsound, togglesound and stopallsounds. is_sample now works with the new sound code
svn-id: r47475
Diffstat (limited to 'engines/sci/sound')
-rw-r--r-- | engines/sci/sound/music.cpp | 64 | ||||
-rw-r--r-- | engines/sci/sound/music.h | 2 | ||||
-rw-r--r-- | engines/sci/sound/soundcmd.cpp | 28 | ||||
-rw-r--r-- | engines/sci/sound/soundcmd.h | 13 |
4 files changed, 97 insertions, 10 deletions
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp index ef75ba96fc..a917e36ab3 100644 --- a/engines/sci/sound/music.cpp +++ b/engines/sci/sound/music.cpp @@ -108,6 +108,16 @@ void SciMusic::pauseAll(bool pause) { } } +void SciMusic::stopAll() { + Common::StackLock lock(_mutex); + + const MusicList::iterator end = _playList.end(); + for (MusicList::iterator i = _playList.begin(); i != end; ++i) { + soundStop(*i); + } +} + + void SciMusic::miditimerCallback(void *p) { SciMusic *aud = (SciMusic *)p; @@ -154,10 +164,8 @@ void SciMusic::sortPlayList() { qsort(pData, _playList.size(), sizeof(MusicEntry *), &f_compare); } void SciMusic::soundInitSnd(MusicEntry *pSnd) { - SoundResource::Track *track = NULL; int channelFilterMask = 0; - - track = pSnd->soundRes->getTrackByType(_pMidiDrv->getPlayId(_soundVersion)); + SoundResource::Track *track = pSnd->soundRes->getTrackByType(_pMidiDrv->getPlayId(_soundVersion)); if (track) { // If MIDI device is selected but there is no digital track in sound resource @@ -223,8 +231,7 @@ void SciMusic::soundPlay(MusicEntry *pSnd) { if (pSnd->pStreamAud && !_pMixer->isSoundHandleActive(pSnd->hCurrentAud)) { if (pSnd->loop > 1) { pSnd->pLoopStream = new Audio::LoopingAudioStream(pSnd->pStreamAud, - pSnd->loop, DisposeAfterUse::NO - ); + pSnd->loop, DisposeAfterUse::NO); _pMixer->playInputStream(pSnd->soundType, &pSnd->hCurrentAud, pSnd->pLoopStream, -1, pSnd->volume, 0, DisposeAfterUse::NO); @@ -358,12 +365,53 @@ void SciMusic::printPlayList(Console *con) { const char *musicStatus[] = { "Stopped", "Initialized", "Paused", "Playing" }; + for (uint32 i = 0; i < _playList.size(); i++) { + MusicEntry *song = _playList[i]; + con->DebugPrintf("%d: %04x:%04x, resource id: %d, status: %s, %s type\n", i, + PRINT_REG(song->soundObj), song->resnum, + musicStatus[song->status], song->pMidiParser ? "MIDI" : "digital audio"); + } +} + +void SciMusic::printSongInfo(reg_t obj, Console *con) { + Common::StackLock lock(_mutex); + + const char *musicStatus[] = { "Stopped", "Initialized", "Paused", "Playing" }; + const MusicList::iterator end = _playList.end(); for (MusicList::iterator i = _playList.begin(); i != end; ++i) { - con->DebugPrintf("%d: %04x:%04x, priority: %d, status: %s\n", i, - PRINT_REG((*i)->soundObj), (*i)->prio, - musicStatus[(*i)->status]); + MusicEntry *song = *i; + if (song->soundObj == obj) { + con->DebugPrintf("Resource id: %d, status: %s\n", song->resnum, musicStatus[song->status]); + con->DebugPrintf("dataInc: %d, hold: %d, loop: %d\n", song->dataInc, song->hold, song->loop); + con->DebugPrintf("signal: %d, priority: %d\n", song->signal, song->prio); + con->DebugPrintf("ticker: %d, volume: %d\n", song->ticker, song->volume); + + if (song->pMidiParser) { + con->DebugPrintf("Type: MIDI\n"); + if (song->soundRes) { + SoundResource::Track *track = song->soundRes->getTrackByType(_pMidiDrv->getPlayId(_soundVersion)); + con->DebugPrintf("Channels: %d\n", track->channelCount); + } + } else if (song->pStreamAud || song->pLoopStream) { + con->DebugPrintf("Type: digital audio (%s), sound active: %s\n", + song->pStreamAud ? "non looping" : "looping", + _pMixer->isSoundHandleActive(song->hCurrentAud) ? "yes" : "no"); + if (song->soundRes) { + con->DebugPrintf("Sound resource information:\n"); + SoundResource::Track *track = song->soundRes->getTrackByType(_pMidiDrv->getPlayId(_soundVersion)); + if (track && track->digitalChannelNr != -1) { + con->DebugPrintf("Sample size: %d, sample rate: %d, channels: %d, digital channel number: %d\n", + track->digitalSampleSize, track->digitalSampleRate, track->channelCount, track->digitalChannelNr); + } + } + } + + return; + } } + + con->DebugPrintf("Song object not found in playlist"); } MusicEntry::MusicEntry() { diff --git a/engines/sci/sound/music.h b/engines/sci/sound/music.h index 660aef9cad..39b6ad0d74 100644 --- a/engines/sci/sound/music.h +++ b/engines/sci/sound/music.h @@ -140,6 +140,7 @@ public: void onTimer(); void clearPlayList(); void pauseAll(bool pause); + void stopAll(); // sound and midi functions void soundInitSnd(MusicEntry *pSnd); @@ -176,6 +177,7 @@ public: } void printPlayList(Console *con); + void printSongInfo(reg_t obj, Console *con); // The following two methods are NOT thread safe - make sure that // the mutex is always locked before calling them diff --git a/engines/sci/sound/soundcmd.cpp b/engines/sci/sound/soundcmd.cpp index f5fb5b4e4f..dcf4b33553 100644 --- a/engines/sci/sound/soundcmd.cpp +++ b/engines/sci/sound/soundcmd.cpp @@ -248,7 +248,7 @@ void SoundCommandParser::cmdInitSound(reg_t obj, int16 value) { if (!obj.segment) return; - int number = obj.segment ? GET_SEL32V(_segMan, obj, number) : 0; + int number = GET_SEL32V(_segMan, obj, number); #ifdef USE_OLD_MUSIC_FUNCTIONS @@ -1072,6 +1072,32 @@ void SoundCommandParser::printPlayList(Console *con) { #endif } +void SoundCommandParser::printSongInfo(reg_t obj, Console *con) { +#ifndef USE_OLD_MUSIC_FUNCTIONS + _music->printSongInfo(obj, con); +#endif +} + +void SoundCommandParser::stopAllSounds() { +#ifndef USE_OLD_MUSIC_FUNCTIONS + _music->stopAll(); +#endif +} + +void SoundCommandParser::startNewSound(int number) { +#ifndef USE_OLD_MUSIC_FUNCTIONS + Common::StackLock lock(_music->_mutex); + + // Overwrite the first sound in the playlist + MusicEntry *song = *_music->getPlayListStart(); + reg_t soundObj = song->soundObj; + cmdDisposeSound(soundObj, 0); + PUT_SEL32V(_segMan, soundObj, number, number); + cmdInitSound(soundObj, 0); + cmdPlaySound(soundObj, 0); +#endif +} + void SoundCommandParser::setMasterVolume(int vol) { #ifndef USE_OLD_MUSIC_FUNCTIONS _music->soundSetMasterVolume(vol); diff --git a/engines/sci/sound/soundcmd.h b/engines/sci/sound/soundcmd.h index fc80b6b3fa..41ce9517a9 100644 --- a/engines/sci/sound/soundcmd.h +++ b/engines/sci/sound/soundcmd.h @@ -58,13 +58,24 @@ public: #endif reg_t parseCommand(int argc, reg_t *argv, reg_t acc); + + // Functions used for game state loading void clearPlayList(); void syncPlayList(Common::Serializer &s); void reconstructPlayList(int savegame_version); - void printPlayList(Console *con); + + // Functions used for the ScummVM menus void setMasterVolume(int vol); void pauseAll(bool pause); + // Debug console functions + void playSound(reg_t obj) { cmdPlaySound(obj, 0); } + void stopSound(reg_t obj) { cmdStopSound(obj, 0); } + void startNewSound(int number); + void stopAllSounds(); + void printPlayList(Console *con); + void printSongInfo(reg_t obj, Console *con); + #ifndef USE_OLD_MUSIC_FUNCTIONS /** * Synchronizes the current state of the music list to the rest of the engine, so that |