audiobuffer-to-aiff
Encodes the contents of an AudioBuffer from the WebAudio API as AIFF. Only supports 16-bit PCM data.
Install
npm install audiobuffer-to-aiff --save
Examples
Node.js example
With the Node Web Audio API library
npm install web-audio-api
Opens the test.wav file located in the ./demo directory, then converts it to AIFF and saves it as audio.aif in the same directory.
const audioBufferToAiff = ;const AudioContext = AudioContext;const fs = ; let audioContext = ; fs;
Client side JavaScript example
This example shows how to load an audio file (./demo/test.wav) with a GET request using XMLHttpRequest, then convert it to AIFF and download it.
index.html
AudioBuffer to AIFF
index.js
var audioContext = new windowAudioContext || windowwebkitAudioContext var xhr = ;xhr;xhrresponseType = "arraybuffer"; xhr { var arrayBuffer = xhrresponse; if arrayBuffer var anchor = document; documentbody; anchorstyle = 'display: none'; audioContext }; xhr;
Usage
arrayBuffer = audioBufferToAiff(audioBuffer)
Encodes the AudioBuffer instance as 16-bit PCM AIFF, returning a new array buffer. Interleaves multi-channel data, if necessary.
License
MIT, see LICENSE.md