Constructor
new BufferPlayer(audioContext, buffer)
Create an audio buffer player.
Parameters:
| Name | Type | Description |
|---|---|---|
audioContext |
Object | An AudioContext. |
buffer |
Object | The audio buffer to play. |
Methods
play(offsetTime, duration)
Play the buffer with the specified parameters.
Parameters:
| Name | Type | Description |
|---|---|---|
offsetTime |
number | The offset time within the buffer. |
duration |
number | The amount of time to play. |
reduceAudioData(channel, targetSize, offsetStartTime, offsetStopTime) → {Float32Array}
Reduce the amount of audio channel data to the specified target array size. The original channel audio data is broken into a number of segments
specified by the target array size. Then the maxmum absolute value in that segment is put into the target array.
Parameters:
| Name | Type | Description |
|---|---|---|
channel |
number | The BufferPlayer channel. |
targetSize |
number | The target size of the reduced data array. |
offsetStartTime |
number | The time offset to start reducing. |
offsetStopTime |
number | The time offset to stop reducing. |
Returns:
The reduced audio data array.
- Type
- Float32Array
sliceAudioData(channel, startTime, stopTime) → {Array}
Slice audio channel data in the specified time range and return it.
Parameters:
| Name | Type | Description |
|---|---|---|
channel |
number | The BufferPlayer channel. |
startTime |
number | The start time for the slice. |
stopTime |
number | The stop time for the slice. |
Returns:
The audio data in the specified time range.
- Type
- Array
stop()
Stop playing the buffer.