# audiobuffer-to-wav

> convert an AudioBuffer to .wav format

Latest version **1.0.0** (published 2015-12-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install audiobuffer-to-wav
pnpm add audiobuffer-to-wav
yarn add audiobuffer-to-wav
bun add audiobuffer-to-wav
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-12-14 |
| First published | 2015-12-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/audiobuffer-to-wav) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 158 |
| Author | Matt DesLauriers |
| Maintainers | mattdesl |
| Keywords | convert, AudioBuffer, to, wav, format, for, browser, webaudio, web audio, audio, buffer, conversion, formats, fmt, riff, wave, sound |

## Links

- npm: https://www.npmjs.com/package/audiobuffer-to-wav
- Repository: https://github.com/Jam3/audiobuffer-to-wav
- Issues: https://github.com/Jam3/audiobuffer-to-wav/issues
- npm.io page: https://npm.io/package/audiobuffer-to-wav

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-12-14

## README

# audiobuffer-to-wav

[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

Encodes the contents of an [AudioBuffer](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer) from the WebAudio API as WAVE. Supports 16-bit PCM and 32-bit float data.

The code for this has been adapted from the export feature of [Recorder.js](https://github.com/mattdiamond/Recorderjs).

PRs welcome.

## Install

```sh
npm install audiobuffer-to-wav --save
```

## Example

```js
var toWav = require('audiobuffer-to-wav')
var xhr = require('xhr')
var context = new AudioContext()

// request the MP3 as binary
xhr({
  uri: 'audio/track.mp3',
  responseType: 'arraybuffer'
}, function (err, body, resp) {
  if (err) throw err
  // decode the MP3 into an AudioBuffer
  audioContext.decodeAudioData(resp, function (buffer) {
    // encode AudioBuffer to WAV
    var wav = toWav(buffer)
    
    // do something with the WAV ArrayBuffer ...
  })
})
```

See [the demo](./demo/index.js) for an example of loading MP3, decoding it, and triggering a download of the encoded WAV file.

A more advanced example might be to write the file using Node and Electron or [hihat](https://www.npmjs.com/package/hihat), i.e. an easy way to convert MP3/OGG/etc to WAV.

## Usage

[![NPM](https://nodei.co/npm/audiobuffer-to-wav.png)](https://www.npmjs.com/package/audiobuffer-to-wav)

#### `arrayBuffer = encodeWAV(audioBuffer, [opt])`

Encodes the [AudioBuffer](https://developer.mozilla.org/en-US/docs/Web/API/AudioBuffer) instance as WAV, returning a new array buffer. Interleaves multi-channel data, if necessary.

By default, exports with 16-bit PCM (format: 1). You can specify `opt.float32` instead, which will write format 3 with 32-bit float data.

## License

MIT, see [LICENSE.md](http://github.com/Jam3/audiobuffer-to-wav/blob/master/LICENSE.md) for details.

---
_Source: https://npm.io/package/audiobuffer-to-wav · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
