linux

The Joys of Cocoa (in 2024)

  • by

The McLaren Synth Kit presents audio synthesis as the construction of a graph of audio operators (voices) with the parameters of each type of operator determined by an associated model. Voices define the code that is run in the audio thread and models hold the values that are read from the audio thread. This separation allows the audio thread code to be ensured that maniplations on the models do not block. With models safely out of the audio loop, UI interactions with model properties is straightforward and can use Cocoa idioms for manipulating property values.

At least that was the intent. The McLaren Synth Kit was released without associated GUI controls, but we believed it would be straightforward to define controls for the various models.

But we had never fully defined a Cocoa-based application that rested on the Synth Kit. We finally put it all together in our newly released application called “Synth80”.

Synth80 is a two-oscillator multi-timbral polyphonic synthesizer. This application pulls together the following features.

  • Cocoa bindings for linking Controllers to McLaren Synth Kit Models
  • Document-based application for saving and restoring presets
  • Undo/Redo facility
  • Single Document Interface document-based application for the singleton Synthesizer window

This article summarizes some of the things we learned about using Cocoa this way while developing Synth80.

Focus on Data Structures

We found that we were able to focus on modeling data more than building GUI elements. The models for our synthesizer elements (envelopes, oscillators, filters, etc) were designed first, with controls added later.

Read More »The Joys of Cocoa (in 2024)

Announcing McLaren MIDI Kit – RTP-MIDI library for your own projects

  • by

The McLaren Synth Kit — https://github.com/mclarenlabs/McLarenSynthKit — now includes an RTP-MIDI engine that you can include in your own projects. The engine is the same one that is in our well-known rtpmidi product! We’re providing the library so that you can set up RTP-MIDI connections as you like.

Background

We sometimes receive requests from users to add features to McLaren Labs’ rtpmidi product to handle connections in a certain way. Some users might want to automatically find a particular endpoint or address. Another user might want automatic re-connect in a certain situation. Others want to experiment by translating events from non-MIDI sources into note events sent to a synthesizer on their network.

Read More »Announcing McLaren MIDI Kit – RTP-MIDI library for your own projects

Arduino AppleMIDI and McLaren rtpmidi

  • by
SparkFun ESP2866 “Thing Dev” board

One of our customers brought to our attention an implementation of RTP MIDI for Arduino. With this sketch, you can use an Arduino to send and receive MIDI over Ethernet and WiFi. It is compatible with McLaren Labs’ rtpmidi, so you can use it to send MIDI from an Arduino to your Raspberry Pi.

Read More »Arduino AppleMIDI and McLaren rtpmidi

Announcing McLaren Synth Kit

The “McLaren Synth Kit” is an Objective-C framework for using MIDI and Audio on Linux computers with the GNUstep programming environment. It is distributed as a project including libraries, headers and example programs at https://github.com/mclarenlabs/libs-mclaren-alpha. You can use it to experiment with sound synthesis for your own personal projects. The project is designed to provide ready-to-compile examples after you clone the repo.

Working with sound is a delicate endeavor. The Synth Kit does a lot of the low-level work of opening devices, managing an audio thread and copying MIDI events to and from dispatch queues. This leaves the audio programmer free to think about designing sounds as a graph of processing units, called Voices.

Standard Voices in the Synth Kit provide envelopes and oscillators of various types, filters and a reverb algorithm. Using the features of modern Objective-C (blocks, ARC and dispatch queues) the Synth Kit makes programming sounds easy, or at least “easier.”

Read More »Announcing McLaren Synth Kit

VSCode, Ubuntu Snaps and ALSA Sound Development

Here at McLaren Labs we like to try all sorts of tools and development environments to see how they work together. We’ve been using vscode (https://code.visualstudio.com/) on and off for about a year, but only recently decided to try using it for a more complete edit/debug/run cycle for an Objective-C Synthesizer project. We ran into an unexpected interaction between the Snap environment of vscode and the ALSA (Advanced Linux Sound Architecture) PCM interface.

The Symptoms

What we discovered was that when running a program that attempted to access an ALSA sound device was that the program malfunctioned. It worked correctly in a “normal” terminal, however.

We reproduced the behavior using the default aplay command that is available in alsa-utils. See the screenshot below for what should appear in a terminal when it is run, playing an Ubuntu standard sound called “Front-Left”. Unless otherwise specified, this command opens the “default” sound device.

If your Ubuntu sound system is set up correctly, you will hear a woman saying “Front Left” … and it will come out of your front-left speaker.

Read More »VSCode, Ubuntu Snaps and ALSA Sound Development

Enabling memlock for rtpmidi on Ubuntu 20.10

  • by

In version 0.5.2 of McLaren Labs’ rtpmidi, we made the use of locked memory the default. Locked memory dedicates fixed RAM to the rtpmidi process, and prevents it from being swapped to disk. The use of locked memory (through the mlockall() function call) can be a benefit to realtime applications like MIDI and Audio, but its use can be to the detriment of other processes. So it should be used carefully.

On Ubuntu 18.04 and 20.04 enabling memlock as the default option seemed benign enough. On Ubuntu 20.10, however, this default caused problems. With memlock enabled, the process printed strange errors and aborted. Example:

***MEMORY-ERROR***: rtpmidi[2023]: GSlice: failed to allocate 8176 bytes (alignment: 8192): Cannot allocate memory

Ubuntu 20.10 (Groovy Gorilla) accounts for locked memory pages differently, and even though the memory limit is higher, with all things accounted for, it is not enough.

Read More »Enabling memlock for rtpmidi on Ubuntu 20.10

The State of Network MIDI (2019)

Network MIDI was invented sometime around 2004 to send MIDI messages over an IP network. To handle network loss, a protocol known as RTP-MIDI was created and documented as RFC-4695. Network MIDI is built into OSX computers and iOS devices. Apple music creators think nothing of connecting MIDI equipment using Ethernet and WiFi, instead of MIDI cables.

Sometime around 2009, Network MIDI was built into iPads and iPhones. This made building touch-based control surface Apps easy, and ensured they integrated with MIDI Workstations over WiFi. While this capability created many cool demos, the unpredictable latency and jitter of WiFi made MIDI-over-WiFi not attractive where timing is important. MIDI-over-Bluetooth became a standard in the last few years, and seems to be the preferred method for sending MIDI over wireless links.

But Network MIDI persists, and new implementations of the protocol as software pop up, as do new hardware products implementing the protocol. This article is a round-up of some of the implementations available in 2019.

Read More »The State of Network MIDI (2019)

Why McLaren Labs uses Objective-C

McLaren Labs was started with the idea that music and media creation on Linux should be as easy and fluid as Mac OSX. We had been inspired by AVFoundation and the modular way its pieces fit together. We loved being able to build media pipelines with sources and sinks that cleaned up after themselves when you were done with them them.

Many of the facets of the OSX components we liked were provided by ObjC features enabled by the Clang compiler and LLVM tool suite. LLVM has revolutionized language development by paving the way for Swift and Rust. Back at the time we were getting started, Swift on Linux was gaining traction and we considered adopting it. However, after some initial explorations with Swift and libdispatch, we discovered that libdispatch just wasn’t ready with Swift on Linux. That was in 2015 – Swift on Linux is much more mature. The equation might be different today … but it might not too.

Read More »Why McLaren Labs uses Objective-C