genish.js

one sample at a time, please.

genish.js is a library to help develop optimized audio callbacks employing per-sample processing techniques. This enables signal processing that is not possible using buffers, for example:

  • chaotic oscillators
  • fm feedback
  • physical modeling
  • audio-rate modulation of scheduling
  • stochastic scheduling with no lookahead required
  • intra-block graph modification

In our opinion per-sample processing is also easier to reason about than processing in blocks of hundreds of samples at a time. Process a sample in unit generator A, then feed it into unit generator B. And then feed the result back into unit generator A to influence the next sample if you want.

The trade-off is efficiency, which is especially important in a dynamic runtime environment like what JavaScript offers. Accordingly, genish takes the audio graphs you write and creates an optimized callback from them. The code generation step minimizes branches and traversing the scope / prototype chains as much as possible.

Per-sample processing is currently possible in the browser using the ScriptProcessor node found in the Web Audio API. While the ScriptProcessor node currently imposes performance penalties, in the (hopefully near) future many of these penalties will be removed when the Audio Worklet is introduced.

genish.js is inspired by the gen~ extension for Max/MSP.