DEV Community

Cover image for Announcing purescript-wags: a library for rendering web audio
Mike Solomon
Mike Solomon

Posted on

Announcing purescript-wags: a library for rendering web audio

I'm thrilled to announce the successor to purescript-audio-behaviors: purescript-wags. WAGS is short for "Web Audio Graphs as a Stream", and stream-based computation is at the heart of its design.

Why another library?

When I created purescript-audio-behaviors, it suffered from three issues from the get-go.

  1. It didn't render audio fast enough, causing audible jank and laggy instruments.
  2. It required giving each audio unit a tag, which made the code suffer from the same problem as all stringly-typed APIs.
  3. Complex feedback loops were impossible to achieve.

The second two problems were livable, but the first one proved to be really annoying. There were too many clicks, stutters, pops and lags. Responsive instruments were impossible to create, and I had to slow down the rendering engine in all but the most trivial works, which made attacks and releases less crisp.

The library's fundamental problem was that it needed to do multiple graph traversals, whereas any real rendering engine has a YOLO philosophy that avoids needless computations. Over the past month, I embarked on a new adventure: creating a second library from the ground-up, aka purescript-wags.

Show me the sound!

Here is some sound made with purescript-wags.

Name Code Sound
Hello world code sound
Atari speaks code sound
The Well-Typed Klavier code sound

How it works

Under the hood, purescript-wags uses a combination of Functional Reactive Programming, Type-Level Programming, Linear types and comonads to achieve ultra-fast web audio rendering.

Over the next few months, I'll do my best to write up articles on the points below, all of which contribute to the library in one way or another.

I hope you make some great web-art with purescript-wags! If you have any questions, please don't hesitate to ask on this page or on the GitHub repo 🎹🎤🎼🔊.

Top comments (0)