diff options
Diffstat (limited to 'futuregael/src')
| -rw-r--r-- | futuregael/src/ofApp.cpp | 6 | ||||
| -rw-r--r-- | futuregael/src/ofApp.h | 43 |
2 files changed, 43 insertions, 6 deletions
diff --git a/futuregael/src/ofApp.cpp b/futuregael/src/ofApp.cpp index fe007e8..c912916 100644 --- a/futuregael/src/ofApp.cpp +++ b/futuregael/src/ofApp.cpp @@ -61,10 +61,10 @@ void ofApp::keyReleased(int key){ break; } case ' ':{ - if (playline->audio.isPlaying()){ - playline->audio.stop(); + if (playline->isPlaying()){ + playline->stop(); } - else playline->audio.play(); + else playline->play(); break; } default:{ 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<string> words=ofSplitString(wrds," "); + + avgWordDuration = duration / words.size(); + + ofLog()<<"loaded "<<audiofile<<", duration "<<duration<<"s, avg "<<avgWordDuration; + } + else duration=0.0f; + + text=wrds; vector<string> 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<ofColor> palette; string text; ofSoundPlayer audio; + float duration; + float avgWordDuration; + bool bisPlaying; + float startTime; }; class ofApp : public ofBaseApp{ |
