WebAudio
Extends:
Direct Subclass:
Indirect Subclass:
WebAudio backend
Constructor Summary
| Public Constructor | ||
| public |
constructor(params: WavesurferParams) Construct the backend |
|
Member Summary
| Public Members | ||
| public |
ac: * ac: Audio Context instance |
|
| public |
analyser: * analyser: provides audio analysis information |
|
| public |
audioContext: * audioContext: allows to process audio with WebAudio API |
|
| public |
Boolean indicating if the backend was destroyed. |
|
| public |
gainNode: * gainNode: allows to control audio volume |
|
| public |
scriptNode: * scriptNode: allows processing audio |
|
Method Summary
| Public Methods | ||
| public |
Create analyser node to perform audio analysis |
|
| public |
Create ScriptProcessorNode to process audio |
|
| public |
Create the gain node needed to control the playback volume. |
|
| public |
destroy() This is called when wavesurfer is destroyed |
|
| public |
Destroy all references with WebAudio, disconnecting audio nodes and closing Audio Context |
|
| public |
getAudioContext(): AudioContext Get the audio context used by this backend or create one |
|
| public |
Returns the current time in seconds relative to the audio-clip's duration. |
|
| public |
Used by |
|
| public |
getOfflineAudioContext(sampleRate: number): OfflineAudioContext Get the offline audio context used by this backend or create one |
|
| public |
Compute the max and min value of the waveform when broken into <length> subranges. |
|
| public |
Returns the current playback rate. |
|
| public |
Get the position from 0 to 1 |
|
| public |
Get the playback position in seconds |
|
| public |
Get the current volume |
|
| public |
init() Initialise the backend, called in |
|
| public |
Used by |
|
| public |
Loaded a decoded audio buffer |
|
| public |
pause() Pauses the loaded audio. |
|
| public |
Plays the loaded audio region. |
|
| public |
Used by |
|
| public |
Unpacked |
|
| public |
setFilters(filters: AudioNode[]) Insert custom Web Audio nodes into the graph |
|
| public |
Set the rendered length (different from the length of the audio) |
|
| public |
Set pre-decoded peaks |
|
| public |
setPlayEnd(end: number) Set a point in seconds for playback to stop at. |
version 3.3.0 |
| public |
setPlaybackRate(value: number) Set the audio source playback rate. |
|
| public |
Set the sink id for the media player |
|
| public |
Set the audio volume |
|
| public |
Does the browser support this backend |
|
Public Constructors
public constructor(params: WavesurferParams) source
Construct the backend
Params:
| Name | Type | Attribute | Description |
| params | WavesurferParams |
Wavesurfer parameters |
Public Members
Public Methods
public destroyWebAudio() source
Destroy all references with WebAudio, disconnecting audio nodes and closing Audio Context
public getAudioContext(): AudioContext source
Get the audio context used by this backend or create one
Return:
| AudioContext |
Existing audio context, or creates a new one |
public getCurrentTime(): number source
Returns the current time in seconds relative to the audio-clip's duration.
public getOfflineAudioContext(sampleRate: number): OfflineAudioContext source
Get the offline audio context used by this backend or create one
Params:
| Name | Type | Attribute | Description |
| sampleRate | number |
The sample rate to use |
public getPeaks(length: number, first: number, last: number): number[] | Number<Array[]> source
Compute the max and min value of the waveform when broken into <length> subranges.
public getPlaybackRate(): number source
Returns the current playback rate. (0=no playback, 1=normal playback)
public load(buffer: Object) source
Loaded a decoded audio buffer
Params:
| Name | Type | Attribute | Description |
| buffer | Object |
Decoded audio buffer to load |
public seekTo(start: number, end: number): {start: number, end: number} source
Used by wavesurfer.seekTo()
public setFilter(filters: ...AudioNode) source
Unpacked setFilters()
Params:
| Name | Type | Attribute | Description |
| filters | ...AudioNode |
One or more filters to set |
public setFilters(filters: AudioNode[]) source
Insert custom Web Audio nodes into the graph
Params:
| Name | Type | Attribute | Description |
| filters | AudioNode[] |
Packed filters array |
Example:
const lowpass = wavesurfer.backend.ac.createBiquadFilter();
wavesurfer.backend.setFilter(lowpass);
public setLength(length: number) source
Set the rendered length (different from the length of the audio)
Params:
| Name | Type | Attribute | Description |
| length | number |
The rendered length |
public setPlayEnd(end: number) version 3.3.0 source
Set a point in seconds for playback to stop at.
Params:
| Name | Type | Attribute | Description |
| end | number |
Position to end at |
public setPlaybackRate(value: number) source
Set the audio source playback rate.
Params:
| Name | Type | Attribute | Description |
| value | number |
The playback rate to use |
public setSinkId(deviceId: string): Promise source
Set the sink id for the media player
Params:
| Name | Type | Attribute | Description |
| deviceId | string |
String value representing audio device id. |