Merge buffer - Node.js Data Type

Node.js examples for Data Type:Float32Array

Description

Merge buffer

Demo Code


'use strict';/*from   ww w . jav  a  2s  .  c  om*/

/**
 * @credit https://github.com/mattdiamond/Recorderjs
 */
function mergeBuffers(channelBuffer, recordingLength){
  const result = new Float32Array(recordingLength);
  const length = channelBuffer.length;
  let offset = 0;

  for (let i = 0; i < length; i++){
    let buffer = channelBuffer[i];

    result.set(buffer, offset);
    offset += buffer.length;
  }

  return result;
}

module.exports = mergeBuffers;

Related Tutorials