AudioWaveformRenderer
public class AudioWaveformRendererRenders audio waveforms to textures for visualization in the editor. Stateless for textures - caller owns and passes texture references.
Properties
Section titled “Properties”
BackgroundColor
Section titled “BackgroundColor”public Color BackgroundColor { get; set; }Gets or sets the background color of the waveform.
Returns
UnityEngine.Color — No return description is available.
WaveformColor
Section titled “WaveformColor”public Color WaveformColor { get; set; }Gets or sets the waveform color.
Returns
UnityEngine.Color — No return description is available.
SelectionColor
Section titled “SelectionColor”public Color SelectionColor { get; set; }Gets or sets the selection highlight color.
Returns
UnityEngine.Color — No return description is available.
Methods
Section titled “Methods”
RenderWaveform(ref Texture2D, AudioClip, int, int)
Section titled “RenderWaveform(ref Texture2D, AudioClip, int, int)”public bool RenderWaveform(ref Texture2D texture, AudioClip clip, int width, int height)Renders a waveform from an AudioClip to a texture.
Parameters
| Name | Type | Description |
|---|---|---|
texture |
UnityEngine.Texture2D | Reference to texture to render into (will be created/resized if needed) |
clip |
UnityEngine.AudioClip | The audio clip to visualize |
width |
System.Int32 | Width of the output texture |
height |
System.Int32 | Height of the output texture |
Returns
System.Boolean — True if successful
RenderWaveform(ref Texture2D, float[], int, int, int)
Section titled “RenderWaveform(ref Texture2D, float[], int, int, int)”public bool RenderWaveform(ref Texture2D texture, float[] samples, int channels, int width, int height)Renders a waveform from raw samples to a texture.
Parameters
| Name | Type | Description |
|---|---|---|
texture |
UnityEngine.Texture2D | Reference to texture to render into (will be created/resized if needed) |
samples |
System.Single[] | Interleaved audio samples |
channels |
System.Int32 | Number of audio channels |
width |
System.Int32 | Width of the output texture |
height |
System.Int32 | Height of the output texture |
Returns
System.Boolean — True if successful
CreateOverlay(ref Texture2D, int, int, float, float, float, float, float, float, float, AnimationCurve, AnimationCurve)
Section titled “CreateOverlay(ref Texture2D, int, int, float, float, float, float, float, float, float, AnimationCurve, AnimationCurve)”public bool CreateOverlay(ref Texture2D texture, int width, int height, float selectionStart, float selectionEnd, float playheadPosition = -1, float silenceStart = 0, float silenceEnd = 1, float fadeInEnd = -1, float fadeOutStart = -1, AnimationCurve fadeInCurve = null, AnimationCurve fadeOutCurve = null)Creates an overlay texture with selection and playhead.
Parameters
| Name | Type | Description |
|---|---|---|
texture |
UnityEngine.Texture2D | Reference to texture to render into (will be created/resized if needed) |
width |
System.Int32 | Width of the overlay |
height |
System.Int32 | Height of the overlay |
selectionStart |
System.Single | Normalized start position of selection (0-1) |
selectionEnd |
System.Single | Normalized end position of selection (0-1) |
playheadPosition |
System.Single | Normalized playhead position (0-1), negative to hide |
silenceStart |
System.Single | Normalized start of detected silence region (0-1) |
silenceEnd |
System.Single | Normalized end of detected silence region (0-1) |
fadeInEnd |
System.Single | Normalized position where fade-in ends (-1 to disable) |
fadeOutStart |
System.Single | Normalized position where fade-out starts (-1 to disable) |
fadeInCurve |
UnityEngine.AnimationCurve | AnimationCurve for fade-in visualization (null to skip) |
fadeOutCurve |
UnityEngine.AnimationCurve | AnimationCurve for fade-out visualization (null to skip) |
Returns
System.Boolean — True if successful
NormalizedToSample(float, int)
Section titled “NormalizedToSample(float, int)”public int NormalizedToSample(float normalized, int totalSamples)Converts a normalized position (0-1) to a sample index.
Parameters
| Name | Type | Description |
|---|---|---|
normalized |
System.Single | |
totalSamples |
System.Int32 |
Returns
System.Int32 — No return description is available.
SampleToNormalized(int, int)
Section titled “SampleToNormalized(int, int)”public float SampleToNormalized(int sample, int totalSamples)Converts a sample index to a normalized position (0-1).
Parameters
| Name | Type | Description |
|---|---|---|
sample |
System.Int32 | |
totalSamples |
System.Int32 |
Returns
System.Single — No return description is available.
PixelToNormalized(int, int)
Section titled “PixelToNormalized(int, int)”public float PixelToNormalized(int pixelX, int width)Converts a pixel X coordinate to a normalized position.
Parameters
| Name | Type | Description |
|---|---|---|
pixelX |
System.Int32 | |
width |
System.Int32 |
Returns
System.Single — No return description is available.
NormalizedToPixel(float, int)
Section titled “NormalizedToPixel(float, int)”public int NormalizedToPixel(float normalized, int width)Converts a normalized position to a pixel X coordinate.
Parameters
| Name | Type | Description |
|---|---|---|
normalized |
System.Single | |
width |
System.Int32 |
Returns
System.Int32 — No return description is available.