Added support for mono bars rendering, closes #123

This commit is contained in:
Jarcode
2019-08-26 23:03:22 -07:00
parent e8e8b1f701
commit 9d4674d680
4 changed files with 41 additions and 11 deletions

View File

@@ -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

View File

@@ -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);

View File

@@ -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