title: Compress Audio Buffer size in Javascript
body: <p>My main goal is to compress an audio file to reduce its size with JavaScript. But the tricky part are all the restrictions and requirements I should complain to for my use case:</p>
  <ul>
  <li>Can I compress an audio file with the Web Audio API (or libraries based on it)?</li>
  <li>Ideally my code should run in the browser as well as NodeJS. For Node, where I am already using the Web Audio API I rely on a library - <a href="https://www.npmjs.com/package/web-audio-api" rel="nofollow noreferrer">https://www.npmjs.com/package/web-audio-api</a> for the support; So ideally I should be able to easily adapt the solution you propose for browser JS in Node as well.</li>
  <li>For Node I wouldn't want to use ffmpeg or any derivatives, since they rely on native binaries to run and that complicates the runtime when I try to deploy to Google Cloud functions and Azure Functions.</li>
  <li>Currently I have the audio content as an <a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer" rel="nofollow noreferrer">AudioBuffer</a>, so ideally the solution should be able to handle such data structures and shouldn't require filesystem interaction.</li>
  </ul>
  <p>In my opinion a library or an algorithm for data size reduction based on the Web Audio API AudioBuffer would be the best solution because even if it is not compatible with the NodeJS library for audio, hopefully I will be able to patch it so it works in my use case.</p>