Tom Gardiner

I'm attempting to create a DAW in Rust

Why?! Am I not happy with FL Studio? Am I just crazy? Hopefully the answer to both of those questions is no.

My dream job involves back-end programming, preferably with some sort of audio or video processing involved. I've always been fascinated by the way media is encoded, and I love writing low level code that can be optimised to the depths of hell and back - I just never get to at work, and there's never really any reason to do so in my spare time. In order to direct my professional career in that direction, what better way than to start a project with a humongous scope that will surely not fail when I inevitably burnout and realise how much more complicated it'll be. /s

Why Rust?

I've chosen Rust because I've been a huge fan of it since discovering it around 2016 or 2017. To prove this - I used it for my final year project at university, which generated "creatures" and trained them using a variety of optimisation methods (eg. genetic algorithm, hill climbing, and simulated annealing); I used it to process millions of weather station and train arrival and departure data points as quickly as possible in my first job out of university; and I still use several personal scripts written in Rust to this day (one generates this website on a cron job!).

However, I've not properly used Rust since 2019, and I would really like to become proficient at it. Rust is a reeeeeeally cool language that prevents you from compiling code it knows will cause memory leaks. It doesn't stop you writing wobbly logic, but it'll stop you throwing pointers into a closed box and hoping they're not being referenced anymore (somewhat akin to Schrödinger's cat)!

Setting up a graphical user interface

Coming from a TypeScript/React background, I'm through with HTML, the DOM, and most importantly - any kind of Electron or WebView application. No. Please and thank you. It must be native, or literally anything that doesn't run Chromium in some form. After trying a few GUI libraries, I finally settled with egui, because of its simpler form/widget construction, and its state management just seems to make more sense to my brain. That, and it has internal windowing already built-in! In nearly all other libraries, I would have to construct such a thing myself, and for quick prototyping, especially, having it already provided was such a huge win.

Screenshot of a graphical user
interface created with the egui library

A few days into the process, I had an almost entirely superficial user interface built up, including a basic windowing system copied almost entirely from one of the example projects within egui, and basic state management so mixer channels could be controlled.

Audio Engine

This is really where I intended to put most effort into this project. Learning how to process digital signals, create synthesizers and effects from scratch, and visualising them - as well as achieving the goals I set out at the start, it's just plain cool!

The only decent library I've found for audio output is cpal, which supports all major platforms, and even supports ASIO on Windows, which is probably what I'll be using eventually, if I get to the point of audio and/or MIDI recording, due to its much lower latency than the default Windows audio API.

I have some ideas as to how this should pan out (that's a music production pun, I'm sorry), but I'll write another blog post soon with what I've learned! You can check up on how the process is going via my more rambly update diary, inside the public repo (it's also being mirrored to GitHub)!