Inspiration
Most assistive mixing systems are web-based, requiring users to submit tracks and receive a mix, which lacks control and an effective workflow. We want to integrate one that applies gain and pan settings per track to create a demo mix into a DAW. We chose Audiotools for our project and use the recently released SDK for the task.
Impact
Democratises music production by giving creators an AI mixing assistant within their workflow that reduces friction and speeds up the process.
How we built it
This script automates the process of applying audio mixing settings (post-gain and panning) to the first eight channels of an Audiotool project. It uses an ONNX AI model (AImix_model.onnx) to generate these settings based on audio samples.
The biggest challenge in our case is that the system needs to access all tracks and apply back effects to all the tracks. Hence, a typical VST solution for one track wouldn't have worked in our case. We list our approach and some of the solutions to circumvent SDK limitations here.
1. Polyfill localStorage
Since the script runs in a Node.js environment, which lacks the browser's localStorage object, a simple in-memory mock is created. This is necessary to satisfy the Audiotool SDK, which may have a dependency on localStorage.
2. Environment Variable Loading
The script robustly loads configuration from a .env file.
- It searches for the
.envfile in both the current working directory and the script's parent directory. - It uses the
dotenvlibrary for initial loading. - A custom function,
manualEnvInject, provides a fallback to parse the.envfile manually. This function is designed to handle various text encodings and formats, ensuring that variables likeAT_PAT(Audiotool Personal Access Token) andAT_PROJECT_URLare loaded correctly.
3. Argument Parsing
This section prepares the parameters required for the script's operation.
- It sets a
TARGET_COUNTof 8, meaning it will only modify the first eight mixer channels. - Helper functions are used to parse comma-separated strings from environment variables into arrays of numbers. These functions are tolerant of different delimiters and whitespace.
- It retrieves the
AT_PAT,AT_PROJECT_URL, and an optionalAT_NEXUS_MODULEpath from the environment variables and validates that the required ones are present.
4. Audiotool SDK Loading and Project Connection
This part of the script handles connecting to the Audiotool platform.
discoverAudiotoolCandidates: This function intelligently locates the installed Audiotool SDK (@audiotool/nexus) by checking common package names and the project'spackage.json.loadAudiotoolModule: It imports the discovered SDK module.openSyncedProject: It establishes a connection to the Audiotool project specified byAT_PROJECT_URL. The function is compatible with multiple versions of the SDK's API for authentication and project synchronisation.
5. Applying the Mix
This is the core logic where the script modifies the Audiotool project.
applyMixToFirstEight: This function queries the project for all mixer channels, sorts them by their index, and selects the first eight.- It then iterates through these channels and applies the
postGainandpanvalues generated by the AI model. - The modifications are performed using the
nexus.modifyfunction, which ensures changes are synced with the Audiotool server. - The script includes detailed logging for each step, indicating which channel is being modified and the values being applied.
6. Main Process
The main function orchestrates the entire workflow:
- It reads the audio sample file paths from the
downloadsdirectory. - It calls the
runModelfunction (fromrun-model.ts), passing the AI model, a music genre, the audio file paths, and a list of instruments. This function returns thePOSTGAINSandPANSarrays. - It loads the Audiotool SDK and connects to the project.
- It calls
applyMixToFirstEightto apply the generated settings. - Finally, it ensures the connection to the project is properly closed.
The script is executed by calling main(), with top-level error handling to catch any exceptions that may occur during the process.
We train the AI model from https://github.com/csteinmetz1/automix-toolkit/tree/main on MEdleyDB and mixing secrets research datasets. Once it is trained, we generate an ONNX checkpoint. This enables easy integration with JavaScript and is much smaller in size.
Challenges we ran into
Adapting backend and frontend
We first found it difficult to keep track of the order in which samples appear in the project because of the API limitations, and also to import and track instrument names.
Accomplishments that we're proud of
We successfully developed the backend by night and had a great team with varied skills who could each take on independent tasks.
What we learned
We learnt how to work with the Audiotools API and discovered that we ended up being a very good team to work with.
What's next for Mixing Assistant
We want to add support for text conditioning within the model and UI. We also want to expand the backend to dynamically support any number of tracks (limitation per the model to 16). Further, a bit more challenging, we would like to support more audio effects beyond gain and panning.
Log in or sign up for Devpost to join the conversation.