Classes, Methods, & Properties
Amplitude
This class acts as a gateway between a Unity AudioSource component and native Javascript access to the web browsers underlying Web Audio API. It monitors the referenced AudioSource.isPlaying status and automatically initializes, retireves amplitude data, and removes Web Audio API resources via the included JavaScript library. Since amplitude retrieval is already possible on other platforms (including in editor) using the Unity API, Amplitude uses platform directives to leverage Unity API in the editor, and internal logic when running on the WebGL platform.
- [Component] → [Crazy Minnow Studio] → [Amplitude] → [Amplitude]
- or from the Inspector, under [Add Component] → [Crazy Minnow Studio] → [Amplitude] → [Amplitude]
Public functions
None
Amplitude works automatically by monitoring the AudioSource.isPlaying status.
Public properties
Amplitude.audioSource (AudioSource)
Link to the Unity AudioSource component that you want to retrieve amplitude data from when running on the WebGL platform.
Amplitude.sampleSize (int)
The sample size selector offers the following sample sizes: 32, 64, 128, 256, 512, 1024, 2048. You selection is saved to this property, and passed to the Javascript function.
Amplitude.absoluteValues (bool)
Retrieved amplitude data ranges from -1 to 1, set this property to true to force a range from 0 to 1.
Amplitude.boost (float)
If your audio clip does not have a high dynamic range, you can boost the amplitude values using this slider (0 [none] to 1 [full]).
Amplitude.sample (float[])
While your audio clip is playing, this float array with a length of your selected Amplitude.sampleSize will be filled with real-time amplitude data.
Amplitude.average (float)
While your audio clip is playing, this float is filled with the real-time average from your Amplitude.sample data.