diff options
| author | Tim Redfern <tim@gray.(none)> | 2012-11-13 15:07:39 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@gray.(none)> | 2012-11-13 15:07:39 +0000 |
| commit | f3b7df8e1a44be946bbc0cf4c2b89e2920d6d7ee (patch) | |
| tree | 547d77f1366c5beb0637b9359eb37da66bc7cd58 /vfg/src/music.cpp | |
| parent | 27b7b4c5ce0102c6089cd0b6cc58096b0c5ccf36 (diff) | |
initial asterisk hookup
Diffstat (limited to 'vfg/src/music.cpp')
| -rwxr-xr-x | vfg/src/music.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/vfg/src/music.cpp b/vfg/src/music.cpp index 4d62f6f..9fd88d3 100755 --- a/vfg/src/music.cpp +++ b/vfg/src/music.cpp @@ -1,8 +1,18 @@ #include "music.h"
//event times & durations are absolute integer milliseconds - - +
+int notemap(int n) {
+ //nonlinear mapping of notes to 3 columns - space 5,4,7
+ //note drawing 46h - 52h
+ int numnotes=16;
+ int firstnote=70;
+ int note=n-firstnote;
+ if (note<5) return 0;
+ else if (note <9) return 1;
+ else return 2;
+} +//---------------------------------------------------------------------------------------------------------- void lyricscore::draw(){ int scoreTime=ofGetElapsedTimeMillis()-startTime; map<int,lyric*>::iterator iter; @@ -108,6 +118,7 @@ void musicscore::parseMidi(string filename){ 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){
+ flakes.clear();
//decimate notes to generate flakes that can be interacted with
map<int,note*>::iterator iter;
note *lastNote=notes.begin()->second;
@@ -118,7 +129,7 @@ void musicscore::makeFlakes(int threshStart,int threshEnd){ flakes[notes.begin()->first]=notes.begin()->second;
for (iter = notes.begin(); iter != notes.end(); iter++) {
float songPos=((float)iter->first)/songDuration;
- if ((iter->second->num/5!=lastNote->num/5)||(iter->first-lastTime>((songPos*threshEnd)+((1.0f-songPos)*threshStart)))) {
+ if ((notemap(iter->second->num)!=notemap(lastNote->num))||(iter->first-lastTime>((songPos*threshEnd)+((1.0f-songPos)*threshStart)))) {
flakes[iter->first]=iter->second;
}
lastNote=iter->second;
@@ -158,13 +169,13 @@ void musicscore::drawFlakes(levelscore *levels) { float heightStep=((float)ofGetHeight())/timeframe;
map<int,note*>::iterator iter;
//draw flakes
- for (iter = flakes.lower_bound(scoreStart-200); iter != flakes.upper_bound(scoreEnd); ++iter) { //extra 200ms for flake to leave screen
+ for (iter = flakes.lower_bound(scoreStart); iter != flakes.upper_bound(scoreEnd); iter++) {
int thisnote=iter->second->num-firstnote;
int thisstart=iter->first-scoreStart;
int thislength=iter->second->duration;
if (iter->second->activated) ofSetColor(255,255,255);
else ofSetColor(ofColor::fromHsb(((float)thisnote*255)/numnotes,200,255));
- flake.draw(((thisnote/5)*300)+100,ofGetHeight()-(thisstart*heightStep),flake.getWidth()/2,flake.getHeight()/2);
+ flake.draw((notemap(iter->second->num)*300)+100,ofGetHeight()-(thisstart*heightStep),flake.getWidth()/2,flake.getHeight()/2);
//todo - make all drawing resolution independent
}
@@ -172,7 +183,7 @@ void musicscore::drawFlakes(levelscore *levels) { //is it the number of flakes they can lose per segment?
missedFlakes=0;
missedLast=false;
- for (iter = flakes.lower_bound(levels->getLowerBound(levels->getLevel(scoreStart))); iter != flakes.upper_bound(scoreStart); ++iter){
+ for (iter = flakes.lower_bound(levels->getLowerBound(levels->getLevel(scoreStart))); iter != flakes.upper_bound(scoreStart); iter++){
if (!iter->second->activated) {
missedFlakes++;
}
@@ -183,7 +194,7 @@ void musicscore::drawFlakes(levelscore *levels) { void musicscore::playerControl(int key,int threshold){
map<int,note*>::iterator iter;
int scoreTime=ofGetElapsedTimeMillis()-startTime;
- for (iter = flakes.lower_bound(scoreTime-threshold); iter != flakes.upper_bound(scoreTime+threshold); ++iter) {
+ for (iter = flakes.lower_bound(scoreTime-threshold); iter != flakes.upper_bound(scoreTime+threshold); iter++) {
iter->second->activate();
}
}
@@ -195,7 +206,7 @@ song::song(string backfile,string melfile,string musfile,string lyricfile,string lyrics.load(lyricfile);
levels.load(levelfile);
isPlaying=false;
- keyThresh=200; + keyThresh=400; notes.setNowpoint(0.8f);
}
void song::setTimeframe(int millis) {notes.setTimeframe(millis);}
|
