mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-04 09:56:30 +00:00
Cleanup, fixed fading of digital sound effects
svn-id: r47023
This commit is contained in:
parent
8ccbe5acd5
commit
3b8512b104
@ -199,7 +199,7 @@ void MidiParser_SCI::parseNextEvent(EventInfo &info) {
|
||||
}
|
||||
}
|
||||
if (info.basic.param1 == 7) // channel volume change -scale it
|
||||
info.basic.param2 = info.basic.param2 * _volume / 0x7F;
|
||||
info.basic.param2 = info.basic.param2 * _volume / MUSIC_VOLUME_MAX;
|
||||
info.length = 0;
|
||||
break;
|
||||
|
||||
@ -474,18 +474,16 @@ byte *MidiParser_SCI::midiFilterChannels(int channelMask) {
|
||||
return _mixedData;
|
||||
}
|
||||
|
||||
void MidiParser_SCI::setVolume(byte bVolume) {
|
||||
if (bVolume > 0x7F)
|
||||
bVolume = 0x7F;
|
||||
if (_volume != bVolume) {
|
||||
_volume = bVolume;
|
||||
void MidiParser_SCI::setVolume(byte volume) {
|
||||
assert(volume <= MUSIC_VOLUME_MAX);
|
||||
if (_volume != volume) {
|
||||
_volume = volume;
|
||||
|
||||
switch (_soundVersion) {
|
||||
case SCI_VERSION_0_EARLY:
|
||||
case SCI_VERSION_0_LATE: {
|
||||
MidiPlayer *SCIDriver = (MidiPlayer *)_driver;
|
||||
int16 globalVolume = _volume * 15 / 127;
|
||||
SCIDriver->setVolume(globalVolume);
|
||||
((MidiPlayer *)_driver)->setVolume(globalVolume);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
void unloadMusic();
|
||||
void setVolume(byte bVolume);
|
||||
void setVolume(byte volume);
|
||||
void stop() {
|
||||
_abort_parse = true;
|
||||
allNotesOff();
|
||||
|
@ -154,6 +154,16 @@ public:
|
||||
uint16 soundGetVoices();
|
||||
uint32 soundGetTempo() const { return _dwTempo; }
|
||||
|
||||
bool soundIsActive(MusicEntry *pSnd) {
|
||||
assert(pSnd->pStreamAud != 0);
|
||||
return _pMixer->isSoundHandleActive(pSnd->hCurrentAud);
|
||||
}
|
||||
|
||||
void updateAudioStreamTicker(MusicEntry *pSnd) {
|
||||
assert(pSnd->pStreamAud != 0);
|
||||
pSnd->ticker = (uint16)(_pMixer->getSoundElapsedTime(pSnd->hCurrentAud) * 0.06);
|
||||
}
|
||||
|
||||
MusicEntry *getSlot(reg_t obj);
|
||||
|
||||
void pushBackSlot(MusicEntry *slotEntry) {
|
||||
|
@ -804,22 +804,20 @@ void SoundCommandParser::cmdUpdateCues(reg_t obj, int16 value) {
|
||||
|
||||
if (musicSlot->pStreamAud) {
|
||||
// Update digital sound effect slots here
|
||||
Audio::Mixer *mixer = g_system->getMixer();
|
||||
|
||||
uint currentLoopCounter = musicSlot->pStreamAud->getNumPlayedLoops();
|
||||
if (currentLoopCounter != musicSlot->sampleLoopCounter) {
|
||||
// during last time we looped at least one time, update loop accordingly
|
||||
musicSlot->loop -= currentLoopCounter - musicSlot->sampleLoopCounter;
|
||||
musicSlot->sampleLoopCounter = currentLoopCounter;
|
||||
}
|
||||
if (!mixer->isSoundHandleActive(musicSlot->hCurrentAud)) {
|
||||
if (!_music->soundIsActive(musicSlot)) {
|
||||
cmdStopSound(obj, 0);
|
||||
} else {
|
||||
musicSlot->ticker = (uint16)(mixer->getSoundElapsedTime(musicSlot->hCurrentAud) * 0.06);
|
||||
_music->updateAudioStreamTicker(musicSlot);
|
||||
}
|
||||
// We get a flag from MusicEntry::doFade() here to set volume for the stream
|
||||
if (musicSlot->fadeSetVolume) {
|
||||
mixer->setChannelVolume(musicSlot->hCurrentAud, musicSlot->volume);
|
||||
_music->soundSetVolume(musicSlot, musicSlot->volume);
|
||||
musicSlot->fadeSetVolume = false;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user