diff options
Diffstat (limited to 'vfg/src/music.cpp')
| -rwxr-xr-x | vfg/src/music.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp index 359b21d..b5b584c 100755 --- a/vfg/src/music.cpp +++ b/vfg/src/music.cpp @@ -28,7 +28,7 @@ void lyricscore::draw(){ } //----------------------------------------------------------------------------------------------------------
musicscore::musicscore() {
- timeframe=2000;
+ timeframe=5000;
missedLast=false; nowpoint=1.0f; missedNote=-1;
@@ -124,7 +124,7 @@ void musicscore::parseMidi(string filename){ iter1--;
printf("processed %s: length %f, %i notes in %f seconds\n",filename.c_str(),((float)(iter1->first+iter1->second->duration)*.001f),notes.size(),ofGetElapsedTimef()-wt);
}
-void musicscore::makeFlakes(int threshStart,int threshEnd){
+void musicscore::makeFlakes(int threshStart,int threshEnd,levelscore *levels){
flakes.clear();
//decimate notes to generate flakes that can be interacted with
map<int,note*>::iterator iter;
@@ -137,12 +137,12 @@ void musicscore::makeFlakes(int threshStart,int threshEnd){ flakes[notes.begin()->first]->puppet=snowflakes[notemap(lastNote->num)];
for (iter = notes.begin(); iter != notes.end(); iter++) {
float songPos=((float)iter->first)/songDuration;
- if ((notemap(iter->second->num)!=notemap(lastNote->num))||(iter->first-lastTime>((songPos*threshEnd)+((1.0f-songPos)*threshStart)))) {
+ if ((levels->nextLevelTime(iter->first)>2000)&&((notemap(iter->second->num)!=notemap(lastNote->num))||(iter->first-lastTime>((songPos*threshEnd)+((1.0f-songPos)*threshStart))))) {
flakes[iter->first]=new flake(iter->second->num,iter->second->velocity,iter->second->duration);
flakes[iter->first]->puppet=snowflakes[notemap(iter->second->num)];
+ lastNote=iter->second;
+ lastTime=iter->first;
}
- lastNote=iter->second;
- lastTime=iter->first;
} missedFlake=flakes.end(); missedNote=-1;
@@ -210,7 +210,7 @@ void musicscore::drawFlakes(levelscore *levels) { }
missedLast=!iter->second->activated;
}
- //at this point missed points to the latest unactivated flake in the level + //at this point missed points to the latest unactivated flake in the level if there is one if ((missed!=flakes.end())&&(missedFlake!=missed)) { missedFlake=missed; missedNote=notemap(missed->second->num); @@ -237,7 +237,7 @@ song::song(string backfile,string melfile,string musfile,string lyricfile,string lyrics.load(lyricfile);
levels.load(levelfile);
isPlaying=false;
- keyThresh=400; + keyThresh=500; notes.setNowpoint(0.8f);
}
void song::setTimeframe(int millis) {notes.setTimeframe(millis);}
@@ -253,7 +253,7 @@ void song::play() { notes.start(); lyrics.start();
isPlaying=true;
- notes.makeFlakes(fThreshStart,fThreshEnd);
+ notes.makeFlakes(fThreshStart,fThreshEnd,&levels);
}
void song::stop() {
backing.stop();
@@ -266,7 +266,7 @@ void song::preRoll(long preroll) { lyrics.start(startTime);
isPreroll=true;
isPlaying=true;
- notes.makeFlakes(fThreshStart,fThreshEnd);
+ notes.makeFlakes(fThreshStart,fThreshEnd,&levels);
}
void song::drawNotes(){
notes.drawNotes(&levels);
@@ -307,4 +307,7 @@ int song::hitNote(){ int n=notes.hitNote;
notes.hitNote=-1;
return n;
+}
+int song::getLevel(long time){
+ return levels.getLevel(time-startTime);
} |
