src/AudioPlayer.js
function joinAudioPackets(packets) {

        // Do not bother joining if one or fewer packets are in the queue
        if (packets.length <= 1)
            return packets[0];

        // Determine total sample length of the entire queue
        var totalLength = 0;
        packets.forEach(function addPacketLengths(packet) {
            totalLength += packet.length;
        });

        // Append each packet within queue
        var offset = 0;
        var joined = new SampleArray(totalLength);
        packets.forEach(function appendPacket(packet) {
            joined.set(packet, offset);
            offset += packet.length;
        });

        return joined;

    }
function joinAudioPackets(packets) {

        // Do not bother joining if one or fewer packets are in the queue
        if (packets.length <= 1)
            return packets[0];

        // Determine total sample length of the entire queue
        var totalLength = 0;
        packets.forEach(function addPacketLengths(packet) {
            totalLength += packet.length;
        });

        // Append each packet within queue
        var offset = 0;
        var joined = new SampleArray(totalLength);
        packets.forEach(function appendPacket(packet) {
            joined.set(packet, offset);
            offset += packet.length;
        });

        return joined;

    }
function joinAudioPackets ( packets ) { // Do not bother joining if one or fewer packets are in the queue if ( packets . length <= 1 ) return packets [ 0 ] ; // Determine total sample length of the entire queue var totalLength = 0 ; packets . forEach ( function addPacketLengths ( packet ) { totalLength += packet . length ; } ) ; // Append each packet within queue var offset = 0 ; var joined = new SampleArray ( totalLength ) ; packets . forEach ( function appendPacket ( packet ) { joined . set ( packet , offset ) ; offset += packet . length ; } ) ; return joined ; }
Given an array of audio packets, returns a single audio packet
containing the concatenation of those packets.

@private
@param {SampleArray[]} packets
The array of audio packets to concatenate.

@returns {SampleArray}
A single audio packet containing the concatenation of all given
audio packets. If no packets are provided, this will be undefined.
Given an array of audio packets returns a single audio packet containing the concatenation of those packets .