0.18.4 • Published 12 months ago

wasgen v0.18.4

Weekly downloads
7
License
ISC
Repository
github
Last release
12 months ago

wasgen


Declarative low-level Web Audio Sound Generator.

You pass in a static object, which defines an arbitrarily complex audio graph and its parameters. This library will then construct all the nodes, connect everything, apply the necessary parameters and envelopes, and clean up afterwards.

Live demo ← open that and hit keys to play sounds.

NOTE!
Are you reasonably familiar with terms like "FM synthesis" and "ADSR envelope"? If not, you may find wafxr more useful than this library.

Usage:

Install as a dependency:

npm install --save wasgen

Instantiate and invoke:

var Generator = require('wasgen')

var ctx = new AudioContext()
var gen = new Generator(ctx, ctx.destination) // both args optional

var program = { type:'sine' }   // see below
var freq = 440                  // in Hz
var velocity = 1                // 0..1

// fixed-duration sounds:
var startTime = gen.now() + 0.1
var releaseTime = startTime + 1
gen.play(program, freq, velocity, startTime, releaseTime)

// dynamic sounds:
var noteID = gen.play(program, freq, velocity, startTime)
setInterval(() => {
    gen.release(noteID)   // sound's release envelope starts when this is called
}, 1000)

And so on. See source for other APIs

Program Format

Sound programs for wasgen use an ad-hoc format that's easy to read but hard to describe. You may find it easiest to open the demo page and browse the examples to get the general idea.

For the full details:

Program format spec


Recent updates

  • 0.18.0 Fixes bitcrusher and adds tanh distortion
  • 0.17.0 Supports playing into OfflineAudioContext
  • 0.16.0 simplifies program format, and many internals
  • 0.12.0 adds bit-crushing, bug fixes
  • 0.10.0
    • adds waveshaper distortion effects
    • rewrites most documentation
    • renamed from soundgen

By

Made with 🍺 by Andy Hall.

License is ISC.

Inspired by (and demo preset programs converted from) TinySynth

0.18.4

12 months ago

0.18.3

1 year ago

0.18.2

2 years ago

0.18.0

3 years ago

0.17.3

3 years ago

0.17.4

3 years ago

0.17.2

4 years ago

0.17.1

4 years ago

0.17.0

4 years ago

0.16.0

4 years ago

0.14.0

4 years ago

0.15.0

4 years ago

0.13.0

4 years ago

0.12.0

4 years ago

0.11.0

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago