WAATableNode
Audio Node for more flexible sample playback.
AudioBufferSourceNode
is good for simple playback of a sound sample. But when you want to read a sound back and forth, at varying playrates, jump around, etc ... it just doesn't cut it.
WAATableNode
plays a sound sample and the playback position is directly controlled by another audio node :
var tableNode = contextpositionNode
This might seem complicated at first, but in fact it is very simple, and extremely flexible. For example, if you want the table node to loop the sound at playrate 1, you can just use a phasor that oscillates between 0 and the sample length, and whose period is the same as the sample duration :
var context = tableNode = context positionNode = context tableNodetable = aSound // can be an AudioBuffer or a Float32ArraytableNode // The buffer will just contain a ramp that will be looped, essentially resulting// in a phasor [0, aSound.length] controlling the playback position.positionBuffer = contextfor var i = 0; i < aSoundlength; i++ positionBufferi = i positionNodepositionNodebuffer = positionBufferpositionNodeloop = truepositionNodestart0
See the complete example here
For a more complex example, you can check this demo.