c++ - Frequency - linear bins to logarithmic screenspace -


i'm working on project, need visualize spectral analysis set precise parameters. i'm conversion of bins screen space, because in linear space, magnitudes in lower frequencies squashed together. here's code in c++:

float windowsize = 640; float windowheight = 480; (size_t = 0; < bins; i++) {     float m = audioin.getspectrum.at(i)*windowheight;     float pos = i;     drawline(vec2(pos, 0), vec2(pos, m)); } 

i trying compute pos using different approaches, failed miserably. i'm missing crucial knowledge logarithms guess.

disclaimer: personal art project, not homework assignment.

typically spectrographs displayed on base 10 logarithmic scale.

assuming bins in case go 0 hz nyquist hz might try (for 44.1khz audio):

float nyquist = 22050.0; float logmax = log10(nyquist); float log = log10((float)i * nyquist / (float)bins); float pos = log / logmax * windowsize; 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -