pluck-string-node
v1.1.0
Published
Pluck String AudioNode for Web Audio API
Downloads
1
Maintainers
Readme
PluckStringNode
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
readonlydetune: AudioParam
readonlycolor: 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.
- create OscillatorNode
- OscillatorNode connect to WaveShaperNode which has random curve
- WaveShaperNode connect to lowpass BiquadFilterNode
- when
start()
, setcolor
to the BiquadFilterNode frequency - and the cutoff frequency continuous change to very low frequency during
timeConstant
.
AudioGraph
License
MIT