aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-11-01 18:12:04 +0000
committerTorbjörn Andersson2003-11-01 18:12:04 +0000
commitae9fe77479fb7722bda25beb1baaf6507b55862a (patch)
tree2302ab6ea6e94c1b6b26fe6f474f6901b0d84c0a
parent0435658b968fef8736b137ce2a50648e656f0bf5 (diff)
downloadscummvm-rg350-ae9fe77479fb7722bda25beb1baaf6507b55862a.tar.gz
scummvm-rg350-ae9fe77479fb7722bda25beb1baaf6507b55862a.tar.bz2
scummvm-rg350-ae9fe77479fb7722bda25beb1baaf6507b55862a.zip
Instead of having a function that reverses the panning table, we now have a
function that creates the panning table. The difference is that you now have to tell whether you want one for normal or reverse stereo, so you are not dependent on the previous state of the table. (I still think it may be possible to get rid of the panning table completely, but that's for later cleanups.) svn-id: r11027
-rw-r--r--sword2/controls.cpp42
-rw-r--r--sword2/driver/d_sound.cpp35
-rw-r--r--sword2/driver/d_sound.h4
3 files changed, 39 insertions, 42 deletions
diff --git a/sword2/controls.cpp b/sword2/controls.cpp
index 6b0c4fa7fe..71376c2911 100644
--- a/sword2/controls.cpp
+++ b/sword2/controls.cpp
@@ -777,9 +777,9 @@ public:
gui->readOptionSettings();
- _objectLabelsSwitch->setValue(gui->_pointerTextSelected != 0);
- _subtitlesSwitch->setValue(gui->_subtitles != 0);
- _reverseStereoSwitch->setValue(gui->_stereoReversed != 0);
+ _objectLabelsSwitch->setValue(gui->_pointerTextSelected);
+ _subtitlesSwitch->setValue(gui->_subtitles);
+ _reverseStereoSwitch->setValue(gui->_stereoReversed);
_musicSwitch->setValue(!g_sound->isMusicMute());
_speechSwitch->setValue(!g_sound->isSpeechMute());
_fxSwitch->setValue(!g_sound->isFxMute());
@@ -839,14 +839,9 @@ public:
virtual void onAction(Widget *widget, int result = 0) {
// Since there is music playing while the dialog is displayed
- // we need to update music volume immediately. Everything else
- // is handled when the dialog is terminated.
-
- if (widget == _reverseStereoSwitch) {
- if (result != gui->_stereoReversed)
- g_sound->reverseStereo();
- gui->_stereoReversed = result;
- } else if (widget == _musicSwitch) {
+ // we need to update music volume immediately.
+
+ if (widget == _musicSwitch) {
g_sound->muteMusic(result);
} else if (widget == _musicSlider) {
g_sound->setMusicVolume(result);
@@ -860,6 +855,10 @@ public:
_gfxPreview->setState(result);
gui->updateGraphicsLevel(result);
} else if (widget == _okButton) {
+ gui->_subtitles = _subtitlesSwitch->getValue();
+ gui->_pointerTextSelected = _objectLabelsSwitch->getValue();
+ gui->_stereoReversed = _reverseStereoSwitch->getValue();
+
// Apply the changes
g_sound->muteMusic(!_musicSwitch->getValue());
g_sound->muteSpeech(!_speechSwitch->getValue());
@@ -867,13 +866,10 @@ public:
g_sound->setMusicVolume(_musicSlider->getValue());
g_sound->setSpeechVolume(_speechSlider->getValue());
g_sound->setFxVolume(_fxSlider->getValue());
+ g_sound->buildPanTable(gui->_stereoReversed);
gui->updateGraphicsLevel(_gfxSlider->getValue());
- gui->_subtitles = _subtitlesSwitch->getValue();
- gui->_pointerTextSelected = _objectLabelsSwitch->getValue();
- gui->_stereoReversed = _reverseStereoSwitch->getValue();
-
gui->writeOptionSettings();
setResult(1);
} else if (widget == _cancelButton) {
@@ -1365,7 +1361,11 @@ Gui::Gui() : _baseSlot(0) {
}
void Gui::readOptionSettings(void) {
- bool newStereoReversed;
+ _subtitles = !ConfMan.getBool("nosubtitles");
+ _pointerTextSelected = ConfMan.getBool("object_labels");
+ _stereoReversed = ConfMan.getBool("reverse_stereo");
+
+ updateGraphicsLevel((uint8) ConfMan.getInt("gfx_details"));
g_sound->setMusicVolume((16 * ConfMan.getInt("music_volume")) / 255);
g_sound->setSpeechVolume((14 * ConfMan.getInt("speech_volume")) / 255);
@@ -1373,15 +1373,7 @@ void Gui::readOptionSettings(void) {
g_sound->muteMusic(ConfMan.getBool("music_mute"));
g_sound->muteSpeech(ConfMan.getBool("speech_mute"));
g_sound->muteFx(ConfMan.getBool("sfx_mute"));
- updateGraphicsLevel((uint8) ConfMan.getInt("gfx_details"));
- _subtitles = !ConfMan.getBool("nosubtitles");
- _pointerTextSelected = ConfMan.getBool("object_labels");
- newStereoReversed = ConfMan.getBool("reverse_stereo");
-
- if (_stereoReversed != newStereoReversed)
- g_sound->reverseStereo();
-
- _stereoReversed = newStereoReversed;
+ g_sound->buildPanTable(_stereoReversed);
}
void Gui::writeOptionSettings(void) {
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index ca776e1118..2794f45989 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -52,14 +52,6 @@ static File fpMus;
#define GetCompressedSign(n) (((n) >> 3) & 1)
#define GetCompressedAmplitude(n) ((n) & 7)
-static int32 panTable[33] = {
- -127, -119, -111, -103, -95, -87, -79, -71,
- -63, -55, -47, -39, -31, -23, -15, -7,
- 0,
- 7, 15, 23, 31, 39, 47, 55, 63,
- 71, 79, 87, 95, 103, 111, 119, 127
-};
-
static int32 musicVolTable[17] = {
0, 15, 31, 47, 63, 79, 95, 111, 127,
143, 159, 175, 191, 207, 223, 239, 255
@@ -165,12 +157,23 @@ Sound::~Sound() {
// FIXME: We could probably use the FLAG_REVERSE_STEREO mixer flag here.
/**
- * This function reverses the pan table, thus reversing the stereo.
+ * This function creates the pan table.
*/
-void Sound::reverseStereo(void) {
- for (int i = 0; i < 16; i++)
- SWAP(panTable[i], panTable[32 - i]);
+void Sound::buildPanTable(bool reverse) {
+ int i;
+
+ for (i = 0; i < 16; i++) {
+ _panTable[i] = -127 + i * 8;
+ _panTable[i + 17] = (i + 1) * 8 - 1;
+ }
+
+ _panTable[16] = 0;
+
+ if (reverse) {
+ for (i = 0; i < 33; i++)
+ _panTable[i] = -_panTable[i];
+ }
}
// Save/Restore information about current music so that we can restore it
@@ -407,7 +410,7 @@ int32 Sound::playCompSpeech(const char *filename, uint32 speechid, uint8 vol, in
// Modify the volume according to the master volume
byte volume = _speechMuted ? 0 : vol * _speechVol;
- int8 p = panTable[pan + 16];
+ int8 p = _panTable[pan + 16];
// Start the speech playing
@@ -659,7 +662,7 @@ int32 Sound::playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type) {
// Start the sound effect playing
byte volume = _fxMuted ? 0 : vol * _fxVol;
- int8 p = panTable[pan + 16];
+ int8 p = _panTable[pan + 16];
g_engine->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, p);
} else {
@@ -703,7 +706,7 @@ int32 Sound::playFx(int32 id, uint8 *data, uint8 vol, int8 pan, uint8 type) {
// Start the sound effect playing
byte volume = _fxMuted ? 0 : vol * _fxVol;
- int8 p = panTable[pan + 16];
+ int8 p = _panTable[pan + 16];
g_engine->_mixer->playRaw(&_fx[i]._handle, _fx[i]._buf, _fx[i]._bufSize, _fx[i]._rate, _fx[i]._flags, -1, volume, p);
}
@@ -733,7 +736,7 @@ int32 Sound::setFxIdVolumePan(int32 id, uint8 vol, int8 pan) {
if (!_fxMuted) {
g_engine->_mixer->setChannelVolume(_fx[i]._handle, _fx[i]._volume * _fxVol);
- g_engine->_mixer->setChannelPan(_fx[i]._handle, panTable[pan + 16]);
+ g_engine->_mixer->setChannelPan(_fx[i]._handle, _panTable[pan + 16]);
}
return RD_OK;
diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h
index 3b30b80ebd..8138acbf6f 100644
--- a/sword2/driver/d_sound.h
+++ b/sword2/driver/d_sound.h
@@ -76,6 +76,8 @@ private:
OSystem::MutexRef _mutex;
RateConverter *_converter;
+ uint32 _panTable[33];
+
FxHandle _fx[MAXFX];
MusicHandle _music[MAXMUS + 1];
@@ -122,7 +124,7 @@ public:
void restoreMusicState();
void playLeadOut(uint8 *leadOut);
int32 musicTimeRemaining();
- void reverseStereo(void);
+ void buildPanTable(bool reverse);
uint8 getFxVolume(void);
uint8 getSpeechVolume(void);
uint8 getMusicVolume(void);