A shader that changes brightness of its object based on the perceived beat of the given sound. This shader uses a simple beat-detection algorithm based on calculating root mean square (RMS) of amplitudes across all channels. RMS is constantly recalculated over a sliding window of the past few seconds. If the current amplitude value is above the RMS the beat is detected.
It is important to note that this shader does not work by default for all types of sounds. For each particular sound profile you may need to "play" with smoothing and threshold gain to achieve the best visual effect.
Note that by default this shader is inactive and user must call start method to start this shader.
Value parameters
smoothing
Smoothing mode. Default value is SMOOTH_UP.
snd
Sound asset to analyze for the beat detection. Note that the start of playing this sound should generally be synchronized in time with calling start method on this shader. If not provided - ensure that method setSound is called before this shader is started.
thresholdGain
A constant that can be used to fine tune the calculated RMS-based threshold. Once threshold is calculated it will be multiplied by this constant. Default value is 1.0f. Typical fine tuning values are between 0.5f and 0.9f.
thresholdTailMs
Duration of the sliding window in milliseconds that is used for calculating RMS-based threshold.
Called on each frame pass on scene object that has this shaders attached to it. This callback is called regardless of whether or not the scene object is visible or in camera frame.
Called on each frame pass on scene object that has this shaders attached to it. This callback is called regardless of whether or not the scene object is visible or in camera frame.
Sets given sound asset for this shader. Note that if this shader is currently active it will be stopped by calling method stop first. After the sound is set you need to call method start to active this shader. Note that the start of playing this sound should generally be synchronized in time with calling start method on this shader.
Sets given sound asset for this shader. Note that if this shader is currently active it will be stopped by calling method stop first. After the sound is set you need to call method start to active this shader. Note that the start of playing this sound should generally be synchronized in time with calling start method on this shader.
Starts the shader effect. Note that the start of playing the sound this shader is configured with must be generally synchronized in time with calling this method.
Starts the shader effect. Note that the start of playing the sound this shader is configured with must be generally synchronized in time with calling this method.
Gets the origin of this asset. Typically, this should be a URL, file name or class name for in-code assets like array images, animations or system font.
Gets the origin of this asset. Typically, this should be a URL, file name or class name for in-code assets like array images, animations or system font.