From 22c0d9bf8339d9c6e667bafd3b12baa867f8a29b Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 22 Sep 2023 00:23:14 +0100 Subject: fixed some bugs --- futuregael/src/show.h | 70 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 12 deletions(-) (limited to 'futuregael/src/show.h') diff --git a/futuregael/src/show.h b/futuregael/src/show.h index 45d0023..43e4bad 100644 --- a/futuregael/src/show.h +++ b/futuregael/src/show.h @@ -2,10 +2,25 @@ #include "ofxCsv.h" #include "vectortext.h" + +/* +[notice ] 1b Briseadh Bualadh Bos.wav, duration 1.709s, 3, width: 8003 +[notice ] 1b Briseadh Bualadh Bos.wav, duration 1.709s, 3, width: 9137 +[notice ] 1b Briseadh Bualadh Bos.wav, duration 1.709s, 3, width: 9137 + +the first time we load a scriptline the width comes out too short. why>>??? + +//this was caused becauase enspace=font.enspace was at the end of the initialiser +//how did this make it work out the 2nd time? +*/ + + class ScriptLine{ public: ScriptLine(SVGFont &font,string audiofile,string cols,string message){ + enspace=font.enspace; + vector colours=ofSplitString(cols,","); for (auto c: colours){ palette.push_back(ofColor::fromHex(ofHexToInt(c))); @@ -14,6 +29,7 @@ public: clear(); vector m=ofSplitString(message," "); width=0; + for (auto& word: m){ glyphWord w; int pos=0; @@ -22,31 +38,30 @@ public: if (c<0){ //ofLog()<<"got unicode glyph, "<231 hue sat 0->255 brightness 255 - ofColor::fromHsb(ofRandom(119)+112,ofRandom(255),255) - )); + ofColor::fromHsb(ofRandom(119)+112,ofRandom(255),255)); + w.glyphs.push_back(g); + w.width+=g.width; pos++; - w.width+=w.glyphs[w.glyphs.size()-1].width; } words.push_back(w); width+=(w.width+enspace); } if (audio.load(audiofile)){ + name=audiofile; //requires https://github.com/arturoc/openFrameworks/tree/feature-soundPlayerDuration duration = ((float)audio.getDurationMS())/1000.0f; avgWordDuration = duration / words.size(); - ofLog()<<"Line "<-1&&word10.0f&&!printed){ + ofLog()<<"added: "< palette; vector words; ofSoundPlayer audio; @@ -141,6 +162,8 @@ public: float avgWordDuration; vector outlines; float enspace; + bool printed; +private: float width; }; @@ -179,6 +202,8 @@ public: playline=script.begin(); + ofLog()<<"Selected "<name; + return true; } @@ -198,6 +223,7 @@ public: if (playline->audio.isLoaded()){ playline->audio.play(); + playline->printed=false; startTime=ofGetElapsedTimef(); bisPlaying=true; ofLog()<<"Line playing "<duration; @@ -212,15 +238,35 @@ public: } } + void previous(){ + stop(); + if (script.size()){ + if (playline!=script.begin()){ + playline--; + ofLog()<<"previous line selected, "<name; + } + } + } + + void next(){ + stop(); + if (script.size()){ + if (playline!=script.end()){ + playline++; + ofLog()<<"next line selected, "<name; + } + } + } + void update(){ if (isPlaying()){ if (ofGetElapsedTimef()-startTime> (playline->avgWordDuration* - playline->words.size()+2)){ + playline->words.size()+1)){ playline->audio.stop(); bisPlaying=false; - ofLog()<<"Line ended, "<duration;; playline++; + ofLog()<<"Line ended, selected "<name; if (playline==script.end()){ ofLog()<<"Show finished!"; } -- cgit v1.2.3