From e5ffc7847cb70f792b4658aa032959949e849669 Mon Sep 17 00:00:00 2001 From: Florian Kagerer Date: Wed, 4 Aug 2010 16:53:09 +0000 Subject: AUDIO: Implement volume and balance control for the AudioCD manager (needed for music fading in Kyra 1 FM-Towns and probably other FM-Towns games). This addition applies to emulated CD audio only for now. I haven't found a way to implement this for real CDs yet. SDL doesn't seem to support this (but it might be just me? If anyone knows more about this, just tell me). svn-id: r51741 --- sound/audiocd.cpp | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'sound/audiocd.cpp') diff --git a/sound/audiocd.cpp b/sound/audiocd.cpp index 7afbd12d03..625def58fe 100644 --- a/sound/audiocd.cpp +++ b/sound/audiocd.cpp @@ -42,6 +42,8 @@ AudioCDManager::AudioCDManager() { _cd.start = 0; _cd.duration = 0; _cd.numLoops = 0; + _cd.volume = Mixer::kMaxChannelVolume; + _cd.balance = 0; _mixer = g_system->getMixer(); _emulating = false; assert(_mixer); @@ -79,7 +81,8 @@ void AudioCDManager::play(int track, int numLoops, int startFrame, int duration, */ _emulating = true; _mixer->playStream(Mixer::kMusicSoundType, &_handle, - makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops)); + makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops), -1, _cd.volume, _cd.balance); + } else { _emulating = false; if (!only_emulate) @@ -109,6 +112,38 @@ bool AudioCDManager::isPlaying() const { } } +void AudioCDManager::setVolume(byte volume) { + _cd.volume = volume; + if (_emulating) { + // Audio CD emulation + if (_mixer->isSoundHandleActive(_handle)) + _mixer->setChannelVolume(_handle, _cd.volume); + } else { + // Real Audio CD + + // Unfortunately I can't implement this atm + // since SDL doesn't seem to offer an interface method for this. + + // g_system->setVolumeCD(_cd.volume); + } +} + +void AudioCDManager::setBalance(int8 balance) { + _cd.balance = balance; + if (_emulating) { + // Audio CD emulation + if (isPlaying()) + _mixer->setChannelBalance(_handle, _cd.balance); + } else { + // Real Audio CD + + // Unfortunately I can't implement this atm + // since SDL doesn't seem to offer an interface method for this. + + // g_system->setBalanceCD(_cd.balance); + } +} + void AudioCDManager::updateCD() { if (_emulating) { // Check whether the audio track stopped playback -- cgit v1.2.3