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/main.cpp | 2 +- futuregael/src/ofApp.cpp | 21 ++++++++- futuregael/src/show.h | 108 ++++++++++++++++++++++++++++++++++++++++---- futuregael/src/vectortext.h | 2 +- 4 files changed, 121 insertions(+), 12 deletions(-) diff --git a/futuregael/src/main.cpp b/futuregael/src/main.cpp index 3e20ab7..79ed500 100644 --- a/futuregael/src/main.cpp +++ b/futuregael/src/main.cpp @@ -8,7 +8,7 @@ int main(int argc, char *argv[]){ ofGLFWWindowSettings settings; - settings.setSize(1200,900); + settings.setSize(512,512); // 1/8 scale //1200 = 13.2° = 42898 pts theoretical diff --git a/futuregael/src/ofApp.cpp b/futuregael/src/ofApp.cpp index 2393618..676b480 100644 --- a/futuregael/src/ofApp.cpp +++ b/futuregael/src/ofApp.cpp @@ -22,6 +22,25 @@ void ofApp::update(){ void ofApp::draw(){ ofBackground(0); + + + if (show.isPlaying()){ + vector& outlines=show.getOutlines(); + + ofPushMatrix(); + ofTranslate(ofGetWidth()/2,ofGetHeight()/2); + for (auto o:outlines){ + o.draw(); + } + ofPopMatrix(); + + ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)+"fps, shapes: "+ofToString(outlines.size())); + } + else { + ofSetWindowTitle("idle"); + } + + } @@ -52,7 +71,7 @@ void ofApp::keyReleased(int key){ break; } case ' ':{ - if (show.isPlaying){ + if (show.isPlaying()){ show.stop(); } else show.play(); 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 diff --git a/futuregael/src/vectortext.h b/futuregael/src/vectortext.h index 0f79e58..e5adbdb 100644 --- a/futuregael/src/vectortext.h +++ b/futuregael/src/vectortext.h @@ -46,10 +46,10 @@ public: }; class SVGFont{ +public: ofXml svg; float enspace; bool bisLoaded; -public: bool isLoaded() { return bisLoaded; } -- cgit v1.2.3