JavaScript plugin · Web Audio API
Plucked-string synthesis for the browser.
String Pluck JS is a small, dependency-free JavaScript plugin that creates plucked-string tones with a Karplus–Strong delay loop. Try the sound, tune the parameters, then copy the starter code into your project.
Zero dependenciesPlain JavaScriptSix sound parametersPolyphonic playback
01 / Interactive example
Live plugin demo
Adjust parameters, then click a note to hear the result.
Trigger notes
Standard guitar tuningKeyboard shortcuts: 1–6 to pluck; Space to strum. Audio starts after the first click or key press.
Parameters
Applied to new notesQuick start · current demo settings
Use in your project
- 1. Include the fileAdd
<script src="string-pluck.js"></script>before your app script. - 2. Create an instanceCall
new StringPluck(options)once and reuse it. - 3. Play after interactionCall
await stringPluck.resume()in a click or key handler, thenstringPluck.pluck(frequency). - 4. Shape later notesUse
stringPluck.setParams({...})to update the sound.
02 / Reference
Small API, expressive sound.
See README.md for option ranges and full examples.
pluck(hz, velocity?, overrides?)Play a note between 40 and 2000 Hz. Optionally set velocity and per-note parameters.
setParams(options)Update attack, decay, brightness, damping, pick position, or volume for future notes.
resume() / stopAll()Unlock browser audio on interaction, or stop all currently playing voices.
dispose()Release the instrument. Closes its AudioContext if the plugin created it.