SQLar

SQLar

Overview

SQLar is an experimental archive format built inside of SQLite. Monolith has bindings for SQLar that allow it to be used to read/store samples.

The SQLar CLI

A version of the sqlar CLI is embedded with the monolith distribution, and can be run with monolith sqlar. Alternatively, one can go into the sqlar directory and install it separately.

Adding a WAV sample foo.wav to the sqlar archive foo.sqlar is a matter of running:

sqlar foo.sqlar foo.wav

Loading a wav sample

The previous sample can then be loaded using the scheme function sqlar-loadwav.

The scheme code below loads foo.wav from archive foo.dband loads it into an ftable, then stores the ftable into register 0, where it can then be used in ugens like oscf, tabread, or osc (assuming a power-of-two size).

(regset (sqlar-load "foo.db" "foo.wav") (param 0))

This is equivalent to the following runt code:

"foo.db" "foo.wav sqlar_load 0 regset

Because runt is stupid with strings, be sure to evalulate both strings on the same line. Or, just use the scheme function, because it handles this for you! (Note: this will be reworked very soon).

Loading WAV files from a Weewiki Crate

A relatively new feature in weewiki is the crate, which provides zettelkasten-like abstractions on top of the SQLar to allow for annotations and curation. Because the format is all SQLite, crates are designed to exist all in one file.

Below is a small runt example that shows how to use cratewav, a utility that loads a WAV file from a Crate (via its crate UUID) into a ftable. The UUID 30578% can partially supplied using SQLite's LIKE operator notation %.

<<cratewav_test.rnt>>=
graforge nodes

"test.db" sqlite_open
"30578%" cratewav 0 regset

1 dmetro 1 0 regget tsmp

"test.wav" wavout bdrop

10 sr * _compute rep

The woven program for cratewave can be found at 10. cratewav.

Notable Portions in Monolith Code

sqlar_util.c is where most of the monolith-specific SQLar logic happens.

There's also sqlar_loadwav.c which specifically is used for loading WAV files from a SQLar file (via the drwav library included in soundpipe.