# pull-audio-generator

> Generate audio as a pull-stream source

Latest version **0.1.0** (published 2017-05-14) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install pull-audio-generator
pnpm add pull-audio-generator
yarn add pull-audio-generator
bun add pull-audio-generator
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2017-05-14 |
| First published | 2017-05-14 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jamen Marz |
| Maintainers | jamen |
| Keywords | audiojs, audio, pull-stream, pull-audio, generate |

## Links

- npm: https://www.npmjs.com/package/pull-audio-generator
- Repository: https://github.com/audiojs/pull-audio-generator
- Homepage: https://github.com/audiojs/pull-audio-generator#readme
- Issues: https://github.com/audiojs/pull-audio-generator/issues
- npm.io page: https://npm.io/package/pull-audio-generator

## Dependencies (1)

- [audio-generator](https://npm.io/package/audio-generator.md) ^2.1.2

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2017-05-14

## README

# pull-audio-generator

> Generate audio as a pull-stream source

Creates [`AudioBuffer`](https://github.com/audiojs/audio-buffer)s using a function that returns samples between `-1..1`.  Also takes options to configure the stream and generated audio.

```js
pull(
  generator(Math.random, {
    duration: Infinity,
    bitDepth: 8,
    // ...
  }),
  drain(buf => {
    // got chunk
  })
)
```

## Install

```sh
npm install --save pull-audio-generator
```

```sh
yarn add pull-audio-generator
```

## Usage

### `generator(fn, options?)`

A [pull-stream source](https://github.com/pull-stream/pull-stream) that produces `AudioBuffer`s from `fn` and `options`.  All options are inherited from [`audio-generator`'s options](https://github.com/audiojs/audio-generator).

The `fn` takes `fn(time)` and returns `-1..1` for all channels or `[-1..1, -1..1, ...]` for each channel.

```js
pull(
  generate(time => {
    return [
      // Channel 1:
      Math.sin(Math.PI * 2 * time * 300),
      // Channel 2:
      Math.random()
    ]
  }),
  drain(buf => {
    // got chunk
  })
)
```

## Also see

 - [`audiojs`](https://github.com/audiojs) for all the audio components
 - [`pull-stream`](https://github.com/pull-stream/pull-stream) for minimal streams
 - [`audio-generator`](https://github.com/audiojs/audio-generator) for pure function of this module

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