View Single Post
Old 25th February 2009, 16:19   #4
Flexi
wellspring of milk
Major Dude
 
Flexi's Avatar
 
Join Date: Apr 2007
Location: 54.089866,12.11168,18.75
Posts: 2,058
Send a message via ICQ to Flexi
code:
// Geiss' custom beat detection code: (fps-independent; quiet songs don't freak out)
decay_rate = pow(0.993, fps); // lower # = more hasty to declare a beat
min_att = 2.5; // lower # = quieter songs can declare beats
decay_to = 1.0; // lower # = more hasty to declare a beat
beat = bass/max(min_att,bass_att);
beat = max(beat, mid /max(min_att,mid_att ));
beat = max(beat, treb/max(min_att,treb_att));
beat = max( beat, (prev_beat-decay_to)*decay_rate + decay_to );
beat_level = (beat - prev_beat - 0.0)*24;
is_beat = above(beat_level, 0.5);
prev_beat = beat;

// Flexis separation and limitation code

max_bpm = 180;
sync = 1; // 1 - enable; 0 - disable

mx = max(bass_att,max(treb_att,mid_att));
mn = min(bass_att,min(treb_att,mid_att));
isbass = equal((bass_att-mn)/(mx-mn),1);
ismid = equal((mid_att-mn)/(mx-mn),1);
istreb = equal((treb_att-mn)/(mx-mn),1);

res = max(0, min(1,max(res,is_beat*below(res,0))));
bassres = max(0, min(if(sync,res,1),max(bassres,isbass*is_beat*below(bassres,0))));
midres = max(0, min(if(sync,res,1),max(midres,ismid*is_beat*below(midres,0))));
trebres = max(0, min(if(sync,res,1),max(trebres,istreb*is_beat*below(trebres,0))));

q8 = equal(bassres,1)*isbass; // is bass beat
q7 = equal(midres,1)*ismid; // is mid beat
q6 = equal(trebres,1)*istreb; // is treb beat
q3 = equal(res,1);

res = res - max_bpm/(60*fps);
bassres = bassres - max_bpm/(60*fps);
midres = midres - max_bpm/(60*fps);
trebres = trebres - max_bpm/(60*fps);



Flexi is offline   Reply With Quote