toAudioBuffer = function toAudioBuffer(data) {

        // Calculate total number of samples
        var samples = data.length / format.channels;

        // Determine exactly when packet CAN play
        var packetTime = context.currentTime;
        if (nextPacketTime < packetTime)
            nextPacketTime = packetTime;

        // Get audio buffer for specified format
        var audioBuffer = context.createBuffer(format.channels, samples, format.rate);

        // Convert each channel
        for (var channel = 0; channel < format.channels; channel++) {

            var audioData = audioBuffer.getChannelData(channel);

            // Fill audio buffer with data for channel
            var offset = channel;
            for (var i = 0; i < samples; i++) {
                audioData[i] = data[offset] / maxSampleValue;
                offset += format.channels;
            }

        }

        return audioBuffer;

    }
Converts the given audio packet into an AudioBuffer, ready for playback
by the Web Audio API. Unlike the raw audio packets received by this
audio player, AudioBuffers require floating point samples and are split
into isolated planes of channel-specific data.

@private
@param {SampleArray} data
    The raw audio packet that should be converted into a Web Audio API
    AudioBuffer.

@returns {AudioBuffer}
    A new Web Audio API AudioBuffer containing the provided audio data,
    converted to the format used by the Web Audio API.