Improve average windowing, remove smooth overrides
This commit is contained in:
@@ -657,7 +657,8 @@ static struct gl_bind_src bind_sources[] = {
|
|||||||
{ .name = "time", .type = BIND_FLOAT, .src_type = SRC_SCREEN }
|
{ .name = "time", .type = BIND_FLOAT, .src_type = SRC_SCREEN }
|
||||||
};
|
};
|
||||||
|
|
||||||
#define window(t, sz) (0.53836 - (0.46164 * cos(TWOPI * (double) t / (double)sz)))
|
#define window(t, sz) (0.53836 - (0.46164 * cos(TWOPI * (double) t / (double) sz)))
|
||||||
|
#define window_frame(t, sz) (0.6 - (0.4 * cos(TWOPI * (double) t / (double) sz)))
|
||||||
#define ALLOC_ONCE(u, udata, sz) \
|
#define ALLOC_ONCE(u, udata, sz) \
|
||||||
if (*udata == NULL) { \
|
if (*udata == NULL) { \
|
||||||
u = calloc(sz, sizeof(typeof(*u))); \
|
u = calloc(sz, sizeof(typeof(*u))); \
|
||||||
@@ -762,7 +763,7 @@ void transform_average(struct gl_data* d, void** udata, void* data) {
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
if (use_window)
|
if (use_window)
|
||||||
DO_AVG(window(f, d->avg_frames - 1));
|
DO_AVG(window_frame(f, d->avg_frames - 1));
|
||||||
else
|
else
|
||||||
DO_AVG(1);
|
DO_AVG(1);
|
||||||
|
|
||||||
@@ -1259,7 +1260,7 @@ struct glava_renderer* rd_new(const char** paths, const char* entry,
|
|||||||
t_count += 2;
|
t_count += 2;
|
||||||
}
|
}
|
||||||
static const char* fmt = "WARNING: using \"%s\" transform explicitly "
|
static const char* fmt = "WARNING: using \"%s\" transform explicitly "
|
||||||
"is deprecated; implied from \"fft\" transform.\n";
|
"is deprecated (no-op); implied from \"fft\" transform.\n";
|
||||||
if (!strcmp(transform_functions[t].name, "gravity")) {
|
if (!strcmp(transform_functions[t].name, "gravity")) {
|
||||||
static bool gravity_warn = false;
|
static bool gravity_warn = false;
|
||||||
if (!gravity_warn) {
|
if (!gravity_warn) {
|
||||||
@@ -1274,6 +1275,13 @@ struct glava_renderer* rd_new(const char** paths, const char* entry,
|
|||||||
avg_warn = true;
|
avg_warn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!strcmp(transform_functions[t].name, "window")) {
|
||||||
|
static bool avg_warn = false;
|
||||||
|
if (!avg_warn) {
|
||||||
|
fprintf(stderr, fmt, transform_functions[t].name);
|
||||||
|
avg_warn = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
{ .name = "uniform", .fmt = "ss",
|
{ .name = "uniform", .fmt = "ss",
|
||||||
@@ -1723,7 +1731,6 @@ static void bind_1d_fbo(struct sm_fb* sm, size_t sz) {
|
|||||||
} else {
|
} else {
|
||||||
/* Just bind our data if it was already allocated and setup */
|
/* Just bind our data if it was already allocated and setup */
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, sm->fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, sm->fbo);
|
||||||
glBindTexture(GL_TEXTURE_1D, sm->tex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2108,6 +2115,8 @@ bool rd_update(struct glava_renderer* r, float* lb, float* rb, size_t bsz, bool
|
|||||||
if (load_flags[offset])
|
if (load_flags[offset])
|
||||||
goto bind_uniform;
|
goto bind_uniform;
|
||||||
load_flags[offset] = true;
|
load_flags[offset] = true;
|
||||||
|
|
||||||
|
bool set_opt = false; /* if bind->optimize_fft was set this frame */
|
||||||
|
|
||||||
/* Only apply transformations if the buffers we were given are newly copied */
|
/* Only apply transformations if the buffers we were given are newly copied */
|
||||||
if (modified) {
|
if (modified) {
|
||||||
@@ -2116,7 +2125,6 @@ bool rd_update(struct glava_renderer* r, float* lb, float* rb, size_t bsz, bool
|
|||||||
.buf = buf, .sz = sz
|
.buf = buf, .sz = sz
|
||||||
};
|
};
|
||||||
|
|
||||||
bool set_opt = false; /* if gl->optimize_fft was set this frame */
|
|
||||||
for (t = 0; t < bind->t_sz; ++t) {
|
for (t = 0; t < bind->t_sz; ++t) {
|
||||||
void (*apply)(struct gl_data*, void**, void*) = bind->transformations[t];
|
void (*apply)(struct gl_data*, void**, void*) = bind->transformations[t];
|
||||||
if (apply != NULL) {
|
if (apply != NULL) {
|
||||||
@@ -2282,7 +2290,7 @@ bool rd_update(struct glava_renderer* r, float* lb, float* rb, size_t bsz, bool
|
|||||||
drawoverlay(&gl->overlay);
|
drawoverlay(&gl->overlay);
|
||||||
glViewport(0, 0, ww, wh);
|
glViewport(0, 0, ww, wh);
|
||||||
if (!gl->premultiply_alpha) glEnable(GL_BLEND);
|
if (!gl->premultiply_alpha) glEnable(GL_BLEND);
|
||||||
|
|
||||||
/* Return state */
|
/* Return state */
|
||||||
glUseProgram(current->shader);
|
glUseProgram(current->shader);
|
||||||
if (current->indirect)
|
if (current->indirect)
|
||||||
|
|||||||
@@ -16,9 +16,3 @@
|
|||||||
1 to enable, 0 to disable. Only works with `xroot` transparency,
|
1 to enable, 0 to disable. Only works with `xroot` transparency,
|
||||||
and improves performance if disabled. */
|
and improves performance if disabled. */
|
||||||
#define C_SMOOTH 1
|
#define C_SMOOTH 1
|
||||||
|
|
||||||
/* Gravity step, overrude frin `smooth_parameters.glsl` */
|
|
||||||
#request setgravitystep 6.0
|
|
||||||
|
|
||||||
/* Smoothing factor, override from `smooth_parameters.glsl` */
|
|
||||||
#request setsmoothfactor 0.01
|
|
||||||
|
|||||||
@@ -30,11 +30,6 @@
|
|||||||
/* Offset (X) of the visualization */
|
/* Offset (X) of the visualization */
|
||||||
#define CENTER_OFFSET_X 0
|
#define CENTER_OFFSET_X 0
|
||||||
|
|
||||||
/* Gravity step, override from `smooth_parameters.glsl` */
|
|
||||||
#request setgravitystep 5.0
|
|
||||||
/* Smoothing factor, override from `smooth_parameters.glsl` */
|
|
||||||
#request setsmoothfactor 0.02
|
|
||||||
|
|
||||||
/* (DEPRECATED) outline color */
|
/* (DEPRECATED) outline color */
|
||||||
#define BAR_OUTLINE OUTLINE
|
#define BAR_OUTLINE OUTLINE
|
||||||
/* (DEPRECATED) outline width (in pixels, set to 0 to disable outline drawing) */
|
/* (DEPRECATED) outline width (in pixels, set to 0 to disable outline drawing) */
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
/* How many frames to queue and run through the average function.
|
/* How many frames to queue and run through the average function.
|
||||||
Increasing this value will create latency between the audio and the
|
Increasing this value will create latency between the audio and the
|
||||||
animation, but will make for much smoother results. */
|
animation, but will make for much smoother results. */
|
||||||
#request setavgframes 6
|
#request setavgframes 5
|
||||||
|
|
||||||
/* Whether to window frames ran through the average function (new & old
|
/* Whether to window frames ran through the average function (new & old
|
||||||
frames are weighted less). This massively helps smoothing out
|
frames are weighted less). This massively helps smoothing out
|
||||||
|
|||||||
@@ -19,19 +19,28 @@ in vec4 gl_FragCoord;
|
|||||||
#define SAMPLER(I) uniform sampler1D t##I;
|
#define SAMPLER(I) uniform sampler1D t##I;
|
||||||
#expand SAMPLER _AVG_FRAMES
|
#expand SAMPLER _AVG_FRAMES
|
||||||
|
|
||||||
|
#define WIN_FUNC window_frame
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
float r = 0;
|
float r = 0;
|
||||||
|
|
||||||
|
/* Disable windowing for two frames (distorts results) */
|
||||||
|
#if _AVG_FRAMES == 2
|
||||||
#define _AVG_WINDOW 0
|
#define _AVG_WINDOW 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Use 'shallow' windowing for 3 frames to ensure the first & last
|
||||||
|
frames have a reasonable amount of weight */
|
||||||
|
#if _AVG_FRAMES == 3
|
||||||
|
#define WIN_FUNC window_shallow
|
||||||
|
#endif
|
||||||
|
|
||||||
#if _AVG_WINDOW == 0
|
#if _AVG_WINDOW == 0
|
||||||
#define F(I) r += texelFetch(t##I, int(gl_FragCoord.x), 0).r
|
#define F(I) r += texelFetch(t##I, int(gl_FragCoord.x), 0).r
|
||||||
#else
|
#else
|
||||||
#define F(I) r += window(I, _AVG_FRAMES - 1) * texelFetch(t##I, int(gl_FragCoord.x), 0).r
|
#define F(I) r += window(I, _AVG_FRAMES - 1) * texelFetch(t##I, int(gl_FragCoord.x), 0).r
|
||||||
#endif
|
#endif
|
||||||
#expand F _AVG_FRAMES
|
#expand F _AVG_FRAMES
|
||||||
/* For some reason the CPU implementation of gravity/average produces the same output but
|
|
||||||
with half the amplitude. I can't figure it out right now, so I'm just halfing the results
|
|
||||||
here to ensure they are uniform.
|
|
||||||
|
|
||||||
TODO: fix this */
|
fragment.r = r / _AVG_FRAMES;
|
||||||
fragment.r = (r / _AVG_FRAMES) / 2;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
/* Window value t that resides in range [0, sz] */
|
/* Window value t that resides in range [0, sz] */
|
||||||
#define window(t, sz) (0.53836 - (0.46164 * cos(TWOPI * t / sz)))
|
#define window(t, sz) (0.53836 - (0.46164 * cos(TWOPI * t / sz)))
|
||||||
|
#define window_frame(t, sz) (0.6 - (0.4 * cos(TWOPI * t / sz)))
|
||||||
|
#define window_shallow(t, sz) (0.7 - (0.3 * cos(TWOPI * t / sz)))
|
||||||
/* Do nothing (used as an option for configuration) */
|
/* Do nothing (used as an option for configuration) */
|
||||||
#define linear(x) (x)
|
#define linear(x) (x)
|
||||||
/* Take value x that scales linearly between [0, 1) and return its sinusoidal curve */
|
/* Take value x that scales linearly between [0, 1) and return its sinusoidal curve */
|
||||||
|
|||||||
Reference in New Issue
Block a user