[Scummvm-cvs-logs] SF.net SVN: scummvm:[51695] scummvm/trunk
athrxx at users.sourceforge.net
athrxx at users.sourceforge.net
Tue Aug 3 16:58:01 CEST 2010
Revision: 51695
http://scummvm.svn.sourceforge.net/scummvm/?rev=51695&view=rev
Author: athrxx
Date: 2010-08-03 14:58:01 +0000 (Tue, 03 Aug 2010)
Log Message:
-----------
KYRA/TOWNS: implement music/sfx volume control via GUI/GMM
Modified Paths:
--------------
scummvm/trunk/engines/kyra/sound_intern.h
scummvm/trunk/engines/kyra/sound_towns.cpp
scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.cpp
scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.h
scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_euphony.cpp
scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_euphony.h
scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
Modified: scummvm/trunk/engines/kyra/sound_intern.h
===================================================================
--- scummvm/trunk/engines/kyra/sound_intern.h 2010-08-03 14:10:25 UTC (rev 51694)
+++ scummvm/trunk/engines/kyra/sound_intern.h 2010-08-03 14:58:01 UTC (rev 51695)
@@ -122,6 +122,8 @@
void beginFadeOut();
+ void updateVolumeSettings();
+
private:
bool loadInstruments();
void playEuphonyTrack(uint32 offset, int loop);
Modified: scummvm/trunk/engines/kyra/sound_towns.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sound_towns.cpp 2010-08-03 14:10:25 UTC (rev 51694)
+++ scummvm/trunk/engines/kyra/sound_towns.cpp 2010-08-03 14:58:01 UTC (rev 51695)
@@ -203,6 +203,19 @@
_driver->playSoundEffect(_sfxChannel, note, 127, sfxPlaybackBuffer);
}
+void SoundTowns::updateVolumeSettings() {
+ if (!_driver)
+ return;
+
+ bool mute = false;
+ _driver->setSoundEffectVolume(ConfMan.getInt("sfx_volume"));
+ if (ConfMan.hasKey("mute"))
+ mute = ConfMan.getBool("mute");
+
+ _driver->setMusicVolume((mute ? 0 : ConfMan.getInt("music_volume")));
+ _driver->setSoundEffectVolume((mute ? 0 : ConfMan.getInt("sfx_volume")));
+}
+
void SoundTowns::stopAllSoundEffects() {
_driver->chanVolume(0x46, 0);
_driver->chanVolume(0x47, 0);
@@ -298,7 +311,7 @@
src = src + READ_LE_UINT16(&src[12]) + 32;
}
- _driver->reserveSfxChannels(2);
+ _driver->reserveSoundEffectChannels(2);
delete[] twm;
Modified: scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.cpp
===================================================================
--- scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.cpp 2010-08-03 14:10:25 UTC (rev 51694)
+++ scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.cpp 2010-08-03 14:58:01 UTC (rev 51695)
@@ -101,7 +101,8 @@
TownsAudioInterface::TownsAudioInterface(Audio::Mixer *mixer, TownsAudioInterfacePluginDriver *driver) : TownsPC98_FmSynth(mixer, kTypeTowns),
_fmInstruments(0), _pcmInstruments(0), _pcmChan(0), _waveTables(0), _waveTablesTotalDataSize(0),
- _baserate(55125.0f / (float)mixer->getOutputRate()), _tickLength(0), _timer(0), _drv(driver), _ready(false) {
+ _baserate(55125.0f / (float)mixer->getOutputRate()), _tickLength(0), _timer(0), _drv(driver),
+ _musicVolume(256), _sfxVolume(256), _pcmSfxChanMask(0), _ready(false) {
#define INTCB(x) &TownsAudioInterface::intf_##x
static const TownsAudioIntfCallback intfCb[] = {
@@ -247,6 +248,8 @@
_timer = 0;
+ setVolumeChannelMasks(-1, 0);
+
callback(0);
_ready = true;
@@ -269,6 +272,22 @@
return res;
}
+void TownsAudioInterface::setMusicVolume(int volume) {
+ _musicVolume = CLIP<uint16>(volume, 0, Audio::Mixer::kMaxMixerVolume);
+ setVolumeIntern(_musicVolume, _sfxVolume);
+}
+
+void TownsAudioInterface::setSoundEffectVolume(int volume) {
+ _sfxVolume = CLIP<uint16>(volume, 0, Audio::Mixer::kMaxMixerVolume);
+ setVolumeIntern(_musicVolume, _sfxVolume);
+}
+
+void TownsAudioInterface::setSoundEffectChanMask(uint32 mask) {
+ _pcmSfxChanMask = mask >> 6;
+ mask &= 0x3f;
+ setVolumeChannelMasks(~mask, mask);
+}
+
void TownsAudioInterface::nextTickEx(int32 *buffer, uint32 bufferSize) {
if (!_ready)
return;
@@ -302,6 +321,10 @@
for (int ii = 0; ii < 8; ii++) {
if (_pcmChanOut & _chanFlags[ii]) {
int32 o = _pcmChan[ii].data[_pcmChan[ii].pos >> 11] * _pcmChan[ii].velo;
+ if ((1 << ii) & (~_pcmSfxChanMask))
+ o = (o * _musicVolume) / Audio::Mixer::kMaxMixerVolume;
+ if ((1 << ii) & _pcmSfxChanMask)
+ o = (o * _sfxVolume) / Audio::Mixer::kMaxMixerVolume;
if (_pcmChan[ii].panLeft)
finOutL += ((o * _pcmChan[ii].panLeft) >> 3);
if (_pcmChan[ii].panRight)
Modified: scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.h
===================================================================
--- scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.h 2010-08-03 14:10:25 UTC (rev 51694)
+++ scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_audio.h 2010-08-03 14:58:01 UTC (rev 51695)
@@ -46,6 +46,12 @@
int callback(int command, ...);
+ void setMusicVolume(int volume);
+ void setSoundEffectVolume(int volume);
+ // Defines the channels used as sound effect channels for the purpose of ScummVM GUI volume control.
+ // The first 6 bits are the 6 fm channels. The next 8 bits are pcm channels.
+ void setSoundEffectChanMask(uint32 mask);
+
private:
void nextTickEx(int32 *buffer, uint32 bufferSize);
@@ -148,6 +154,10 @@
uint32 _tickLength;
uint32 _timer;
+ uint16 _musicVolume;
+ uint16 _sfxVolume;
+ uint32 _pcmSfxChanMask;
+
TownsAudioInterfacePluginDriver *_drv;
bool _ready;
Modified: scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_euphony.cpp
===================================================================
--- scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_euphony.cpp 2010-08-03 14:10:25 UTC (rev 51694)
+++ scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_euphony.cpp 2010-08-03 14:58:01 UTC (rev 51695)
@@ -130,8 +130,19 @@
_intf->callback(35, id);
}
-void TownsEuphonyDriver::reserveSfxChannels(int num) {
+void TownsEuphonyDriver::reserveSoundEffectChannels(int num) {
_intf->callback(33, num);
+ uint32 volMask = 0;
+
+ if (num > 8)
+ return;
+
+ for (uint32 v = 1 << 13; num; num--) {
+ volMask |= v;
+ v >>= 1;
+ }
+
+ _intf->setSoundEffectChanMask(volMask);
}
int TownsEuphonyDriver::setMusicTempo(int tempo) {
@@ -289,6 +300,14 @@
}
}
+void TownsEuphonyDriver::setMusicVolume(int volume) {
+ _intf->setMusicVolume(volume);
+}
+
+void TownsEuphonyDriver::setSoundEffectVolume(int volume) {
+ _intf->setSoundEffectVolume(volume);
+}
+
void TownsEuphonyDriver::resetTables() {
memset(_tEnable, 0xff, 32);
memset(_tMode, 0xff, 16);
Modified: scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_euphony.h
===================================================================
--- scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_euphony.h 2010-08-03 14:10:25 UTC (rev 51694)
+++ scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_euphony.h 2010-08-03 14:58:01 UTC (rev 51695)
@@ -39,7 +39,7 @@
void loadInstrument(int chanType, int id, const uint8 *data);
void loadWaveTable(const uint8 *data);
void unloadWaveTable(int id);
- void reserveSfxChannels(int num);
+ void reserveSoundEffectChannels(int num);
int setMusicTempo(int tempo);
int startMusicTrack(const uint8 *data, int trackSize, int startTick);
@@ -66,6 +66,9 @@
void timerCallback(int timerId);
+ void setMusicVolume(int volume);
+ void setSoundEffectVolume(int volume);
+
TownsAudioInterface *intf() {
return _intf;
}
Modified: scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp
===================================================================
--- scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp 2010-08-03 14:10:25 UTC (rev 51694)
+++ scummvm/trunk/sound/softsynth/fmtowns_pc98/towns_pc98_fmsynth.cpp 2010-08-03 14:58:01 UTC (rev 51695)
@@ -1157,12 +1157,12 @@
void TownsPC98_FmSynth::setVolumeIntern(int volA, int volB) {
Common::StackLock lock(_mutex);
- _volumeA = volA;
- _volumeB = volB;
+ _volumeA = CLIP<uint16>(volA, 0, Audio::Mixer::kMaxMixerVolume);
+ _volumeB = CLIP<uint16>(volB, 0, Audio::Mixer::kMaxMixerVolume);
if (_ssg)
- _ssg->setVolumeIntern(volA, volB);
+ _ssg->setVolumeIntern(_volumeA, _volumeB);
if (_prc)
- _prc->setVolumeIntern(volA, volB);
+ _prc->setVolumeIntern(_volumeA, _volumeB);
}
void TownsPC98_FmSynth::setVolumeChannelMasks(int channelMaskA, int channelMaskB) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list