Audio buffer sources
Joshua D. Reiss · Focal Press eBooks · 2022
This chapter examines how to work with audio buffers: creating them, loading audio into them, using them in source nodes, and changing the playback state of the node. Sound samples, or audio assets, are represented in the Web Audio as an array of floats in AudioBuffers . These buffers may be created by copying an array of data, setting each value in the buffer directly, or loading data from an audio file. The AudioBuffer represents an audio asset that resides in memory. They store multiple audio channels, each channel represented as an array of floating point linear PCM values with a nominal range of [-1,1]. Playback of an audio buffer can get complicated quite quickly, since these parameters all interact to determine what is played when. Loop-related properties may be varied during playback of the buffer. Internally, the buffer may be resampled at any time to reduce the computation or improve the quality of the output.