patriciogonzalezvivo / glslViewer

Console-based GLSL Sandbox for 2D/3D shaders
BSD 3-Clause "New" or "Revised" License
4.7k stars 351 forks source link

Feature request: Audio input uniform variable #61

Closed dgfitch closed 3 years ago

dgfitch commented 7 years ago

I'm new to GLSL but I'm learning thanks to Book of Shaders (so cool!)

I think it would be amazing to get access to the microphone or other audio input in a uniform vector, as The_Force allows in its bands uniform, which is a vec4(low, mid-low, mid-high, high). I think shaderToy also supports sound input with some kind of channels uniform, but I'm not smart enough to figure that out.

You can plug in a mic or load an audio file, and make shaders react to audio very easily. It's very fun in The_Force and it could be a cool feature in glslViewer, where a command line switch could turn on microphone or listen to the current playing audio or something.

I don't know C++ very well at all, or how hard this would be to do on different platforms. But I may look into it someday soon and send a pull request if I figure it out! If you think this is a dumb idea, feel free to close this issue, I won't be offended. Haha.

Thanks for making this cool tool!

doug-moen commented 7 years ago

shadertoy.com has more audio input data in its uniforms than just 4 numbers. See: https://www.shadertoy.com/view/Xds3Rr

shadertoy also lets you write sound shaders that generate audio. Click on the "Sound" tab to see the sound shader with its mainSound entry point: https://www.shadertoy.com/view/ldXXDj

I think it would be good to replicate the shadertoy interface. Then we could run the shaders I linked to in glslViewer. We'd need to select a good cross-platform audio library to support this, as you mention.

patriciogonzalezvivo commented 6 years ago

What about the possibility to link OSC messages/events to uniforms? Trying to find ways to get more "life" data to GLSLViewer for VJing... in a flexible way.

kgolinski commented 6 years ago

OSC would be a killer feature! I imagine the perfect setup with shaders, rpi and touchOSC on a phone.

teraspora commented 5 years ago

For each frame, I'd like to sample the live audio stream for dominant frequencies and amplitude data, so my shader can react to the music. The audio data doesn't have to be precise so could perhaps be input by a cheap microphone. Then turn it into a varying vec4 or mat4for example...? Would this be feasible?

bespsm commented 3 years ago

I guess we can close this issue, what do you think @patriciogonzalezvivo ?

patriciogonzalezvivo commented 3 years ago

True! Thanks again. For those interested please read https://github.com/patriciogonzalezvivo/glslViewer/wiki/Compiling-with-Audio-and-Video-support