Skip to content

Commit

Permalink
MORTEVIELLE: Improve looping of the intro song
Browse files Browse the repository at this point in the history
Using a LoopingAudioStream gets rid of the pause between each loop
(and simplifies the code).
  • Loading branch information
criezy committed Aug 4, 2013
1 parent deef0b9 commit 7b517f7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
4 changes: 2 additions & 2 deletions engines/mortevielle/sound.cpp
Expand Up @@ -185,8 +185,8 @@ void SoundManager::playNote(int frequency, int32 length) {
}


void SoundManager::playSong(const byte* buf, int size) {
Audio::AudioStream *stream = Audio::makeRawStream(buf, size, 11025 / 2, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_16BITS);
void SoundManager::playSong(const byte* buf, int size, int loops) {
Audio::AudioStream *stream = Audio::makeLoopingAudioStream(Audio::makeRawStream(buf, size, 11025 / 2, Audio::FLAG_UNSIGNED | Audio::FLAG_LITTLE_ENDIAN | Audio::FLAG_16BITS), loops);
Audio::SoundHandle songHandle;
_mixer->playStream(Audio::Mixer::kSFXSoundType, &songHandle, stream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO);

Expand Down
2 changes: 1 addition & 1 deletion engines/mortevielle/sound.h
Expand Up @@ -106,7 +106,7 @@ class SoundManager {
void playNote(int frequency, int32 length);

int decodeMusic(const byte *PSrc, byte *PDest, int size);
void playSong(const byte *buf, int size);
void playSong(const byte *buf, int size, int loops = 1);

void litph(tablint &t, int typ, int tempo);
};
Expand Down
9 changes: 1 addition & 8 deletions engines/mortevielle/utils.cpp
Expand Up @@ -2213,14 +2213,7 @@ void MortevielleEngine::music() {
_addFix = (float)((kTempoMusic - 8)) / 256;
_speechManager.cctable(_speechManager._tbi);

bool fin = false;
int k = 0;
do {
fin = keyPressed();
_soundManager.playSong(musicBuf, musicSize);
++k;
fin = fin | keyPressed() | (k >= 5);
} while (!fin);
_soundManager.playSong(musicBuf, musicSize, 5);
while (keyPressed())
getChar();

Expand Down

0 comments on commit 7b517f7

Please sign in to comment.