diff options
| author | Tim Redfern <tim@gray.(none)> | 2012-11-10 20:52:55 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@gray.(none)> | 2012-11-10 20:52:55 +0000 |
| commit | 275acd8fe15ca66401cff428091772e7ab71444e (patch) | |
| tree | 9a122a9385ff56006a67a37e34e0c41bee690873 /vfg/src/music.cpp | |
| parent | eda90b505d3a583e0c3788ca1ad924d75b02fe01 (diff) | |
lyrics displaying correctly
Diffstat (limited to 'vfg/src/music.cpp')
| -rwxr-xr-x | vfg/src/music.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp index 29b1ef6..ef43c11 100755 --- a/vfg/src/music.cpp +++ b/vfg/src/music.cpp @@ -1,7 +1,22 @@ #include "music.h"
-//event times & durations are absolute integer milliseconds
-//---------------------------------------------------------------------------------------------------------------------------------------------
+//event times & durations are absolute integer milliseconds + + +void lyricscore::draw(){ + int scoreTime=ofGetElapsedTimeMillis()-startTime; + map<int,lyric*>::iterator iter; + iter=lyrics.upper_bound(scoreTime); + if (iter!=lyrics.begin()) { + iter--; + if ((iter->first+iter->second->duration)>scoreTime) { //outpoint of lyric previous to the one next soonest is afterwards => this lyric is visible + int alpha=((iter->first+iter->second->duration)-scoreTime)<fadeout?(int)((((float)((iter->first+iter->second->duration)-scoreTime))/((float)fadeout))*255.0f):255; + ofSetColor(255,255,255,alpha); + font.drawString(iter->second->text,(ofGetWidth()/2)-(font.stringWidth(iter->second->text)/2.0f), ypos); + } + } +} +//----------------------------------------------------------------------------------------------------------
musicscore::musicscore() {
timeframe=2000;
flake.loadImage("flake.png");
@@ -177,7 +192,8 @@ void song::play() { backing.play();
melody.play();
startTime=ofGetElapsedTimeMillis();
- notes.startTime=startTime;
+ notes.start(); + lyrics.start();
isPlaying=true;
notes.makeFlakes(fThreshStart,fThreshEnd);
}
@@ -188,7 +204,8 @@ void song::stop() { }
void song::preRoll(long preroll) {
startTime=ofGetElapsedTimeMillis()+preroll;
- notes.startTime=startTime;
+ notes.start(startTime); + lyrics.start(startTime);
isPreroll=true;
isPlaying=true;
notes.makeFlakes(fThreshStart,fThreshEnd);
@@ -213,9 +230,10 @@ void song::draw(){ }
}
else melody.setVolume(1.0f);
- notes.draw(&levels);
+ notes.draw(&levels); + lyrics.draw();
}
-
+
ofDrawBitmapString(ofToString((float)songTime/1000.0f,3)+" "+ofToString(levels.getLevel(songTime))+" "+ofToString(notes.missedFlakes)+" of "+ofToString(levels.getLives(songTime)),10,ofGetHeight()-15);
}
void song::playerControl(int key){
|
