# wae-cli

> web-audio-engine command line

Latest version **0.6.0** (published 2016-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install wae-cli
pnpm add wae-cli
yarn add wae-cli
bun add wae-cli
```

Provides the command `wae`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2016-04-30 |
| First published | 2016-04-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Nao Yonamine |
| Maintainers | mohayonao |
| Keywords | cli, web audio api |

## Links

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

## Dependencies (4)

- [speaker](https://npm.io/package/speaker.md) ^0.3.0
- [optionator](https://npm.io/package/optionator.md) ^0.8.1
- [tickable-timer](https://npm.io/package/tickable-timer.md) ^1.0.0
- [web-audio-engine](https://npm.io/package/web-audio-engine.md) *

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 0.6.0 (latest) — 2016-04-30
- 0.5.0 — 2016-04-28
- 0.4.1 — 2016-04-28
- 0.4.0 — 2016-04-28
- 0.3.1 — 2016-04-28
- 0.3.0 — 2016-04-27
- 0.2.0 — 2016-04-27
- 0.1.0 — 2016-04-26

## README

# wae-cli
[![NPM Version](http://img.shields.io/npm/v/wae-cli.svg?style=flat-square)](https://www.npmjs.org/package/wae-cli)
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](http://mohayonao.mit-license.org/)

> [`web-audio-engine`](https://github.com/mohayonao/web-audio-engine) command line

## Installation

```sh
$ npm install -g wae-cli
```

## Usage

You can write a code using the Web Audio API via `audioContext`.

```js
// coin.js
const osc = audioContext.createOscillator();
const amp = audioContext.createGain();

osc.type = "square";
osc.frequency.setValueAtTime(987.7666, 0);
osc.frequency.setValueAtTime(1318.5102, 0.075);
osc.start(0);
osc.stop(2);
osc.connect(amp);
osc.onended = () => {
  process.exit();
};

amp.gain.setValueAtTime(0.25, 0);
amp.gain.setValueAtTime(0.25, 0.075);
amp.gain.linearRampToValueAtTime(0, 2);
amp.connect(audioContext.destination);
```

simplest playback (using [`node-speaker`](https://github.com/TooTallNate/node-speaker))

```sh
$ wae coin
```

playback using [ALSA](http://alsa.opensrc.org/Aplay) `aplay` via `stdout`

```sh
$ wae coin -o stdout | aplay -f cd
```

playback using [SoX](http://sox.sourceforge.net/) `play` via `stdout`

```sh
$ wae coin -o stdout | play -t s16 -r 44100 -c 2 -
```

render to an audio file

```sh
$ wae coin -o coin.wav
```

other options

```
$ wae --help
wae [option] script-name [args]

  -h, --help             display help
  -v, --version          display version
  -t, --type String      file type of audio - default: s16
  -r, --rate Number      samplerate of audio - default: 44100
  -c, --channels Number  number of channels of audio: e.g. 2 = stereo - default: 2
  -d, --duration Number  number of duration for rendering
  -o, --out String       write output to <file> - default: speaker
  -V, --verbose          run in verbose mode - default: false

AUDIO FILE FORMAT: s16 s32 u8 raw cd
```

#### provide arguments
You can provide arguments from command line using node module style function. The arguments are parsed as JSON.

```js
// beep.js
module.exports = (audioContext, frequency, duration) => {
  const osc = audioContext.createOscillator();
  const amp = audioContext.createGain();

  osc.frequency.value = frequency;
  osc.start(0);
  osc.stop(duration);
  osc.connect(amp);

  amp.gain.setValueAtTime(0.5, 0);
  amp.gain.linearRampToValueAtTime(0, duration);
  amp.connect(audioContext.destination);
};
```

```sh
$ wae beep -- 1760 0.5
```

#### asynchronous code
You can run asynchronous code using `Promise`.

```js
const fs = require("fs");

module.exports = (audioContext) => {
  const buffer = fs.readFileSync("coin.wav");

  return audioContext.decodeAudioData(buffer).then((audioBuffer) => {
    const bufSrc = audioContext.createBufferSource();

    bufSrc.buffer = audioBuffer;
    bufSrc.start(0);

    bufSrc.connect(audioContext.destination);
  });
};
```

## License
MIT

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