Added support for mono bars rendering, closes #123
This commit is contained in:
@@ -131,7 +131,7 @@ struct gl_data {
|
||||
int fcounter, ucounter, kcounter;
|
||||
bool print_fps, avg_window, interpolate, force_geometry, force_raised,
|
||||
copy_desktop, smooth_pass, premultiply_alpha, check_fullscreen,
|
||||
clickthrough;
|
||||
clickthrough, mirror_input;
|
||||
void** t_data;
|
||||
size_t t_count;
|
||||
float gravity_step, target_spu, fr, ur, smooth_distance, smooth_ratio,
|
||||
@@ -226,6 +226,7 @@ static GLuint shaderload(const char* rpath,
|
||||
"#define _SMOOTH_FACTOR %.6f\n"
|
||||
"#define _USE_ALPHA %d\n"
|
||||
"#define _PREMULTIPLY_ALPHA %d\n"
|
||||
"#define _CHANNELS %d\n"
|
||||
"#define USE_STDIN %d\n"
|
||||
"#if USE_STDIN == 1\n"
|
||||
"uniform %s STDIN;\n"
|
||||
@@ -251,7 +252,7 @@ static GLuint shaderload(const char* rpath,
|
||||
GLchar* buf = malloc((blen * sizeof(GLchar*)) + ext.p_len);
|
||||
int written = snprintf(buf, blen, header_fmt, (int) shader_version, (int) max_uniforms,
|
||||
gl->smooth_pass ? 1 : 0, (double) gl->smooth_factor,
|
||||
1, gl->premultiply_alpha ? 1 : 0,
|
||||
1, gl->premultiply_alpha ? 1 : 0, gl->mirror_input ? 1 : 2,
|
||||
gl->stdin_type != STDIN_TYPE_NONE, bind_types[gl->stdin_type].n,
|
||||
bind_header);
|
||||
if (written < 0) {
|
||||
@@ -850,6 +851,7 @@ struct renderer* rd_new(const char** paths, const char* entry,
|
||||
.sm_prog = 0,
|
||||
.copy_desktop = true,
|
||||
.premultiply_alpha = true,
|
||||
.mirror_input = false,
|
||||
.check_fullscreen = false,
|
||||
.smooth_pass = true,
|
||||
.fft_scale = 10.2F,
|
||||
@@ -970,7 +972,10 @@ struct renderer* rd_new(const char** paths, const char* entry,
|
||||
},
|
||||
{
|
||||
.name = "setmirror", .fmt = "b",
|
||||
.handler = RHANDLER(name, args, { r->mirror_input = *(bool*) args[0]; })
|
||||
.handler = RHANDLER(name, args, {
|
||||
r->mirror_input = *(bool*) args[0];
|
||||
gl->mirror_input = *(bool*) args[0];
|
||||
})
|
||||
},
|
||||
{
|
||||
.name = "setfullscreencheck", .fmt = "b",
|
||||
@@ -2101,7 +2106,7 @@ bool rd_update(struct renderer* r, float* lb, float* rb, size_t bsz, bool modifi
|
||||
gl->ur = gl->ucounter / gl->tcounter; /* update rate (UPS) */
|
||||
if (gl->print_fps) { /* print FPS */
|
||||
#ifdef GLAVA_DEBUG
|
||||
printf("FPS: %.2f, UPS: %.2f\n, time: %.2f",
|
||||
printf("FPS: %.2f, UPS: %.2f, time: %.2f\n",
|
||||
(double) gl->fr, (double) gl->ur, (double) gl->time);
|
||||
#else
|
||||
printf("FPS: %.2f, UPS: %.2f\n",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* Note: to only render a single channel, see `setmirror` in `rc.glsl`. */
|
||||
|
||||
/* Center line thickness (pixels) */
|
||||
#define C_LINE 1
|
||||
@@ -24,8 +25,10 @@
|
||||
/* Whether to switch left/right audio buffers */
|
||||
#define INVERT 0
|
||||
/* Whether to flip the output vertically */
|
||||
#define FLIP 0
|
||||
#define FLIP 1
|
||||
/* Whether to mirror output along `Y = X`, causing output to render on the left side of the window */
|
||||
/* Use with `FLIP 1` to render on the right side */
|
||||
#define MIRROR_YX 0
|
||||
/* Whether to disable mono rendering when `#request setmirror true` is set in `rc.glsl`. */
|
||||
#define DISABLE_MONO 0
|
||||
|
||||
|
||||
@@ -29,6 +29,10 @@ out vec4 fragment;
|
||||
#define TWOPI 6.28318530718
|
||||
#define PI 3.14159265359
|
||||
|
||||
#if DISABLE_MONO == 1
|
||||
#define CHANNELS 2
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
#if MIRROR_YX == 0
|
||||
@@ -42,8 +46,16 @@ void main() {
|
||||
#define AREA_X gl_FragCoord.y
|
||||
#define AREA_Y gl_FragCoord.x
|
||||
#endif
|
||||
|
||||
|
||||
#if CHANNELS == 2
|
||||
float dx = (AREA_X - (AREA_WIDTH / 2));
|
||||
#else
|
||||
#if INVERT == 1
|
||||
float dx = AREA_WIDTH - AREA_X;
|
||||
#else
|
||||
float dx = AREA_X;
|
||||
#endif
|
||||
#endif
|
||||
#if FLIP == 0
|
||||
float d = AREA_Y;
|
||||
#else
|
||||
@@ -57,8 +69,13 @@ void main() {
|
||||
float p, s;
|
||||
if (md < ceil(float(BAR_WIDTH) / 2) && md >= -floor(float(BAR_WIDTH) / 2)) { /* if not in gap */
|
||||
s = dx / section;
|
||||
p = (sign(s) == 1.0 ? ceil(s) : floor(s)) / float(nbars / 2); /* position, (-1.0F, 1.0F)) */
|
||||
p += sign(p) * ((0.5F + center) / AREA_WIDTH); /* index center of bar position */
|
||||
p = (sign(s) == 1.0 ? ceil(s) : floor(s));
|
||||
#if CHANNELS == 2
|
||||
p /= float(nbars / 2);
|
||||
#else
|
||||
p /= float(nbars);
|
||||
#endif
|
||||
p += sign(p) * ((0.5F + center) / AREA_WIDTH); /* index center of bar position */
|
||||
/* Apply smooth function and index texture */
|
||||
#define smooth_f(tex, p) smooth_audio(tex, audio_sz, p)
|
||||
float v;
|
||||
@@ -72,7 +89,9 @@ void main() {
|
||||
#if DIRECTION == 1
|
||||
p = 1.0F - p;
|
||||
#endif
|
||||
#if INVERT > 0
|
||||
#if CHANNELS == 1
|
||||
v = smooth_f(audio_l, p);
|
||||
#elif INVERT > 0
|
||||
v = smooth_f(audio_l, p);
|
||||
#else
|
||||
v = smooth_f(audio_r, p);
|
||||
@@ -82,7 +101,9 @@ void main() {
|
||||
#if DIRECTION == 1
|
||||
p = 1.0F - p;
|
||||
#endif
|
||||
#if INVERT > 0
|
||||
#if CHANNELS == 1
|
||||
v = smooth_f(audio_l, p);
|
||||
#elif INVERT > 0
|
||||
v = smooth_f(audio_r, p);
|
||||
#else
|
||||
v = smooth_f(audio_l, p);
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
"none" - Disable window opacity completely. */
|
||||
#request setopacity "native"
|
||||
|
||||
/* Whether to mirror left and right audio input channels from PulseAudio.*/
|
||||
/* Whether to average and mirror left and right audio input channels.
|
||||
This may cause some modules to only render a single channel. */
|
||||
#request setmirror false
|
||||
|
||||
/* OpenGL context and GLSL shader versions, do not change unless
|
||||
|
||||
Reference in New Issue
Block a user