Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jamen/pull-audio-generator
https://github.com/jamen/pull-audio-generator
Last synced: 17 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jamen/pull-audio-generator
- Owner: jamen
- License: mit
- Created: 2017-05-14T23:09:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-14T23:13:07.000Z (over 7 years ago)
- Last Synced: 2024-10-25T19:36:59.584Z (19 days ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
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