Updated gravity transform, cleaned up graph shader
This commit is contained in:
@@ -7,10 +7,50 @@ uniform ivec2 screen; /* screen dimensions */
|
||||
#request uniform "audio_sz" audio_sz
|
||||
uniform int audio_sz;
|
||||
|
||||
#request setavgframes 4
|
||||
/* How many frames to queue and run through the average function */
|
||||
#request setavgframes 6
|
||||
|
||||
/* Whether to window frames ran through the average function (new & old frames
|
||||
are weighted less). This massively helps smoothing out spikes in the animation */
|
||||
#request setavgwindow true
|
||||
// #request interpolate true
|
||||
#request setgravitystep 0.06
|
||||
|
||||
/* Gravity step, higher values means faster drops. The step is applied in a rate
|
||||
independant method like so:
|
||||
|
||||
val -= (gravitystep) * (seconds per update) */
|
||||
#request setgravitystep 5.2
|
||||
|
||||
/* When we transform our audio, we need to go through the following steps:
|
||||
|
||||
transform -> "window"
|
||||
First, apply a window function to taper off the ends of the spectrum, helping
|
||||
avoid artifacts in the FFT output.
|
||||
|
||||
transform -> "fft"
|
||||
Apply the Fast Fourier Transform algorithm to separate raw audio data (waves)
|
||||
into their respective spectrums.
|
||||
|
||||
transform -> "fft"
|
||||
As part of the FFT process, we return spectrum magnitude on a log(n) scale,
|
||||
as this is how the (decibel) dB scale functions.
|
||||
|
||||
transform -> "gravity"
|
||||
To help make our data more pleasing to look at, we apply our data received over
|
||||
time to a buffer, taking the max of either the existing value in the buffer or
|
||||
the data from the input. We then reduce the data by the 'gravity step', and
|
||||
return the storage buffer.
|
||||
|
||||
This makes frequent and abrupt changes in frequency less distracting, and keeps
|
||||
short frequency responses on the screen longer.
|
||||
|
||||
transform -> "avg"
|
||||
As a final step, we take the average of several data frames (specified by
|
||||
'setavgframes') and return the result to further help smooth the resulting
|
||||
animation. In order to mitigate abrupt changes to the average, the values
|
||||
at each end of the average buffer can be weighted less with a window function
|
||||
(the same window function used at the start of this step!). It can be disabled
|
||||
with 'setavgwindow'.
|
||||
*/
|
||||
|
||||
#request uniform "audio_l" audio_l
|
||||
#request transform audio_l "window"
|
||||
|
||||
Reference in New Issue
Block a user