aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMax Horn2008-01-05 22:44:39 +0000
committerMax Horn2008-01-05 22:44:39 +0000
commitf68d84b54f3bd1857ec57940a8b792a66168c484 (patch)
treecbad84e5485c294649a3515c12a7352c0dcbe0b0 /engines
parent923ad313dc1e85ff3e2169f08abe0b2e016896c2 (diff)
downloadscummvm-rg350-f68d84b54f3bd1857ec57940a8b792a66168c484.tar.gz
scummvm-rg350-f68d84b54f3bd1857ec57940a8b792a66168c484.tar.bz2
scummvm-rg350-f68d84b54f3bd1857ec57940a8b792a66168c484.zip
Moved some code which was being duplicated to methods of class Track
svn-id: r30266
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/imuse_digi/dimuse.cpp34
-rw-r--r--engines/scumm/imuse_digi/dimuse.h13
-rw-r--r--engines/scumm/imuse_digi/dimuse_track.cpp30
3 files changed, 21 insertions, 56 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp
index 9c28a67d41..25091e5309 100644
--- a/engines/scumm/imuse_digi/dimuse.cpp
+++ b/engines/scumm/imuse_digi/dimuse.cpp
@@ -206,18 +206,7 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags));
- const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
- const int vol = track->vol / 1000;
- Audio::Mixer::SoundType type = Audio::Mixer::kPlainSoundType;
-
- if (track->volGroupId == 1)
- type = Audio::Mixer::kSpeechSoundType;
- if (track->volGroupId == 2)
- type = Audio::Mixer::kSFXSoundType;
- if (track->volGroupId == 3)
- type = Audio::Mixer::kMusicSoundType;
-
- _mixer->playInputStream(type, &track->mixChanHandle, track->stream, -1, vol, pan, false);
+ _mixer->playInputStream(track->getType(), &track->mixChanHandle, track->stream, -1, track->getVol(), track->getPan(), false);
_mixer->pauseHandle(track->mixChanHandle, true);
}
}
@@ -264,17 +253,6 @@ void IMuseDigital::callback() {
debug(5, "Fade: sound(%d), Vol(%d)", track->soundId, track->vol / 1000);
}
- const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
- const int vol = track->vol / 1000;
- Audio::Mixer::SoundType type = Audio::Mixer::kPlainSoundType;
-
- if (track->volGroupId == 1)
- type = Audio::Mixer::kSpeechSoundType;
- if (track->volGroupId == 2)
- type = Audio::Mixer::kSFXSoundType;
- if (track->volGroupId == 3)
- type = Audio::Mixer::kMusicSoundType;
-
if (!track->souStreamUsed) {
assert(track->stream);
byte *tmpSndBufferPtr = NULL;
@@ -341,8 +319,8 @@ void IMuseDigital::callback() {
curFeedSize = feedSize;
if (_mixer->isReady()) {
- _mixer->setChannelVolume(track->mixChanHandle, vol);
- _mixer->setChannelBalance(track->mixChanHandle, pan);
+ _mixer->setChannelVolume(track->mixChanHandle, track->getVol());
+ _mixer->setChannelBalance(track->mixChanHandle, track->getPan());
track->stream->queueBuffer(tmpSndBufferPtr, curFeedSize);
track->regionOffset += curFeedSize;
} else
@@ -363,10 +341,10 @@ void IMuseDigital::callback() {
if (!track->mixerStreamRunning) {
track->mixerStreamRunning = true;
assert(track->streamSou);
- _mixer->playInputStream(type, &track->mixChanHandle, track->streamSou, -1, vol, pan);
+ _mixer->playInputStream(track->getType(), &track->mixChanHandle, track->streamSou, -1, track->getVol(), track->getPan());
} else {
- _mixer->setChannelVolume(track->mixChanHandle, vol);
- _mixer->setChannelBalance(track->mixChanHandle, pan);
+ _mixer->setChannelVolume(track->mixChanHandle, track->getVol());
+ _mixer->setChannelBalance(track->mixChanHandle, track->getPan());
}
}
}
diff --git a/engines/scumm/imuse_digi/dimuse.h b/engines/scumm/imuse_digi/dimuse.h
index d6aa6d271f..c7029dac91 100644
--- a/engines/scumm/imuse_digi/dimuse.h
+++ b/engines/scumm/imuse_digi/dimuse.h
@@ -103,6 +103,19 @@ private:
Audio::AudioStream *streamSou; // sound mixer's audio stream handle for *.sou
Track();
+
+ int getPan() const { return (pan != 64) ? 2 * pan - 127 : 0; }
+ int getVol() const { return vol / 1000; }
+ Audio::Mixer::SoundType getType() const {
+ Audio::Mixer::SoundType type = Audio::Mixer::kPlainSoundType;
+ if (volGroupId == 1)
+ type = Audio::Mixer::kSpeechSoundType;
+ else if (volGroupId == 2)
+ type = Audio::Mixer::kSFXSoundType;
+ else if (volGroupId == 3)
+ type = Audio::Mixer::kMusicSoundType;
+ return type;
+ }
};
Track *_track[MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS];
diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp
index f7cc3f27af..0f7d6a5198 100644
--- a/engines/scumm/imuse_digi/dimuse_track.cpp
+++ b/engines/scumm/imuse_digi/dimuse_track.cpp
@@ -155,19 +155,8 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
track->mixerFlags |= kFlagLittleEndian;
#endif
- const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
- const int vol = track->vol / 1000;
- Audio::Mixer::SoundType type = Audio::Mixer::kPlainSoundType;
-
- if (track->volGroupId == 1)
- type = Audio::Mixer::kSpeechSoundType;
- if (track->volGroupId == 2)
- type = Audio::Mixer::kSFXSoundType;
- if (track->volGroupId == 3)
- type = Audio::Mixer::kMusicSoundType;
-
track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags));
- _mixer->playInputStream(type, &track->mixChanHandle, track->stream, -1, vol, pan, false);
+ _mixer->playInputStream(track->getType(), &track->mixChanHandle, track->stream, -1, track->getVol(), track->getPan(), false);
track->mixerStreamRunning = true;
}
@@ -328,23 +317,8 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDel
fadeTrack->volFadeUsed = true;
// Create an appendable output buffer
- Audio::Mixer::SoundType type;
- switch (fadeTrack->volGroupId) {
- case 1:
- type = Audio::Mixer::kSpeechSoundType;
- break;
- case 2:
- type = Audio::Mixer::kSFXSoundType;
- break;
- case 3:
- type = Audio::Mixer::kMusicSoundType;
- break;
- default:
- type = Audio::Mixer::kPlainSoundType;
- break;
- }
fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundDesc), makeMixerFlags(fadeTrack->mixerFlags));
- _mixer->playInputStream(type, &fadeTrack->mixChanHandle, fadeTrack->stream, -1, fadeTrack->vol / 1000, fadeTrack->pan, false);
+ _mixer->playInputStream(track->getType(), &fadeTrack->mixChanHandle, fadeTrack->stream, -1, fadeTrack->getVol(), fadeTrack->pan, false);
fadeTrack->mixerStreamRunning = true;
fadeTrack->used = true;