https://github.com/lukehorvat/vibrato
Web Audio API vibrato effect.
https://github.com/lukehorvat/vibrato
audiocontext vibrato web-audio
Last synced: about 1 month ago
JSON representation
Web Audio API vibrato effect.
- Host: GitHub
- URL: https://github.com/lukehorvat/vibrato
- Owner: lukehorvat
- License: mit
- Created: 2017-10-05T12:23:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-07T12:20:36.000Z (over 8 years ago)
- Last Synced: 2025-01-28T12:40:15.321Z (over 1 year ago)
- Topics: audiocontext, vibrato, web-audio
- Language: HTML
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vibrato [](https://www.npmjs.com/package/vibrato)
[Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API) vibrato effect.
## Installation
Install the package with NPM:
```bash
$ npm install vibrato
```
## Usage
The package exposes a function that accepts an [AudioContext](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext) as the first argument, and an [AudioParam](https://developer.mozilla.org/en-US/docs/Web/API/AudioParam) as the second. Optionally, an object specifying `rate` and `depth` can also be provided as the third argument. When called, the function will apply a vibrato effect to the AudioParam.
Example:
```javascript
import vibrato from "vibrato";
let context = new (window.AudioContext || window.webkitAudioContext)();
let oscillator = context.createOscillator();
oscillator.connect(context.destination);
oscillator.start();
vibrato(context, oscillator.frequency, { rate: 4, depth: 16 });
```
Furthermore, as a convenient shorthand, you can pass in an [OscillatorNode](https://developer.mozilla.org/en-US/docs/Web/API/OscillatorNode) directly:
```javascript
vibrato(oscillator, { rate: 4, depth: 16 });
```