aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/mortevielle/mortevielle.cpp4
-rw-r--r--engines/mortevielle/mortevielle.h2
-rw-r--r--engines/mortevielle/sound.cpp24
-rw-r--r--engines/mortevielle/sound.h3
-rw-r--r--engines/mortevielle/speech.cpp23
-rw-r--r--engines/mortevielle/speech.h1
6 files changed, 28 insertions, 29 deletions
diff --git a/engines/mortevielle/mortevielle.cpp b/engines/mortevielle/mortevielle.cpp
index 4e2582ceb1..c117e36636 100644
--- a/engines/mortevielle/mortevielle.cpp
+++ b/engines/mortevielle/mortevielle.cpp
@@ -104,16 +104,12 @@ MortevielleEngine::MortevielleEngine(OSystem *system, const ADGameDescription *g
_curPict = nullptr;
_curAnim = nullptr;
_rightFramePict = nullptr;
- _compMusicBuf1 = nullptr;
- _noiseBuf = nullptr;
}
MortevielleEngine::~MortevielleEngine() {
free(_curPict);
free(_curAnim);
free(_rightFramePict);
- free(_compMusicBuf1);
- free(_noiseBuf);
}
/**
diff --git a/engines/mortevielle/mortevielle.h b/engines/mortevielle/mortevielle.h
index 0201d8f70d..bedb6a1ceb 100644
--- a/engines/mortevielle/mortevielle.h
+++ b/engines/mortevielle/mortevielle.h
@@ -439,8 +439,6 @@ public:
byte *_curPict;
byte *_curAnim;
byte *_rightFramePict;
- byte *_compMusicBuf1;
- byte *_noiseBuf;
Debugger _debugger;
ScreenSurface _screenSurface;
diff --git a/engines/mortevielle/sound.cpp b/engines/mortevielle/sound.cpp
index 9d451dadd3..5dea574a81 100644
--- a/engines/mortevielle/sound.cpp
+++ b/engines/mortevielle/sound.cpp
@@ -138,6 +138,7 @@ SoundManager::SoundManager(Audio::Mixer *mixer) {
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_speakerHandle,
_speakerStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
_audioStream = nullptr;
+ _ambiantNoiseBuf = nullptr;
}
SoundManager::~SoundManager() {
@@ -145,6 +146,7 @@ SoundManager::~SoundManager() {
_audioStream->finish();
_mixer->stopHandle(_speakerHandle);
delete _speakerStream;
+ free(_ambiantNoiseBuf);
}
/**
@@ -178,6 +180,26 @@ int SoundManager::decodeMusic(const byte *PSrc, byte *PDest, int size) {
return decompSize;
}
+/**
+ * Load sonmus.mor file
+ * @remarks Originally called 'charge_son'
+ */
+void SoundManager::loadAmbiantSounds() {
+ Common::File f;
+ if (!f.open("sonmus.mor"))
+ error("Missing file - sonmus.mor");
+
+ free(_ambiantNoiseBuf);
+ int size = f.size();
+ byte *compMusicBuf1 = (byte *)malloc(sizeof(byte) * size);
+ _ambiantNoiseBuf = (byte *)malloc(sizeof(byte) * size * 2);
+ f.read(compMusicBuf1, size);
+ f.close();
+
+ decodeMusic(compMusicBuf1, _ambiantNoiseBuf, size);
+ free(compMusicBuf1);
+}
+
void SoundManager::litph(tablint &t, int typ, int tempo) {
if (_vm->_speechManager._typlec == 2) {
warning("--->");
@@ -225,7 +247,7 @@ void SoundManager::litph(tablint &t, int typ, int tempo) {
} else {
if (!_audioStream)
_audioStream = Audio::makeQueuingAudioStream(22428, false);
- _audioStream->queueBuffer(&_vm->_noiseBuf[ambiantNoiseAdr[val * 2]], ambiantNoiseAdr[(val * 2) + 1] - ambiantNoiseAdr[(val * 2)], DisposeAfterUse::NO, Audio::FLAG_UNSIGNED);
+ _audioStream->queueBuffer(&_ambiantNoiseBuf[ambiantNoiseAdr[val * 2]], ambiantNoiseAdr[(val * 2) + 1] - ambiantNoiseAdr[(val * 2)], DisposeAfterUse::NO, Audio::FLAG_UNSIGNED);
// Audio::SeekableAudioStream *raw = nullptr;
// raw = Audio::makeRawStream(&_vm->_mem[(kAdrNoise * 16)] + ambiantNoiseAdr[val * 2], ambiantNoiseAdr[(val * 2) + 1], 22428, Audio::FLAG_UNSIGNED, DisposeAfterUse::NO);
// Audio::SoundHandle soundHandle;
diff --git a/engines/mortevielle/sound.h b/engines/mortevielle/sound.h
index a2459acee5..763e18a622 100644
--- a/engines/mortevielle/sound.h
+++ b/engines/mortevielle/sound.h
@@ -97,6 +97,8 @@ private:
MortevielleEngine *_vm;
PCSpeaker *_speakerStream;
Audio::SoundHandle _speakerHandle;
+ byte *_ambiantNoiseBuf;
+
public:
Audio::Mixer *_mixer;
Audio::QueuingAudioStream *_audioStream;
@@ -109,6 +111,7 @@ public:
int decodeMusic(const byte *PSrc, byte *PDest, int size);
void playSong(const byte *buf, uint usize, uint loops);
+ void loadAmbiantSounds();
void litph(tablint &t, int typ, int tempo);
};
diff --git a/engines/mortevielle/speech.cpp b/engines/mortevielle/speech.cpp
index 2bf2e2c286..c721aa2e02 100644
--- a/engines/mortevielle/speech.cpp
+++ b/engines/mortevielle/speech.cpp
@@ -158,26 +158,6 @@ void SpeechManager::regenbruit() {
}
/**
- * Load sonmus.mor file
- * @remarks Originally called 'charge_son'
- */
-void SpeechManager::loadMusicSound() {
- Common::File f;
- if (!f.open("sonmus.mor"))
- error("Missing file - sonmus.mor");
-
- free(_vm->_compMusicBuf1);
- free(_vm->_noiseBuf);
- int size = f.size();
- _vm->_compMusicBuf1 = (byte *)malloc(sizeof(byte) * size);
- _vm->_noiseBuf = (byte *)malloc(sizeof(byte) * size * 2);
- f.read(_vm->_compMusicBuf1, size);
-
- _vm->_soundManager.decodeMusic(_vm->_compMusicBuf1, _vm->_noiseBuf, size);
- f.close();
-}
-
-/**
* Load phoneme sound file
* @remarks Originally called 'charge_phbruit'
*/
@@ -597,7 +577,8 @@ void SpeechManager::startSpeech(int rep, int ht, int typ) {
regenbruit();
break;
case 2:
- loadMusicSound();
+ //TODO: Only call it once
+ _vm->_soundManager.loadAmbiantSounds();
loadPhonemeSounds();
break;
default:
diff --git a/engines/mortevielle/speech.h b/engines/mortevielle/speech.h
index 57f0116827..4fe9a34dca 100644
--- a/engines/mortevielle/speech.h
+++ b/engines/mortevielle/speech.h
@@ -89,7 +89,6 @@ public:
void veracf(byte b);
void cctable(tablint &t);
void regenbruit();
- void loadMusicSound();
void loadPhonemeSounds();
void loadNoise();
void trait_car();