aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Göffringmann2004-01-06 11:48:30 +0000
committerRobert Göffringmann2004-01-06 11:48:30 +0000
commite34d7b6c41054fb1093a1967639d2a328eabd5f8 (patch)
tree841d0036eb2eeb73dcb90a589c66c354cc7b5d69
parentcc67301791cd46bc6e81bb76ef30c45d692a7547 (diff)
downloadscummvm-rg350-e34d7b6c41054fb1093a1967639d2a328eabd5f8.tar.gz
scummvm-rg350-e34d7b6c41054fb1093a1967639d2a328eabd5f8.tar.bz2
scummvm-rg350-e34d7b6c41054fb1093a1967639d2a328eabd5f8.zip
get volume from gamedetector
svn-id: r12169
-rw-r--r--sword1/music.cpp14
-rw-r--r--sword1/music.h2
-rw-r--r--sword1/sound.cpp9
-rw-r--r--sword1/sound.h2
-rw-r--r--sword1/sword1.cpp6
5 files changed, 26 insertions, 7 deletions
diff --git a/sword1/music.cpp b/sword1/music.cpp
index 5cdc83a31c..7e2e908509 100644
--- a/sword1/music.cpp
+++ b/sword1/music.cpp
@@ -116,6 +116,7 @@ SwordMusic::SwordMusic(OSystem *system, SoundMixer *pMixer) {
_mutex = _system->create_mutex();
_converter[0] = NULL;
_converter[1] = NULL;
+ _volume = 192;
}
SwordMusic::~SwordMusic() {
@@ -132,12 +133,13 @@ void SwordMusic::passMixerFunc(void *param, int16 *buf, uint len) {
void SwordMusic::mixer(int16 *buf, uint32 len) {
Common::StackLock lock(_mutex);
- for (int i = 0; i < ARRAYSIZE(_handles); i++) {
- if (_handles[i].streaming() && _converter[i]) {
- st_volume_t vol = 255;
- _converter[i]->flow(_handles[i], buf, len, vol, vol);
- }
- }
+ for (int i = 0; i < ARRAYSIZE(_handles); i++)
+ if (_handles[i].streaming() && _converter[i])
+ _converter[i]->flow(_handles[i], buf, len, _volume, _volume);
+}
+
+void SwordMusic::setVolume(uint8 vol) {
+ _volume = (st_volume_t)vol;
}
void SwordMusic::startMusic(int32 tuneId, int32 loopFlag) {
diff --git a/sword1/music.h b/sword1/music.h
index bc6e6baad6..dcdc7e2609 100644
--- a/sword1/music.h
+++ b/sword1/music.h
@@ -64,7 +64,9 @@ public:
~SwordMusic();
void startMusic(int32 tuneId, int32 loopFlag);
void fadeDown();
+ void setVolume(uint8 vol);
private:
+ st_volume_t _volume;
SwordMusicHandle _handles[2];
RateConverter *_converter[2];
OSystem *_system;
diff --git a/sword1/sound.cpp b/sword1/sound.cpp
index 2ded6fa9ee..e9cb523b5a 100644
--- a/sword1/sound.cpp
+++ b/sword1/sound.cpp
@@ -36,6 +36,12 @@ SwordSound::SwordSound(const char *searchPath, SoundMixer *mixer, ResMan *pResMa
_cowHeader = NULL;
_endOfQueue = 0;
_currentCowFile = 0;
+ _speechVol = _sfxVol = 192;
+}
+
+void SwordSound::setVolume(uint8 sfxVol, uint8 speechVol) {
+ _sfxVol = sfxVol;
+ _speechVol = speechVol;
}
int SwordSound::addToQueue(int32 fxNo) {
@@ -138,6 +144,7 @@ void SwordSound::playSample(QueueElement *elem) {
uint8 volR = _fxList[elem->id].roomVolList[cnt].rightVol * 10;
int8 pan = (volR - volL) / 2;
uint8 volume = (volR + volL) / 2;
+ volume = (volume * _sfxVol) >> 8;
uint32 size = READ_LE_UINT32(sampleData + 0x28);
uint8 flags;
if (READ_LE_UINT16(sampleData + 0x22) == 16)
@@ -167,7 +174,7 @@ bool SwordSound::startSpeech(uint16 roomNo, uint16 localNo) {
uint32 size;
int16 *data = uncompressSpeech(index + _cowHeaderSize, sampleSize, &size);
if (data)
- _mixer->playRaw(&_speechHandle, data, size, 11025, SPEECH_FLAGS, SOUND_SPEECH_ID);
+ _mixer->playRaw(&_speechHandle, data, size, 11025, SPEECH_FLAGS, SOUND_SPEECH_ID, _speechVol);
return true;
} else
return false;
diff --git a/sword1/sound.h b/sword1/sound.h
index c249493dd5..8131d780bb 100644
--- a/sword1/sound.h
+++ b/sword1/sound.h
@@ -59,6 +59,7 @@ class SwordSound {
public:
SwordSound(const char *searchPath, SoundMixer *mixer, ResMan *pResMan);
~SwordSound(void);
+ void setVolume(uint8 sfxVol, uint8 speechVol);
void newScreen(uint32 screen);
void quitScreen(void);
void closeCowSystem(void);
@@ -74,6 +75,7 @@ public:
void engine(void);
private:
+ uint8 _sfxVol, _speechVol;
void playSample(QueueElement *elem);
void initCowSystem(void);
diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp
index 9ee4c9102e..85cf4f05c6 100644
--- a/sword1/sword1.cpp
+++ b/sword1/sword1.cpp
@@ -109,6 +109,12 @@ void SwordEngine::initialize(void) {
_logic = new SwordLogic(_objectMan, _resMan, _screen, _mouse, _sound, _music, _menu);
_mouse->useLogicAndMenu(_logic, _menu);
+ _music->setVolume((uint8)ConfMan.getInt("music_volume"));
+ uint8 speechVol = (uint8)ConfMan.getInt("speech_volume");
+ if (!speechVol)
+ speechVol = 192;
+ _sound->setVolume((uint8)ConfMan.getInt("sfx_volume"), speechVol);
+
_systemVars.justRestoredGame = _systemVars.currentCD =
_systemVars.gamePaused = 0;
_systemVars.deathScreenFlag = 3;