From 495cc57aaa5a00fccdee92ff6a3328fb62e2c319 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sun, 17 Sep 2023 20:14:53 +0100 Subject: reading durations --- futuregael/src/ofApp.h | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'futuregael/src/ofApp.h') diff --git a/futuregael/src/ofApp.h b/futuregael/src/ofApp.h index f627e48..d656bf1 100644 --- a/futuregael/src/ofApp.h +++ b/futuregael/src/ofApp.h @@ -6,17 +6,54 @@ class scriptLine{ public: - scriptLine(string audiofile,string cols,string words){ - audio.load(audiofile); - text=words; + scriptLine(string audiofile,string cols,string wrds){ + if (audio.load(audiofile)){ + //requires https://github.com/arturoc/openFrameworks/tree/feature-soundPlayerDuration + duration = ((float)audio.getDurationMS())/1000.0f; + + vector words=ofSplitString(wrds," "); + + avgWordDuration = duration / words.size(); + + ofLog()<<"loaded "< colours=ofSplitString(cols,","); for (auto c: colours){ palette.push_back(ofColor::fromHex(ofHexToInt(c))); } + + bisPlaying=false; + + } + void play(){ + if (audio.isLoaded()){ + audio.play(); + startTime=ofGetElapsedTimef(); + } + } + bool isPlaying(){ + return audio.isPlaying(); + } + void stop(){ + if (isPlaying()){ + audio.stop(); + } + } + void update(){ + if (isPlaying()){ + //if (ofGetElapsedTimef()){} + } } vector palette; string text; ofSoundPlayer audio; + float duration; + float avgWordDuration; + bool bisPlaying; + float startTime; }; class ofApp : public ofBaseApp{ -- cgit v1.2.3