stringpluck.js
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

Live plugin demo

Adjust parameters, then click a note to hear the result.

Trigger notes

Standard guitar tuning

Keyboard shortcuts: 1–6 to pluck; Space to strum. Audio starts after the first click or key press.

Parameters

Applied to new notes
Quick start · current demo settings

Use in your project

  1. 1. Include the fileAdd <script src="string-pluck.js"></script> before your app script.
  2. 2. Create an instanceCall new StringPluck(options) once and reuse it.
  3. 3. Play after interactionCall await stringPluck.resume() in a click or key handler, then stringPluck.pluck(frequency).
  4. 4. Shape later notesUse stringPluck.setParams({...}) to update the sound.

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.