Tools · The Engine

A real-time audio engine with a C API.

The Engine is a cross-platform shared library for synthesis, sampling and mixing. A C++20 core sits behind a plain C API, so you can call it from C, C++, C#, or anything else that can load a native library.

  • TheEngineCore shared library
  • C++20 core
  • C API
  • CMake build
  • Windows · Linux · macOS · Android

What it does

Create an engine, load instruments into slots, and play notes, either straight away or scheduled to the sample on the engine’s audio clock. Then mix the result through channel strips, effect buses and a master compressor and limiter.

You choose who owns the audio device. Call UniversalCore_Render from your own audio callback, or let the engine open the device itself with UniversalCore_StartAudio (via miniaudio).

Control it from any thread. Calls go through a lock-free command queue, and nothing allocates on the audio thread.

A first sound

#include "UniversalCore.h"

// 48 kHz, up to 512 frames per render
UniversalEngineHandle eng = UniversalCore_Create(48000, 512);

UniversalCore_InitInstrument(eng, 0, 1);  // slot 0: synth
UniversalCore_InitInstrument(eng, 1, 3);  // slot 1: drums
UniversalCore_SetTempo(eng, 120.0f);

// Let the engine open the output device...
UniversalCore_StartAudio(eng);
// ...or call UniversalCore_Render(eng, buf, frames, 2)
// from your own audio callback instead.

// Schedule on the audio clock (seconds)
double t = UniversalCore_GetTime(eng) + 0.1;
UniversalCore_PlayNoteAt(eng, 0, 60.0f, 100, 1, t); // C4
UniversalCore_StopNoteAt(eng, 0, 1, t + 0.5);
UniversalCore_PlayNoteAt(eng, 1, 36.0f, 120, 2, t); // kick

// later
UniversalCore_StopAudio(eng);
UniversalCore_Destroy(eng);

Signal flow

The Engine signal flow Your code sends commands from any thread through a lock-free queue to the audio thread. Instrument slots (synth, sampler, drums) feed mixer channel strips, which feed the reverb, delay and chorus buses and the master compressor and limiter, out to your render callback or the audio device. Your code any thread Command queue lock-free notes, params, tempo, samples AUDIO THREAD · NO ALLOCATION Synth 2 osc · FM · filters Sampler key zones Drums pads instrument slots · polyphony shared sample pool Channel strips gain · pan sends meters Reverb Delay Chorus effect buses Master compressor + limiter dry Output Render() or device

Features

Instrument slots

Synth, sampler with key zones, or drums in each slot. Polyphony with voice stealing.

Synth

Two oscillators with FM, two filters, LFOs and modulation envelopes.

Sample-accurate timing

Schedule on the audio clock with PlayNoteAt, StopNoteAt and SetTempo.

Mixer

Per-channel strips and meters, reverb, delay and chorus buses, and a master compressor and limiter.

Shared sample pool

Load a sample once, from a file, memory or raw floats, and assign it to any zone or pad.

Parameter metadata

Query each parameter’s range and default, so your UI can build its own controls.

Bring your own audio, or don’t

Render from your own callback, or let the engine drive the device through miniaudio.

Thread-safe control

A lock-free command queue lets any thread drive it. Nothing allocates on the audio thread.

Platforms

Built with CMake
WindowsTheEngineCore.dll
LinuxlibTheEngineCore.so
macOSlibTheEngineCore.dylib
AndroidNDK

In use

Powering GainStage

GainStage’s music and sound run on The Engine, called from C# through its C API.

See GainStage →

Interested in using The Engine in your own project? Get in touch.