Created
July 27, 2010 04:15
-
-
Save encryptio/491728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int pti = 0; | |
for (int i = 0; i < len; i++) { | |
float f = (float)i/len*sr; | |
if ( f < curve->pts[0].freq ) { | |
// before the first point | |
in[i].r = curve->pts[0].power; | |
} else if ( curve->pts[curve->ct-1].freq < f ) { | |
// after last point | |
in[i].r = curve->pts[curve->ct-1].freq; | |
} else { | |
// in-between points | |
while ( !(curve->pts[pti].freq <= f && f < curve->pts[pti+1].freq) ) pti++; | |
// pts[pti ] is the point immediately to the left of f | |
// likewise, pts[pti+1] is the point immediately to the right of f | |
wantpoint *low = &(curve->pts[pti ]); | |
wantpoint *hi = &(curve->pts[pti+1]); | |
float p0 = (f-low->freq)/(hi->freq-low->freq); | |
in[i].r = p0*hi->power + (1-p0)*low->power; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment