Skip to content

Use & author libs/codes helpers

The libs/codes/ system lets you factor reusable JS helpers out of clips and load them globally into the coding Note Effect runtime. Helpers can be app-wide (shared across every project) or project-scoped (saved next to a project file).

TypePathScope
App libs/codes{appData}/libs/codes/All projects on this machine
Project libs/codeslibs/codes/ next to the project fileThis project only
Factory libsBundled with the app (read-only)All projects, all machines

The Project libs folder itself is not created until you press the Create button in the file browser.

In the file browser, each .js file has a checkbox on its left.

  • ON — added to this project’s loadedLibs. The file’s source is prepended to your user code when the coding Note Effect runs.
  • OFF — removed from loadedLibs (the file itself stays).

After turning a lib ON, any clip code can call its functions directly — no import is needed.

Use export function (or plain function declarations) and the helpers become callable from clip code.

libs/codes/myhelpers.js
export function houseKick(b, len = 0.25, vel = 100) {
noteOn(36, len, vel, b);
}
export function arpUp(rootPitch, lenBeats, step = 0.25) {
for (let b = 0; b < lenBeats; b += step) {
setNote({
pitch: rootPitch + ((b / step) % 8),
startBeat: b,
lengthBeats: step,
});
}
}

In a clip:

onBeat((b) => {
houseKick(b);
});

The runtime executes user code with new Function(...), which does not support ESM. The host stripModuleSyntax() removes export / import keywords before injecting the lib. So:

  • export function add() -> the function exists in the script’s global scope
  • import x from "..." -> stripped and effectively a no-op

You cannot import from URLs or other modules. Keep helpers self-contained, or use the host API.

  • Open a .js file by clicking it -> editor modal opens
  • Cmd/Ctrl + S to save
  • Esc to close (asks for confirmation if there are unsaved changes)
  • Factory libs are read-only

Saving a lib refreshes the file browser, but clips that are already open are not re-rendered automatically. The clip’s render dependencies are clip.code and loadedLibs, not the lib source.

To pick up the change:

  • Edit the clip’s Code by one character (re-render trigger), or
  • Toggle the lib OFF then ON in the file browser

This is documented further in Troubleshooting.

Lib sources are cached by path + mtime + size. The cache is invalidated automatically when a file changes on disk.