I'm thrilled to announce the successor to
purescript-wags. WAGS is short for "Web Audio Graphs as a Stream", and stream-based computation is at the heart of its design.
When I created
purescript-audio-behaviors, it suffered from three issues from the get-go.
- It didn't render audio fast enough, causing audible jank and laggy instruments.
- It required giving each audio unit a tag, which made the code suffer from the same problem as all stringly-typed APIs.
- 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
Here is some sound made with
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.
MemoizedStatemonad that is conceptually close to the
- simulated linear types using a proof system
- inductive types using typelevel Peanos to efficiently represent changing audio
- the use of typeclasses for overloaded audio unit constructors
- type-level lenses into audio graphs (ie creating audio, connecting audio, disconnecting audio, etc).
- indexed applicative functors
- indexed cofree comonads
- bitwise arithmetic in the type system
- type-level loops using rebasing
- Using events and behaviors for JIT scheduling
- the Well-Typed Klavier, which was the reason I started this whole thing.
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 🎹🎤🎼🔊.