summaryrefslogtreecommitdiff
path: root/futuregael/soundPlayerDuration.patch
diff options
context:
space:
mode:
Diffstat (limited to 'futuregael/soundPlayerDuration.patch')
-rw-r--r--futuregael/soundPlayerDuration.patch149
1 files changed, 149 insertions, 0 deletions
diff --git a/futuregael/soundPlayerDuration.patch b/futuregael/soundPlayerDuration.patch
new file mode 100644
index 0000000..b7cdd28
--- /dev/null
+++ b/futuregael/soundPlayerDuration.patch
@@ -0,0 +1,149 @@
+diff --git a/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp b/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp
+index 51cc5f05a..aaa4e283c 100644
+--- a/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp
++++ b/libs/openFrameworks/sound/ofFmodSoundPlayer.cpp
+@@ -5,6 +5,7 @@
+ #include "ofMath.h"
+ #include "ofLog.h"
+
++#include "ofAppRunner.h"
+
+ static bool bFmodInitialized_ = false;
+ static float fftInterpValues_[8192]; //
+@@ -36,6 +37,23 @@ void ofFmodSoundSetVolume(float vol){
+ void ofFmodSoundUpdate(){
+ if (bFmodInitialized_){
+ FMOD_System_Update(sys);
++
++ unsigned int size;
++ int numbuffers;
++ FMOD_System_GetDSPBufferSize(sys, &size, &numbuffers);
++ /*
++ unsigned int hi, lo;
++ FMOD_Channel_GetDSPClock(sys, &hi, &lo);
++ int rate;
++ FMOD_SOUND_FORMAT format;
++ int outchannels, inchannels;
++ FMOD_DSP_RESAMPLER resamplemethod;
++ int bits;
++ FMOD_System_GetSoftwareFormat(sys, &rate, &format, &outchannels, &inchannels, &resamplemethod, &bits);
++ std::cout << "size: " << buffersize << std::endl;
++ std::cout << hi << " " << lo << std::endl;
++ std::cout << lo / double(rate) << " - " << ofGetElapsedTimef() << std::endl;
++ */
+ }
+ }
+
+@@ -280,6 +298,16 @@ void ofFmodSoundPlayer::setPositionMS(int ms) {
+ FMOD_Channel_SetPosition(channel, ms, FMOD_TIMEUNIT_MS);
+ }
+ }
++//------------------------------------------------------------
++uint64_t ofFmodSoundPlayer::getDurationMS() const{
++ if(isLoaded()){
++ unsigned int ms;
++ FMOD_Sound_GetLength(sound, &ms, FMOD_TIMEUNIT_MS);
++ return ms;
++ }else{
++ return 0;
++ }
++}
+
+ //------------------------------------------------------------
+ float ofFmodSoundPlayer::getPosition() const{
+diff --git a/libs/openFrameworks/sound/ofFmodSoundPlayer.h b/libs/openFrameworks/sound/ofFmodSoundPlayer.h
+index b54f1b2e6..ea211f7ad 100644
+--- a/libs/openFrameworks/sound/ofFmodSoundPlayer.h
++++ b/libs/openFrameworks/sound/ofFmodSoundPlayer.h
+@@ -62,6 +62,7 @@ class ofFmodSoundPlayer : public ofBaseSoundPlayer {
+ float getPan() const;
+ float getVolume() const;
+ bool isLoaded() const;
++ uint64_t getDurationMS() const;
+
+ static void initializeFmod();
+ static void closeFmod();
+diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp
+index 71caf42d8..093709e82 100644
+--- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp
++++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.cpp
+@@ -692,6 +692,11 @@ void ofOpenALSoundPlayer::update(ofEventArgs & args){
+ }
+ }
+
++uint64_t ofOpenALSoundPlayer::getDurationMS() const{
++ return duration * 1000;
++}
++
++
+ //------------------------------------------------------------
+ void ofOpenALSoundPlayer::unload(){
+ stop();
+diff --git a/libs/openFrameworks/sound/ofOpenALSoundPlayer.h b/libs/openFrameworks/sound/ofOpenALSoundPlayer.h
+index 042f7b354..df09811ca 100644
+--- a/libs/openFrameworks/sound/ofOpenALSoundPlayer.h
++++ b/libs/openFrameworks/sound/ofOpenALSoundPlayer.h
+@@ -76,6 +76,8 @@ class ofOpenALSoundPlayer : public ofBaseSoundPlayer, public ofThread {
+ bool isPaused() const;
+ bool isLoaded() const;
+
++ uint64_t getDurationMS() const;
++
+ static void initialize();
+ static void close();
+
+diff --git a/libs/openFrameworks/sound/ofSoundBaseTypes.h b/libs/openFrameworks/sound/ofSoundBaseTypes.h
+index 3f2e1aa98..1b2a9b73b 100644
+--- a/libs/openFrameworks/sound/ofSoundBaseTypes.h
++++ b/libs/openFrameworks/sound/ofSoundBaseTypes.h
+@@ -3,6 +3,8 @@
+ #include "ofConstants.h"
+ #include <functional>
+
++#include "ofLog.h"
++
+ class ofSoundBuffer;
+
+
+@@ -189,4 +191,9 @@ public:
+ virtual bool isLoaded() const = 0;
+ virtual float getVolume() const = 0;
+
++ virtual uint64_t getDurationMS() const{
++ ofLogError("ofBaseSoundPlayer") << "getDurationMS not implemented for this platform";
++ return 0;
++ }
++
+ };
+diff --git a/libs/openFrameworks/sound/ofSoundPlayer.cpp b/libs/openFrameworks/sound/ofSoundPlayer.cpp
+index 060b0daa2..9c914cbbe 100644
+--- a/libs/openFrameworks/sound/ofSoundPlayer.cpp
++++ b/libs/openFrameworks/sound/ofSoundPlayer.cpp
+@@ -237,3 +237,12 @@ float ofSoundPlayer::getVolume() const{
+ return 0;
+ }
+ }
++
++//--------------------------------------------------------------------
++uint64_t ofSoundPlayer::getDurationMS() const{
++ if( player ){
++ return player->getDurationMS();
++ } else {
++ return 0;
++ }
++}
+diff --git a/libs/openFrameworks/sound/ofSoundPlayer.h b/libs/openFrameworks/sound/ofSoundPlayer.h
+index a24bfdcc5..358c81965 100644
+--- a/libs/openFrameworks/sound/ofSoundPlayer.h
++++ b/libs/openFrameworks/sound/ofSoundPlayer.h
+@@ -156,6 +156,10 @@ public:
+ /// \return whether or not the player is ready to begin playback.
+ bool isLoaded() const;
+
++ /// Returns the duration of the sound in ms.
++ uint64_t getDurationMS() const;
++
++
+ protected:
+ std::shared_ptr<ofBaseSoundPlayer> player;
+