npm

Does your artifact manager get in the way? Join us on Oct. 8 at 10am PT, to discuss how npm can help.Sign up »

pluck-string-node

1.1.0 • Public • Published

PluckStringNode

Build Status NPM Version License

Pluck String AudioNode for Web Audio API

Installation

npm install pluck-string-node

downloads:

API

PluckStringNode

  • constructor(audioContext, opts)
    • audioContext: BaseAudioContext
    • opts.color: number tone color (aka cutoff frequency)
    • opts.timeConstant: number time constant until harmonics converges

Instance Attributes

  • frequency: AudioParam readonly
  • detune: AudioParam readonly
  • color: number
  • timeConstant: number

Instance Methods

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

Quick Example

var pluck = new PluckStringNode(audioContext);
 
pluck.color = 1000;
pluck.timeConstant = 10;
pluck.frequency.value = 880;
pluck.start(audioContext.currentTime);
pluck.stop(audioContext.currentTime + 4);

Demo

https://mohayonao.github.io/pluck-string-node/

Algorithm

This node's algorithm is inspired from Karplus–Strong string synthesis.

  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 timeConstant.

AudioGraph

pluck-string-node

License

MIT

install

npm i pluck-string-node

Downloadsweekly downloads

1

version

1.1.0

license

MIT

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability