EMCT: COMPUTING MAJOR PROJECT

Part 2: Audio Programming in Rust, to be or not to be?

Rusty
4 min readJul 6, 2023

Debating the use case of Rust as the programming language of choice for the Major Project

A CLI message from the Rustlings game. It shows a large crab drawn in text characters congratulating you on completing Rustlings.
The message given when you complete Rustlings!

Upon writing my first blog post it became clear to me I wanted to just get my teeth into it and start exploring what audio effects are.

My programming language of choice?

I chose to use Rust as my programming language of choice to challenge myself. I’d dabbled in various audio programming frameworks such as JUCE, Maximilian, openFrameworks and had worked extensively in the visual programming language MaxMSP. While these frameworks were useful, I felt a distinct amount of confusion regarding the underlying concepts of audio tools. If you asked me how to make a plugin or to explain what a plugin is, I knew I’d struggle. I also couldn’t tell you what makes a plugin unique compared to other plugins that perform the same audio processing. This is becoming quite the crux of my project, this desire to understand the underlying principles of audio effects.

Therefore, my choices for Rust are: It will force me to understand the abstracted parts of audio tool development. Its very aggressive approach to memory safety and lack of support from the larger, more utilised SDKs (JUCE or VST SDK, for example) means I’ll have to develop an understanding of what these abstraction environments handle. Then I would have to learn how to implement this myself. This would likely be a useful learning experience but this project hinges on a deliverable, so where am I and is Rust making sense?

Where I am:

  • Began learning Rust
    — Read the Rust programming book.
    — Finished the in-built Rust educational CLI program ‘Rustlings’.
  • Began developing in Rust
    — Learning application development via cross-platform tools like GTK, which has a Rust version.
    — Began developing Rust Audio tools, with a Freeverb written in Rust by Ian Hobson being my first point of call.
  • Began Research
    — It’s clear my sources of information will be very important for this project, so finding strong academic books on the topics of audio development will be important.
    — Began research more into the underlying theory of digital audio, including audio data formatting, PCM sampling methods and starting to develop an understanding of abstraction framework purposes.

Review of current progress and Rust as a choice:

The development process has been relatively smooth. Rust is doing what I wanted, forcing me to look at systems programming in a way I never have, but it’s also becoming clear that Rust has shortcomings.

The most notable of which is, it’s not particularly backwards compatible. C/C++ has always prided itself on backward compatibility. As Rust is the “counter-C” high-efficiency systems language, it’s quickly becoming clear that Rust developers don’t give a damn about backward compatibility.

Second, Rust is weird. The syntax is unlike anything I’ve ever worked with before, and it’s rules, from borrowing to lifetimes, make the language very difficult to use, especially for a beginner. This is slowing me down. Issues I run into are made three times harder by my lack of familiarity with the language.

What does this mean for me? Well, it means even popular and well-written Rust implementations of audio tools are deprecated. For example, Ian Hobson’s Freeverb-rs is completely unusable because its front-end methods inside GTK-rs are deprecated. This has stifled me and is an issue I’m running into with other Rust plugin examples I find online. Rust already has considerably less maturity compared to C/C++, coupled with the niche nature of audio programming, and it’s becoming clear that Rust support for audio may be doing more harm than good. Combined with my difficulty using the language, it’s starting to look like Rust may not be the best choice for this project.

Next Steps:

  • Create the full proposal for the project
    — This will involve consolidating research and developing a firmer understanding of what my project is.
  • Consider C++ over Rust
    — This project is focused on the underlying parts of audio plugins. There’s no definitive need for the project to be done in Rust. Therefore if working in C++ still allows me to conduct my research, I will consider making the switch.
    — This will involve finding C++ examples of audio code and teaching myself how to compile C++ code properly.
  • Consider the extent of abstraction
    — While I want this project to have minimal abstraction, some may be necessary. Through research, I hope to establish what is essential.

Written: Dec 14, 2022

--

--

Rusty

Audio, Coding, Technology and Music --- Educational blog posts on a variety of creative computing works.