From 5c59ea6a5797bb44a46846008ddc235c8a5537af Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 20 Sep 2023 08:35:26 +0100 Subject: basic playback --- futuregael/src/show.h | 108 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 99 insertions(+), 9 deletions(-) (limited to 'futuregael/src/show.h') diff --git a/futuregael/src/show.h b/futuregael/src/show.h index 7261d8d..e3aeebe 100644 --- a/futuregael/src/show.h +++ b/futuregael/src/show.h @@ -42,16 +42,96 @@ public: } else duration=0.0f; + enspace=font.enspace; + } void clear(){ words.clear(); } + vector& getOutlines(float time){ + float phase=time/avgWordDuration; + float phaseseg=fmod(phase,(int)phase); + + //ofLog()<<"phase "<1.0f) word1amt=1.0f; + + float word2amt=phaseseg*2.0; + if (word2amt>1.0f) word2amt=1.0f; + + outlines.clear(); + float p=-ofGetWidth()/2; + + float s=0.1f; + + if (word1>-1&&word1 palette; vector words; ofSoundPlayer audio; float duration; float avgWordDuration; + vector outlines; + float enspace; }; @@ -62,7 +142,7 @@ public: return font.load(fontpath); } Show(){ - isPlaying=false; + bisPlaying=false; } Show(filesystem::path fontpath){ font.load(fontpath); @@ -103,25 +183,27 @@ public: if (playline->audio.isLoaded()){ playline->audio.play(); startTime=ofGetElapsedTimef(); - isPlaying=true; + bisPlaying=true; ofLog()<<"Line playing "<duration; } } void stop(){ - if (isPlaying){ + if (isPlaying()){ playline->audio.stop(); - isPlaying=false; + bisPlaying=false; ofLog()<<"Line stopped"; } } void update(){ - if (isPlaying){ - if (ofGetElapsedTimef()-startTime>playline->duration){ + if (isPlaying()){ + if (ofGetElapsedTimef()-startTime> + (playline->avgWordDuration* + playline->words.size()+2)){ playline->audio.stop(); - isPlaying=false; - ofLog()<<"Line finished! "<duration;; + bisPlaying=false; + ofLog()<<"Line ended, "<duration;; playline++; if (playline==script.end()){ ofLog()<<"Show finished!"; @@ -130,6 +212,11 @@ public: } } + vector& getOutlines(){ + + return playline->getOutlines(ofGetElapsedTimef()-startTime); + } + ofxCsv csv; vector script; @@ -137,7 +224,10 @@ public: vector::iterator playline; float startTime; - bool isPlaying; + bool bisPlaying; + bool isPlaying() { + return bisPlaying; + } SVGFont font; }; \ No newline at end of file -- cgit v1.2.3