Designing an Audio Loop Station

This week, I was assigned my Capstone project, designing an Audio Loop Station.

What is an audio loop station? Traditionally, it is a piece of hardware that allows artists to record short (generally 16 beat) loops that will then repeat indefinitely. The user then records multiple loops, so they layer on top of each other. That way, one person can play the percussion, bass, lead instrument, lead singer and harmonizer, and anything else they can think up. In summation, and audio loop station is the modern one-man band. Here is an example video the instructor provided in the project description.

The Challenge of Platform Choice

In this project, we will turn this piece of hardware into digital software, so the artist only needs a laptop to create an infinite amount of music. But how will this work? There’s a lot of variables at play here, such as how the application will run. Will it be a desktop app or a web app? Or even a mobile app? With each of these components, performance is very important, so what will provide the best?

Initially, creating a desktop application with Python jumps out to me, as I have worked with audio in Python. However, performance goes out the window, as working with audio on a Python GUI can be clunky in most situations. Then there is web and mobile applications. These stand out as contenders for a seamless, beautiful UI with minimum work. However, I fear JavaScript and Dart may also struggle with performance.

Finally, there is C++, the gold standard in performance. Currently, I am thinking this could be the best solution. Performance will be much easier to maintain with C++, and Microsoft Visual Studio provides tools for easily creating a C++ UI. Here is an example C++ UI that has a couple useful attributes to draw ideas from.

Technologies Used in Audio Looping

Some technologies which are new to me will be required to complete this project. Of these technologies, Audio Stream I/O, threading for non-blocking processes and DSP stand out most to me.

Audio Stream I/O

From research, audio stream I/O sounds like a way to input and output audio directly through the sound card of the computer. Where normal file I/O would utilize many layers in an OS to load an audio file, we will need to bypass all these steps to maximize the performance of our application. Based on research performed at Stanford, it appears C++ has a library called RtAudio to perform realtime audio I/O. This will be a good initial point for research should we choose to use C++.

Stanford realtime audio I/O research: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.74.9579&rep=rep1&type=pdf

Multithreading in C++

Threading in C++ is something I am mildly familiar with, as I had to learn multithreading for an Operating Systems class. While C was used in this class, the idea will be similar and more than likely simpler in C++. There is a thread library in C++ which enables this functionality to occur, and it looks to be very simple. Essentially, a function is written that will be executed on its own thread. Then, using the syntax “thread thread1(function, n)” (where n is the number of threads) will allow the process to fork and be non-blocking.

// Code obtained from:
// https://www.geeksforgeeks.org/multithreading-in-cpp/
#include <thread>
using namespace std;

// A dummy function
void foo(int Z)
{
    for (int i = 0; i < Z; i++) {
        cout << "Thread using function"
               " pointer as callable\n";
    }
}

int main()
{
    thread th1(foo, 3);
    return 0;
}

Digital Signal Processing

Finally, in the technologies, DSP was the final thing that stood out to me. It stands for Digital Signal Processing, meaning filtering or altering audio using some sort of digital processor. This will include items such as changing the pitch of the audio, lengthening the audio without changing pitch, filtering signals and reversing playback. Some of this, I have done, but others I have not. Prior to computer science, I was in mechanical engineering, and I learned about some techniques such as filtering audio. However, refreshing my knowledge will likely take some time, and there will still be more to learn.

This project poses many questions to me, most of which I do not yet have the answer for. I look forward to discovering where it will go, and what technologies we choose to use.

Leave a comment

Your email address will not be published. Required fields are marked *