aboutsummaryrefslogtreecommitdiff
path: root/engines/groovie/music.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/groovie/music.cpp')
-rw-r--r--engines/groovie/music.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/engines/groovie/music.cpp b/engines/groovie/music.cpp
index 45f9800211..24306c8bfd 100644
--- a/engines/groovie/music.cpp
+++ b/engines/groovie/music.cpp
@@ -31,7 +31,10 @@
#include "common/config-manager.h"
#include "common/macresman.h"
#include "common/memstream.h"
+#include "audio/audiostream.h"
#include "audio/midiparser.h"
+#include "audio/decoders/mp3.h"
+#include "audio/decoders/quicktime.h"
namespace Groovie {
@@ -92,6 +95,7 @@ void MusicPlayer::playCD(uint8 track) {
} else if ((track == 98) && (_prevCDtrack == 3)) {
// Track 98 is used as a hack to stop the credits song
g_system->getAudioCDManager()->stop();
+ stopCreditsIOS();
return;
}
@@ -124,6 +128,8 @@ void MusicPlayer::playCD(uint8 track) {
playSong((19 << 10) | 36); // XMI.GJD, file 36
} else if (track == 3) {
// TODO: Credits MIDI fallback
+ if (_vm->getPlatform() == Common::kPlatformIOS)
+ playCreditsIOS();
}
}
}
@@ -224,6 +230,22 @@ void MusicPlayer::unload() {
_isPlaying = false;
}
+void MusicPlayer::playCreditsIOS() {
+#ifdef USE_MAD
+ Common::File *f = new Common::File();
+ f->open("7th_Guest_Dolls_from_Hell_OC_ReMix.mp3");
+ Audio::AudioStream *stream = Audio::makeMP3Stream(f, DisposeAfterUse::YES);
+ _vm->_system->getMixer()->playStream(Audio::Mixer::kMusicSoundType, &_handleCreditsIOS, stream);
+#else
+ warning("MAD library required for credits music");
+#endif
+}
+
+void MusicPlayer::stopCreditsIOS() {
+#ifdef USE_MAD
+ _vm->_system->getMixer()->stopHandle(_handleCreditsIOS);
+#endif
+}
// MusicPlayerMidi
@@ -747,4 +769,55 @@ Common::SeekableReadStream *MusicPlayerMac::decompressMidi(Common::SeekableReadS
return new Common::MemoryReadStream(output, size, DisposeAfterUse::YES);
}
+MusicPlayerMPEG4::MusicPlayerMPEG4(GroovieEngine *vm) : MusicPlayer(vm) {
+}
+
+void MusicPlayerMPEG4::updateVolume() {
+ // Just set the mixer volume for the music sound type
+ _vm->_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _userVolume * _gameVolume / 100);
+}
+
+void MusicPlayerMPEG4::unload() {
+ MusicPlayer::unload();
+
+ _vm->_system->getMixer()->stopHandle(_handle);
+}
+
+bool MusicPlayerMPEG4::load(uint32 fileref, bool loop) {
+ // Find correct filename
+ ResInfo info;
+ _vm->_resMan->getResInfo(fileref, info);
+ uint len = info.filename.size();
+ if (len < 4)
+ return false; // This shouldn't actually occur
+
+ // iOS port provides alternative intro sequence music
+ if (info.filename == "gu39.xmi") {
+ info.filename = "intro.m4a";
+ } else if (info.filename == "gu32.xmi") {
+ info.filename = "foyer.m4a";
+ } else {
+ // RL still says xmi, but we're after external m4a
+ info.filename.setChar('m', len-3);
+ info.filename.setChar('4', len-2);
+ info.filename.setChar('a', len-1);
+ }
+
+ // Create the audio stream
+ Audio::AudioStream *audStream = Audio::makeQuickTimeStream(info.filename);
+
+ if (!audStream) {
+ warning("Could not play MPEG-4 sound '%s'", info.filename.c_str());
+ return false;
+ }
+
+ // Loop if requested
+ if (loop)
+ audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream *)audStream, 0);
+
+ // Play!
+ _vm->_system->getMixer()->playStream(Audio::Mixer::kMusicSoundType, &_handle, audStream);
+ return true;
+}
+
} // End of Groovie namespace