Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jaz303/bitcrusher
Bitcrush effect for Web Audio API
https://github.com/jaz303/bitcrusher
Last synced: 3 days ago
JSON representation
Bitcrush effect for Web Audio API
- Host: GitHub
- URL: https://github.com/jaz303/bitcrusher
- Owner: jaz303
- License: isc
- Created: 2014-03-25T15:25:52.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-12T21:42:34.000Z (over 10 years ago)
- Last Synced: 2024-08-09T21:23:02.154Z (3 months ago)
- Language: JavaScript
- Size: 246 KB
- Stars: 35
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bitcrusher
Implementation of a bit-crush effect using the Web Audio API.
## Installation
Browserify is recommended; alternatively you can grab a UMD module from the `build` directory. If using `npm`:
$ npm install bitcrusher
## Usage
```javascript
var bitcrusher = require('bitcrusher');var audioContext = window.createAudioContext();
var bitcrushNode = bitcrush(audioContext, {
bitDepth: 6,
frequency: 0.5
});var mySource = // ... create audio source
mySource.connect(bitcrushNode);
bitcrushNode.connect(audioContext.destination);
```## API
#### `bitcrusher(audioContext, opts)`
Create a new bitcrusher in the Web Audio Context `audioContext` configured with the supplied options:
* `bufferSize`: defaults to 4096
* `channelCount`: defaults to 2
* `bitDepth`: output resolution, defaults to 8
* `frequency`: sample-and-hold ratio; used to reduce the perceived output frequency. Defaults to 1 (no change).Returns a `ScriptProcessorNode` configured with a bitcrush effect.
## Reference
If you're running OS X, open `graph.gcx` in `Grapher.app` to visualise the algorithm.
## TODO
`bitDepth` and `frequency` options would ideally instances of `AudioParam`. Unfortunately the Web Audio API does not yet allow standalone instances to be created.