# wav-encoder

> promise-based wav encoder

Latest version **1.3.0** (published 2017-08-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install wav-encoder
pnpm add wav-encoder
yarn add wav-encoder
bun add wav-encoder
```

## 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.3.0 |
| Published | 2017-08-11 |
| First published | 2015-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/wav-encoder) |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 41 |
| Author | Nao Yonamine |
| Maintainers | mohayonao |
| Keywords | encode, universal, wav |

## Links

- npm: https://www.npmjs.com/package/wav-encoder
- Repository: https://github.com/mohayonao/wav-encoder
- Homepage: https://github.com/mohayonao/wav-encoder/
- Issues: https://github.com/mohayonao/wav-encoder/issues
- npm.io page: https://npm.io/package/wav-encoder

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.3.0 (latest) — 2017-08-11
- 1.2.0 — 2017-08-08
- 1.1.0 — 2016-04-05
- 1.0.0 — 2015-12-21
- 0.3.0 — 2015-06-10
- 0.2.2 — 2015-03-19
- 0.2.1 — 2015-03-19
- 0.2.0 — 2015-03-18
- 0.1.1 — 2015-03-17
- 0.1.0 — 2015-03-17
- 0.0.1 — 2015-03-16

## README

# wav-encoder
[![Build Status](https://img.shields.io/travis/mohayonao/wav-encoder.svg?style=flat-square)](https://travis-ci.org/mohayonao/wav-encoder)
[![NPM Version](https://img.shields.io/npm/v/wav-encoder.svg?style=flat-square)](https://www.npmjs.org/package/wav-encoder)
[![License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](https://mohayonao.mit-license.org/)

> promise-based wav encoder

## Installation

```
$ npm install wav-encoder
```

## API

- `encode(audioData: AudioData, [opts: object]): Promise<ArrayBuffer>`
  - `audioData` should contain two fields `sampleRate` and `channelData`.
  - `opts` is an optional parameter which used to design the output wav format.
    - `opts.bitDepth` the number of bits of information in each sample
    - `opts.float` encode to float values
    - `opts.symmetric` encode to symmetrical values (see [#10](https://github.com/mohayonao/wav-encoder/issues/10))
    - The default format is `{ float: false, bitDepth: 16 }`
- `encode.sync(audioData: AudioData, [opts: object]): ArrayBuffer`
  - synchronous version

```js
interface AudioData {
  sampleRate: number;
  channelData: Float32Array[];
}
```

## Usage

```js
const fs = require("fs");
const WavEncoder = require("wav-encoder");

const whiteNoise1sec = {
  sampleRate: 44100,
  channelData: [
    new Float32Array(44100).map(() => Math.random() - 0.5),
    new Float32Array(44100).map(() => Math.random() - 0.5)
  ]
};

WavEncoder.encode(whiteNoise1sec).then((buffer) => {
  fs.writeFileSync("noise.wav", new Buffer(buffer));
});
```

## License
MIT

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