Skip to content

AlgoCompSynth/CLAMS

Repository files navigation

Command Line Algorithmic Music System (CLAMS)

M. Edward (Ed) Borasky

“I’ve never seen a happy clam. In fact, most of them were really steamed.” ~ M. Edward (Ed) Borasky

Overview

CLAMS is a text-based interactive environment for composing and performing music and visuals on a Pimoroni PicoVision. It can be made to work on other boards using the RP2040 microcontroller, but you will need additional hardware.

How does it work?

CLAMS is a domain-specific language built on a Forth compiler / interpreter. The user connects to the board via a serial connection and enters CLAMS / Forth code interactively.

Why Forth?

“Premature optimization may be the root of all evil, but it is damned fun!” ~ M. Edward (Ed) Borasky

  1. Forth (Brodie 2022) is an extensible interactive operating system. It supports editing, assembling, compiling, debugging and running real-time tasks from a terminal.
  2. Forth is efficient. A well-designed Forth will usually run a task at no worse than half the speed of a hand-optimized assembly version. CLAMS will have several optimizations built in for the ultimate speed.
  3. Forth is lean. There are very few concepts to learn, there is minimal run-time overhead in RAM, and the whole package takes up much less flash space than MicroPython or CircuitPython.

What about Forth standard (Forth 200x Committee 2012) compatibility?

Not really. CLAMS is an extended subset of the standard. It won’t contain all of the standard’s core word set, and it will contain some extensions to support real-time audio and the RP2040 hardware.

The RP2040 is both limited and complex. It uses the ARM Cortex M0+ instruction set, which doesn’t even have a 32-bit multiply that produces a 64-bit product. Division is handled by a co-processor. There are also co-processors for programmable I/O and interpolation / multiply-accumulate operations.

That said, if a word in CLAMS does exist in one of the standard word sets, it should function the way it does in the standard. The search order word set will be implemented, and all of the specialized co-processor operations will be in specialized word sets.

What about portability?

Again, not really. There are a number of other micro-controller music boards, most notably the Electro-Smith Daisy and the Rebel Technology OWL platforms. But they have their own SDKs, so there’s not much need to port CLAMS to them. There are also a number of audio projects that use the Teensy® USB Development Board, which has a comprehensive audio library. Also, the Daisy, OWL and Teensy processors are all more powerful than the RP2040.

By contrast, there’s not much for the Raspberry Pi Pico / RP2040. There are some simple demos, a few do-it-yourself hardware offerings, and there’s the Allen Synthesis EuroPi, a Eurorack module with an open source MicroPython software platform. CLAMS will be a different approach.

The overall concept is an interactive language for making music on Raspberry Pi Pico / RP2040. I’m aiming for ChucK (Salazar et al. 2014) semantics with Forth syntax - a single text-based language to implement both the definitions of synthesized instruments and the sequences of sounds they make, intended for live coding / algorave performances.

References

Brodie, Leo. 2022. “Starting Forth.” FORTH, Inc. https://www.forth.com/starting-forth/0-starting-forth/.

Forth 200x Committee. 2012. “Forth 2012 Standard.” Forth 200x Committee. http://www.forth200x.org/documents/forth-2012.pdf.

Salazar, S., A. Kapur, G. Wang, and P. Cook. 2014. Programming for Musicians and Digital Artists: Creating Music with ChucK. Manning.