1.0.0 • Published 8 years ago

pluck-node v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

PluckNode

Build Status NPM Version License

PluckNode for Web Audio API

Installation

npm install pluck-node

downloads:

API

PluckNode

  • constructor(audioContext, [color, decayTime])
    • color: number cutoff frequency (aka tone color)
    • decayTime: number time until harmonics converges

Class Methods

  • install(): void
    • install createPluck() method to AudioContext.prototype force

Instance Attributes

  • frequency: AudioParam readonly
  • detune: AudioParam readonly

Instance Methods

  • start(when: number): void
  • stop(when: number): void

Usage

var pluck = new PluckNode(audioContext, 1000, 10);

pluck.frequency.value = 880;
pluck.start(audioContext.currentTime);
pluck.stop(audioContext.currentTime + 4);

Install to AudioContext

At first, call install() method.

require("PluckNode").install();
<script src="/path/to/pluck-node.js"></script>
<script>PluckNode.install();</script>

Then, you can use createPluck(color, decayTime) method at AudioContext.

Demo

http://mohayonao.github.io/pluck-node/

Algorithm

  1. create OscillatorNode
  2. OscillatorNode connect to WaveShaperNode which has random curve
  3. WaveShaperNode connect to lowpass BiquadFilterNode
  4. when start(), set color to the BiquadFilterNode frequency
  5. and the cutoff frequency continuous change to very low frequency during decayTime.

AudioGraph

pluck-node

License

MIT