From 7e99d4291172f4dadb59b81cf525817dd8a210e5 Mon Sep 17 00:00:00 2001 From: Comment Date: Tue, 4 Dec 2012 14:53:44 +0000 Subject: dress rehearsal version --- vfg/src/music.cpp | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) (limited to 'vfg/src/music.cpp') diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp index 30af87b..8f3b767 100755 --- a/vfg/src/music.cpp +++ b/vfg/src/music.cpp @@ -132,6 +132,15 @@ void musicscore::printNotes() { printf("%i: %i, %i for %i\n",iter->first,iter->second->num,iter->second->velocity,iter->second->duration); } } +void musicscore::makeRandomNotes(int length,int startFreq,int endFreq){ + notes.clear(); + int time=startFreq; + while (time::iterator iter; @@ -246,6 +254,13 @@ void musicscore::playerControl(int key){ } } //--------------------------------------------------------------------------------------------------------------------------------------------- +song::song(){ + isPractice=true; +} +song::~song(){ + backing.unloadSound(); + melody.unloadSound(); +} song::song(string backfile,string melfile,string musfile,string lyricfile,string levelfile) { backing.loadSound(backfile); melody.loadSound(melfile); @@ -253,6 +268,7 @@ song::song(string backfile,string melfile,string musfile,string lyricfile,string lyrics.load(lyricfile); levels.load(levelfile); isPlaying=false; + isPractice=false; } void song::setTimeframe(int millis) {notes.setTimeframe(millis);} void song::setKeyThresh(int millis) {notes.keyThresh=millis;} @@ -264,13 +280,7 @@ int song::getCurrentTime(){ return ofGetElapsedTimeMillis()-startTime; } void song::play() { - backing.play(); - melody.play(); - startTime=ofGetElapsedTimeMillis(); - notes.start(); - lyrics.start(); - isPlaying=true; - notes.makeFlakes(fThreshStart,fThreshEnd,&levels); + preRoll(0); } void song::stop() { backing.stop(); @@ -279,25 +289,36 @@ void song::stop() { } void song::preRoll(long preroll) { startTime=ofGetElapsedTimeMillis()+preroll; - notes.start(startTime); - lyrics.start(startTime); + if (isPractice) { + notes.makeRandomNotes(20000,4000,1000); + levels.makePractice(20000); + } + else { + lyrics.start(startTime); + } + notes.makeFlakes(fThreshStart,fThreshEnd,&levels); + notes.start(startTime); isPreroll=true; isPlaying=true; - notes.makeFlakes(fThreshStart,fThreshEnd,&levels); } void song::drawNotes(float hOffs){ notes.drawNotes(hOffs,&levels); } +string song::getScoreString(){ + int songTime=ofGetElapsedTimeMillis()-startTime; + return ofToString((float)songTime/1000.0f,1)+" "+ofToString(levels.getLevel(songTime))+" "+ofToString(notes.missedFlakes)+" of "+ofToString(levels.getLives(songTime)); +} void song::draw(float hOffs,float scale){ int songTime=ofGetElapsedTimeMillis()-startTime; if (isPlaying) { - if (isPreroll) { + if (isPreroll&&(!isPractice)) { if (startTimelevels.length) { printf("stopping: %i (%i)\n",songTime,levels.length); stop(); } } - - ofDrawBitmapString(ofToString((float)songTime/1000.0f,1)+" "+ofToString(levels.getLevel(songTime))+" "+ofToString(notes.missedFlakes)+" of "+ofToString(levels.getLives(songTime)),hOffs+10,(ofGetHeight()*gridY[1])-3); } void song::playerControl(int key){ notes.playerControl(key); -- cgit v1.2.3