createBuffer abstract method
- int numberOfChannels,
- int length,
- TauSampleRate sampleRate
The createBuffer()
method of the BaseAudioContext
is used to create a new, empty AudioBuffer object, which
can then be populated by data, and played via an AudioBufferSourceNode.
For more details about audio buffers, check out the AudioBuffer reference page.
Note:
createBuffer()
used to be able to take compressed data and give back decoded samples, but this ability was removed from the specification, because all the decoding was done on the main thread, socreateBuffer()
was blocking other code execution. The asynchronous methoddecodeAudioData()
does the same thing — takes compressed audio, such as an MP3 file, and directly gives you back an AudioBuffer that you can then play via an AudioBufferSourceNode. For simple use cases like playing an MP3,decodeAudioData()
is what you should be using.
Implementation
AudioBuffer createBuffer(
int numberOfChannels,
int length,
TauSampleRate sampleRate,
);