cl-useq – A Common Lisp Library for working with uSEQ

Had a few moments this weekend to put together a library to connect to uSEQ. It uses a standard common-lisp implementation (tested with SBCL) and cl-libserial-port to form a serial connection to the uSEQ device (RP2040 based usb device).

I implemented a basic REPL to have a back and forth with the device. uSEQ ships with a much more full featured library called useqedit that I would recommend most people to use. I wrote this library to fold uSEQ into my native coding environment, which is Emacs and SLIME.

The cl-useq library can be found on my github along with a description and examples.

uSeq

It’s been a loong while since I last posted and I’ve been getting back into coding and music, the intersection of which got me into EE and CompSci way back in the early 2000s.

Common Lisp was the language of CLM and other software synthesis that attracted me at the time with fantasies of studying at Stanford’s CCRMA lab and the LaBRI Institute.

Nowadays there are new options like Incudine and OpusModus, which continue that direction and give me hope that I can continue to experiment with software based composition.

Lately I’ve been spending my days studying and practicing on an old studio piano as well as building a modest Eurorack DIY modular synth setup.

A kit popped up over at Thonk for a “livecoding” module called “uSeq” by Emute Labs, which is connected to the University of Sussex Experimental Music Lab.  It uses a Lisp dialect (uLisp) as a means to program the module using their own DSL called ModuLisp. There is even a published paper written that discusses livecoding with this tool.

The kit as sold by Thonk

The kit comes with everything you need to assemble the module minus a soldering iron, solder, and about 1/2 an hour of time.  There are two SMD switches, but other than it’s all through hole components.  They have a great build guide here and there is also a prebuilt version if you’d prefer to rack it up and go.

Soldered with Kestler no clean 60/40 solder
Installed and testing the blinkenlights.

The soldering went well and everything fired up on first go.  The 10 LEDs lit up in circling sequence and it showed up as a USB device on my Gentoo Linux host running realtime Linux Kernel 6.6.36. Here is the output of dmesg:

[646594.147296] usb 1-3: new full-speed USB device number 6 using xhci_hcd
[646594.295794] usb 1-3: New USB device found, idVendor=2e8a, idProduct=f00a, bcdDevice= 1.00
[646594.295812] usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[646594.295820] usb 1-3: Product: RP2040
[646594.295825] usb 1-3: Manufacturer: Generic
[646594.295830] usb 1-3: SerialNumber: E463B013DB56402B
[646594.332211] cdc_acm 1-3:1.0: ttyACM0: USB ACM device
[646594.332284] usbcore: registered new interface driver cdc_acm
[646594.332291] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

The bolded text “ttyACM0” is the device name for connecting to this new USB connection via the device file /dev/ttyACM0. The issue is that the permissions on that file did not allow my user to open the device:

elliott@deph ~ $ ls -al /dev/ttyACM0
crw-rw---- 1 root dialout 166, 0 Aug 4 04:22 /dev/ttyACM0

The OS is assigning the Rasberry Pi 2040 chip on uSeq as a communications device (like modems) rather than a USB serial device and so it assigns the “dialout” group and root user. If I’d like to connect to the device, I’ll need to either join that group or change permissions. I decided to change the permissions and the best way to do that is by setting up a udev rule. Here is what I added:

elliott@deph ~ $ cat /etc/udev/rules.d/50-useq.rules
SUBSYSTEMS=="usb"
ATTRS{idVendor}=="2e8a"
ATTRS{idProduct}=="f00a"
GROUP="audio"
MODE="0660"

The idVendor and idProduct were from dmesg output above, but also can be found by doing a lsusb -vvv to see all the details of the device. I have the “audio” group setup, my user configured to use it, and I changed the permissions to “0660” to ensure read/write access to that group as well as the root user. The udev rules were reloaded and the cable replugged back in to complete the permissions adjustment.

elliott@deph ~ $ ls -al /dev/ttyACM0
crw-rw---- 1 root audio 166, 0 Aug 4 04:22 /dev/ttyACM0

Now that we have a device and it’s attached, we can connect to it via a serial console emulator app. Luckily Emacs has built in methods and it was quick to load serial-term mode and connect to the device with an “9600 baud 8N1” connection rate using line-mode.

All this went flawlessly and I was soon issuing ModuLisp commands to the uSeq module to get reoccurring patterns on the analog outputs. Looking at the code it’s apparent that there is a python interface (useqedit) and I believe a SuperCollider interface here. The easiest method of connecting with uSeq is the webbased interface and it works well.

Over the next few weeks I’d like to go over the current state of the development environment, commands, and other aspects about using this module towards doing some livecoded audio.