|
From: Yoda-JM <yo...@us...> - 2009-07-12 11:25:51
|
Module: performous
Branch: master
Commit: afe071271c0c9802ae49bffc6d3ff8938b748a13
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun Jul 12 13:24:19 2009 +0200
Added multiple audio track playback
---
game/audio.cc | 20 ++++++++++++++++++++
game/audio.hh | 1 +
2 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/game/audio.cc b/game/audio.cc
index 09aa93f..3c79331 100644
--- a/game/audio.cc
+++ b/game/audio.cc
@@ -64,6 +64,26 @@ void Audio::operator()(da::pcm_data& areas, da::settings const&) {
}
}
+void Audio::playMusic(std::vector<std::string> const& filenames, bool preview, double fadeTime, double startPos) {
+ if (!isOpen()) return;
+ // First construct the new stream
+ fadeout(fadeTime);
+ for(unsigned int i = 0 ; i < filenames.size() ; i++ ) {
+ std::cout << "Adding " << filenames[i] << std::endl;
+ std::auto_ptr<Stream> s;
+ try {
+ s.reset(new Stream(filenames[i], m_rs.rate(), preview ? config["audio/preview_volume"] : config["audio/music_volume"]));
+ s->fadein(fadeTime);
+ if (startPos != 0.0) s->mpeg.seek(startPos, false);
+ } catch (std::runtime_error& e) {
+ std::cerr << "Error loading " << filenames[i] << " (" << e.what() << ")" << std::endl;
+ }
+ boost::recursive_mutex::scoped_lock l(m_mutex);
+ m_streams.push_back(s);
+ }
+ if (!preview) m_paused = false;
+}
+
void Audio::playMusic(std::string const& filename, bool preview, double fadeTime, double startPos) {
if (!isOpen()) return;
// First construct the new stream
diff --git a/game/audio.hh b/game/audio.hh
index d13784b..3378891 100644
--- a/game/audio.hh
+++ b/game/audio.hh
@@ -122,6 +122,7 @@ class Audio {
* @param startPos starting position
*/
void playMusic(std::string const& filename, bool preview = false, double fadeTime = 0.1, double startPos = 0.0);
+ void playMusic(std::vector<std::string> const& filenames, bool preview = false, double fadeTime = 0.1, double startPos = 0.0);
/** Play a preview of the song, starting at startPos
* @param filename the track filename
* @param startPos starting position
|