JSPM

  • Created
  • Published
  • Downloads 54
  • Score
    100M100P100Q57299F
  • License MIT

An light-weight, garbage-collection-free, and easy-to-use audio engine for browser-based music apps.

Package Exports

  • glicol
  • glicol/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (glicol) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

What's this?

This is a light-weight, garbage-collection free, memory-safe and easy-to-use audio library for browsers. It's written in Rust and ported to JS via WebAssembly and runs in AudioWorklet. The communication is realised with SharedArrayBuffer.

Note that you need to have cross-origin isolation enabled on the web server (both the dev server and the one you deploy your web app) to use this package. For vite dev server, you can use my plugin here. For deployment on Netlify or Firebase, check their docs for editing the header files. If you use a customised server, you have to figure it out yourself.

Usage

This is a proof of concept and the API may change. But after you npm i glicol, you can just write:

import Glicol from "glicol"
const glicol = new Glicol()

Then you run your main audio graph logic:

glicol.run(`o: saw 50 >> lpf 300.0 1.0`)

You can call the run again if you want to change some parameters. There won't be an update to the whole graph. Instead, the Glicol Rust engine will be smart enough to tell the difference and only update where is modified.

glicol.run(`o: saw 50 >> lpf 300.0 1.0`)

Another style is to send message to the engine:

// track "o", node_index 0, param 0, set to 110
glicol.send_msg(`o, 0, 0, 110`);

You can use it with GUI, see this example:

https://glicol-npm.netlify.app

Multiple message in one String is also possible.

glicol.send_msg(`o, 0, 0, 110; o, 1, 0, 500; o, 1, 1, 0.8`);

Feedback

There are many todos for this package. Please let me know your thoughts and suggestions here:

https://github.com/chaosprint/glicol

Issues or Discussion are both fine.

Dev note (not for users)

pnpm link --dir /usr/local/lib/ glicol