Changed FFT scaling to use native code and requests

This commit is contained in:
Jarcode
2018-01-12 17:04:03 -08:00
parent 96f40d089e
commit 15ffe975cc
6 changed files with 20 additions and 8 deletions

View File

@@ -71,7 +71,7 @@ void main() {
}
#undef smooth_f
v *= AMPLIFY * (1 + p); /* amplify result */
v *= AMPLIFY; /* amplify result */
if (d < v - BAR_OUTLINE_WIDTH) { /* if within range of the reported frequency, draw */
#if BAR_OUTLINE_WIDTH > 0
if (md < (BAR_WIDTH / 2) - BAR_OUTLINE_WIDTH)

View File

@@ -91,9 +91,6 @@ void render_side(in sampler1D tex, float idx) {
s *= clamp((abs((screen.x / 2) - gl_FragCoord.x) / screen.x) * 48, 0.0F, 1.0F);
s *= clamp((min(gl_FragCoord.x, screen.x - gl_FragCoord.x) / screen.x) * 48, 0.0F, 1.0F);
/* amplify higher frequencies */
s *= 1 + BDIST;
/* and finally set fragment color if we are in range */
#if INVERT > 0
float pos = float(screen.y) - gl_FragCoord.y;

View File

@@ -54,7 +54,7 @@ void main() {
float v;
if (idx > 0) v = smooth_f(audio_l); /* left buffer */
else v = smooth_f(audio_r); /* right buffer */
v *= AMPLIFY * (1 + pos); /* amplify and scale with frequency */
v *= AMPLIFY; /* amplify */
#undef smooth_f
d -= C_RADIUS + (float(C_LINE) / 2.0F); /* offset to fragment distance from inner circle */
if (d <= v - BAR_OUTLINE_WIDTH) {

View File

@@ -19,3 +19,12 @@
and lower values reduce the displayed frequencies in a log-like
scale. */
#define SAMPLE_RANGE 0.9
/* Factor for how to scale higher frequencies. Used in a linear equation
which is multiplied by the result of the fft transformation. */
#request setfftscale 10.2
/* Cutoff for the bass end of the audio data when scaling frequencies.
Higher values cause more of the bass frequencies to be skipped when
scaling. */
#request setfftcutoff 0.3

View File

@@ -42,7 +42,6 @@ float smooth_audio(in sampler1D tex, int tex_sz, highp float idx, float r) {
avg += texture(tex, float(s) / float(tex_sz)).r * w;
}
avg /= weight;
avg *= max(idx + 0.7, 1);
return avg;
}