Constructor

new(?version:Int, channels:Int, sampleRate:Int, samplesPerPoint:Int, bits:Int, length:Int, data:Array<Int>)

Variables

@:value(16)read onlybits:Int = 16

Number of bits to use for each sample value. Valid values are 8 and 16.

@:value(1)read onlychannels:Int = 1

The number of channels in the waveform.

@:value([])read onlydata:Array<Int> = []

Array of Int16 values representing the waveform. TODO: Use an openfl.Vector for performance.

@:value(0)read onlylength:Int = 0

The length of the data array, in points.

@:value(44100)@:alias("sample_rate")read onlysampleRate:Int = 44100

@:value(256)@:alias("samples_per_pixel")read onlysamplesPerPoint:Int = 256

Number of input audio samples per output waveform data point. At base zoom level this is number of samples per pixel. Lower values can more accurately represent the waveform when zoomed in, but take more data.

@:value(-1)read onlyversion:Int = -1

The version of the waveform data format.

Methods

@:value({ newData : null })clone(?newData:Array<Int>):WaveformData

Create a new WaveformData whose parameters match the current object.

get(index:Int):Int

indexToPercent(index:Int):Float

Given a waveform data point index, return the percentage progress through the waveform.

indexToSeconds(index:Int):Float

Given a waveform data point index, return the time in seconds.

lenSamples():Int

Returns:

The length of the waveform in samples.

lenSeconds():Float

Returns:

The length of the waveform in seconds.

maxSampleValue():Int

Maximum possible value for a waveform data point. The minimum possible value is (-1 * maxSampleValue)

merge(that:WaveformData):WaveformData

Create a new WaveformData whose data represents the two waveforms overlayed.

percentToIndex(percent:Float):Int

Given the percentage progress through the waveform, return the waveform data point index.

inlinepointsPerSecond():Float

The number of data points this waveform data provides per second of audio.

resample(newSamplesPerPoint:Int):WaveformData

Resample the waveform data to create a new WaveformData object matching the desired samplesPerPoint value. This is useful for zooming in/out of the waveform in a performant manner.

Parameters:

newSamplesPerPoint

The new value for samplesPerPoint.

secondsToIndex(seconds:Float):Int

Given the time in seconds, return the waveform data point index.

set(index:Int, value:Int):Void