diff options
Diffstat (limited to 'futuregael/src')
| -rw-r--r-- | futuregael/src/ofApp.cpp | 6 | ||||
| -rw-r--r-- | futuregael/src/ofApp.h | 5 | ||||
| -rw-r--r-- | futuregael/src/show.h | 70 |
3 files changed, 67 insertions, 14 deletions
diff --git a/futuregael/src/ofApp.cpp b/futuregael/src/ofApp.cpp index 3fb103b..86e6b4b 100644 --- a/futuregael/src/ofApp.cpp +++ b/futuregael/src/ofApp.cpp @@ -100,10 +100,12 @@ void ofApp::keyPressed(ofKeyEventArgs &args){ //-------------------------------------------------------------- void ofApp::keyReleased(int key){ switch(key){ - case OF_KEY_UP:{ + case OF_KEY_LEFT:{ + show.previous(); break; } - case OF_KEY_DOWN:{ + case OF_KEY_RIGHT:{ + show.next(); break; } case ' ':{ diff --git a/futuregael/src/ofApp.h b/futuregael/src/ofApp.h index 8e4b4aa..cc4d5cb 100644 --- a/futuregael/src/ofApp.h +++ b/futuregael/src/ofApp.h @@ -7,6 +7,11 @@ #include "show.h" +/* + +reduce interval between lines +*/ + class ofApp : public ofBaseApp{ public: 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<string> colours=ofSplitString(cols,","); for (auto c: colours){ palette.push_back(ofColor::fromHex(ofHexToInt(c))); @@ -14,6 +29,7 @@ public: clear(); vector<string> 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, "<<uniglyph; } - w.glyphs.push_back(font.getGlyph(uniglyph, + auto g=font.getGlyph(uniglyph, palette.size()? palette[ofRandom(palette.size())]: //112->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 "<<audiofile<<", duration "<<duration<<"s, "<<words.size()<<" words avg "<<avgWordDuration<<"s"; + ofLog()<<audiofile<<", duration "<<duration<<"s, width: "<<width; } else duration=0.0f; - enspace=font.enspace; - } void clear(){ words.clear(); @@ -97,9 +112,10 @@ public: outlines.clear(); - float s=0.05f; + float s=0.1f; - float p=(-ofGetWidth()/3*s)-(width*wordphase); + float p=((ofGetWidth()/4)*s)-(width*wordphase)-((ofGetWidth()/2)*s*wordphase); + float start=p; if (word1>-1&&word1<words.size()){ for (int i=0;i<word1;i++){ @@ -129,11 +145,16 @@ public: p+=g.width; } } + + if ((wordphase-1.0f)>0.0f&&!printed){ + ofLog()<<"added: "<<p-start<<" width: "<<width; + printed=true; + } return outlines; } - + string name; vector<ofColor> palette; vector<glyphWord> words; ofSoundPlayer audio; @@ -141,6 +162,8 @@ public: float avgWordDuration; vector<colourPolyline> outlines; float enspace; + bool printed; +private: float width; }; @@ -179,6 +202,8 @@ public: playline=script.begin(); + ofLog()<<"Selected "<<playline->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 "<<playline->duration; @@ -212,15 +238,35 @@ public: } } + void previous(){ + stop(); + if (script.size()){ + if (playline!=script.begin()){ + playline--; + ofLog()<<"previous line selected, "<<playline->name; + } + } + } + + void next(){ + stop(); + if (script.size()){ + if (playline!=script.end()){ + playline++; + ofLog()<<"next line selected, "<<playline->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, "<<playline->duration;; playline++; + ofLog()<<"Line ended, selected "<<playline->name; if (playline==script.end()){ ofLog()<<"Show finished!"; } |
