summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--futuregael/bin/data/show.csv6
-rw-r--r--futuregael/src/ofApp.cpp6
-rw-r--r--futuregael/src/ofApp.h43
3 files changed, 46 insertions, 9 deletions
diff --git a/futuregael/bin/data/show.csv b/futuregael/bin/data/show.csv
index 795ddda..2884832 100644
--- a/futuregael/bin/data/show.csv
+++ b/futuregael/bin/data/show.csv
@@ -1,4 +1,4 @@
-Inneall Intleacht Shaorga mé.mp3|00A8FF,FFB700,FF3082|Inneall Intleacht Shaorga mé, le cumhacht agus críonnacht chuile cleamhnais a bhí riamh ann. Tá beirt tagtha chugainn anocht chun leigheas a chuir ar a gcuid uaigneas go deo, le cabhair uaimse. Briseadh bualadh bos. Go raibh maith agaibh, tá míle fáílte romhaibh anseo chuig Sráid Láir na Gaillimhe, don chéad babhta eile liomsa - an Inneall Cleamhnais agus Cuardach Croíthe.
-Casaimid lenár gcroíthe.mp3|E27D60,085DCB,E8A87C,C38D9E,41B3A3|Casaimid lenár gcroíthe anois.
-Agus ní ghlacann an inneall seo.mp3|00A8FF,FFB700,FF3082|Agus ní ghlacann an inneall seo freagracht as timpistí nó toradh ar bith bainteach le saorthoil aon rannpháirtí.
+Inneall Intleacht Shaorga mé.wav|00A8FF,FFB700,FF3082|Inneall Intleacht Shaorga mé, le cumhacht agus críonnacht chuile cleamhnais a bhí riamh ann. Tá beirt tagtha chugainn anocht chun leigheas a chuir ar a gcuid uaigneas go deo, le cabhair uaimse. Briseadh bualadh bos. Go raibh maith agaibh, tá míle fáílte romhaibh anseo chuig Sráid Láir na Gaillimhe, don chéad babhta eile liomsa - an Inneall Cleamhnais agus Cuardach Croíthe.
+Casaimid lenár gcroíthe.wav|E27D60,085DCB,E8A87C,C38D9E,41B3A3|Casaimid lenár gcroíthe anois.
+Agus ní ghlacann an inneall seo.wav|00A8FF,FFB700,FF3082|Agus ní ghlacann an inneall seo freagracht as timpistí nó toradh ar bith bainteach le saorthoil aon rannpháirtí.
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{