Making a decent music visualizer for Linux

Occasionally I like to listen to music and have a visualizer flicker along with the music.
I tried the ncmpcpp build-in visualizer and c.a.v.a. but for some reason they both had a pretty terrible framerate. I wanted something that is as smooth as the foobar2k spectrum visualizer, so I decided to write my own music visualizer.

The project started off as a simple Oscilloscope with no filtering, just a modified OpenGL learning example that draws the audio buffer.

Once I became a little more familiar with OpenGL and a FFT library (most of the code was taken from ncmpcpp :) ) I modified the project to render a audio spectrum. Back then the code was pretty ugly C with global functions and variables. Porting the code over to C++ was pretty much straight forward with the occasional segfaults due to switching variable names.

After some time, I figured that hard-coded variables aren't good enough, so I implemented configuration file parsing.
Since then I implemented other features like pulseaudio input, spectrum gravity (done on the GPU), rainbow colors and runtime configuration parsing and rendering.

Here are some example pictures:


Github link, In case you are interested:

4 Likes

nice work

How would you rate your experience with GLFW? How would you compare it to freeglut?

I've used freeglut plenty of times so I found your opengl code for GLFW intriguing.

Seems to me that some linux players ported Milkdrop/style stuff into them and that there is/was serious untapped wealth in the old school Winamp style visuals.

This is the first time I ever used GLFW,
But I had a quick look at the freeglut api reference and I'd say that the only difference between them is that GLFW doesn't have rendering functions. GLFW can also create a window without OpenGL context, which is pretty neat for Vulkan.

1 Like

I will seriously consider GLFW next time around. There are some clunky things about freeglut trying to use with latest openGL. ( It's old as dirt )