C++
Native C interface for embedding the Rapidly Audio Engine into desktop, server, and embedded applications.
The C interface for the Rapidly Audio Engine gives developers access to Rapidly's audio processing capabilities from any language with C-compatible bindings. The engine is light-weight, cross-platform, and loads pre-trained models for real-time tasks: noise reduction and de-reverberation.
Getting Started
The Rapidly API is designed to be as simple as possible. The ProcessFile example in the Rapidly SDK on GitHub is a complete working integration.
Prerequisites
- CMake 3.22 or later
- Add the Rapidly API
Includefolder to your header search path
Basic Usage
Include the Rapidly header:
#include "RapidlyEngine.h"Create a processor by specifying a model file path, channel count, and sample rate:
RapidlyProcessorHandle processorHandle = rapidlyCreateProcessor(
modelFilePath,
numOfChannels,
sampleRate
);
if (processorHandle == NULL)
handleError("Unable to create the Rapidly audio processor.");Add audio for processing. The API supports both interleaved and separate channel formats:
// Interleaved format (L1, R1, L2, R2, ...)
rapidlyAddAudioInterleaved(processorHandle, audioBuffer, numOfSamples);Retrieve processed audio. Processing introduces latency, so query the number of available samples first:
int32_t numOfPendingSamples = rapidlyGetNumOfPendingSamples(processorHandle);
float* processedBuffer = malloc(numOfChannels * numOfPendingSamples * sizeof(float));
rapidlyGetAudioInterleaved(processorHandle, processedBuffer, numOfPendingSamples);When finished, delete the processor to free memory:
rapidlyDeleteProcessor(processorHandle);To capture the processing tail caused by model latency, add silent audio (zeros) after your input stream ends.
Output Busses and Parameters
Rapidly models typically have multiple output busses with adjustable gain and sensitivity. A noise-reduction model outputs clean speech on one bus and isolated noise on another. A de-reverberation model adds a separate bus for the captured reverb.
Querying Output Busses
int32_t numOfBusses = rapidlyGetNumOfOutputBusses(processorHandle);
char busName[256];
rapidlyGetOutputBusName(processorHandle, busIndex, busName, sizeof(busName));Setting Gain and Sensitivity
Use parameter IDs to control each output bus. The first bus uses RAPIDLY_PARAM_BUS_GAINS, the second RAPIDLY_PARAM_BUS_GAINS + 1, and so on:
// Set gain for bus 0 to unity (1.0)
rapidlySetParameterValue(processorHandle, RAPIDLY_PARAM_BUS_GAINS + 0, 1.0f);
// Increase sensitivity for bus 1
rapidlySetParameterValue(processorHandle, RAPIDLY_PARAM_BUS_SENSITIVITIES + 1, 50.0f);Licensing
A Rapidly license removes audio watermarking from the output and unlocks the model and latency entitlements granted by the key. Without a license, the engine runs in a watermarked demo mode that audibly degrades the output.
License keys have the format lk_<base64url-payload>.<base64url-signature> and are verified offline against an embedded Ed25519 public key. No network access is required.
To obtain a license, contact us.
Pass the key to the engine before creating any processor:
if (!rapidlyAddLicense("lk_..."))
handleError("Rapidly license could not be verified.");Types
RapidlyProcessorHandle
typedef void* RapidlyProcessorHandle;Opaque handle to an audio processor instance. Created with rapidlyCreateProcessor.
RapidlyProcessorInfo
typedef struct RapidlyProcessorInfo {
double sampleRate; // Sample rate the model was trained on
int32_t numOfModelChannels; // Number of channels used internally
int32_t latencyInSamples; // Maximum processing latency
int32_t blockSize; // STFT block size
int32_t hopSize; // STFT hop size
} RapidlyProcessorInfo;The processor automatically converts sample rates and channel formats to match the model.
Functions
Licensing
rapidlyAddLicense
bool rapidlyAddLicense(const char* licenseString);Adds a license key to remove audio watermarking from the output.
| Parameter | Description |
|---|---|
licenseString | License string issued by Rapidly. |
Returns: true if the license is valid, false otherwise.
Processor Lifecycle
rapidlyCreateProcessor
RapidlyProcessorHandle rapidlyCreateProcessor(
const char* modelFilepath,
int32_t numOfChannels,
double sampleRate
);Creates a processor and loads a single model file.
| Parameter | Description |
|---|---|
modelFilepath | Path to the .rapidly model file. |
numOfChannels | Number of audio channels to process. |
sampleRate | Sample rate of the input audio. |
Returns: Valid processor handle on success, NULL on failure.
rapidlyDeleteProcessor
void rapidlyDeleteProcessor(RapidlyProcessorHandle processorHandle);Deletes a processor instance and frees all associated memory.
rapidlyResetProcessorState
void rapidlyResetProcessorState(RapidlyProcessorHandle processorHandle);Resets the processor state and clears all internal delay lines. Call this when starting a new audio stream.
Audio I/O
rapidlyAddAudio
void rapidlyAddAudio(
RapidlyProcessorHandle processorHandle,
const float** pcmChannels,
int32_t numOfSamples
);Adds audio from separate channel buffers.
| Parameter | Description |
|---|---|
processorHandle | Handle to the processor. |
pcmChannels | Array of pointers to per-channel sample data. |
numOfSamples | Number of samples per channel to add. |
rapidlyAddAudioInterleaved
void rapidlyAddAudioInterleaved(
RapidlyProcessorHandle processorHandle,
const float* interleavedPCM,
int32_t numOfSamples
);Adds audio from an interleaved buffer (L1, R1, L2, R2, ...).
| Parameter | Description |
|---|---|
processorHandle | Handle to the processor. |
interleavedPCM | Pointer to interleaved sample data. |
numOfSamples | Number of samples per channel to add. |
rapidlyGetNumOfPendingSamples
int32_t rapidlyGetNumOfPendingSamples(RapidlyProcessorHandle processorHandle);Returns the number of processed samples available for retrieval.
Returns: Number of completed samples ready to read.
rapidlyGetAudio
bool rapidlyGetAudio(
RapidlyProcessorHandle processorHandle,
float* const* pcmChannels,
int32_t numOfSamples
);Retrieves processed audio into separate channel buffers.
| Parameter | Description |
|---|---|
processorHandle | Handle to the processor. |
pcmChannels | Array of pointers to receive per-channel data. |
numOfSamples | Number of samples to retrieve. Must be less than or equal to the pending sample count. |
Returns: true on success, false on failure.
rapidlyGetAudioInterleaved
bool rapidlyGetAudioInterleaved(
RapidlyProcessorHandle processorHandle,
float* interleavedPCM,
int32_t numOfSamples
);Retrieves processed audio into an interleaved buffer.
| Parameter | Description |
|---|---|
processorHandle | Handle to the processor. |
interleavedPCM | Pointer to receive interleaved sample data. |
numOfSamples | Number of samples to retrieve. Must be less than or equal to the pending sample count. |
Returns: true on success, false on failure.
Parameters
rapidlyGetParameterValue
float rapidlyGetParameterValue(
RapidlyProcessorHandle processorHandle,
int32_t parameterIndex
);Gets the current value of a parameter.
Returns: Current parameter value.
rapidlySetParameterValue
void rapidlySetParameterValue(
RapidlyProcessorHandle processorHandle,
int32_t parameterIndex,
float parameterValue
);Sets a parameter value.
rapidlyGetParameterRange
void rapidlyGetParameterRange(
RapidlyProcessorHandle processorHandle,
int32_t parameterIndex,
float* minimumValue,
float* maximumValue
);Gets the valid range for a parameter.
Processor Info
rapidlyGetProcessorInfo
void rapidlyGetProcessorInfo(
RapidlyProcessorHandle processorHandle,
RapidlyProcessorInfo* processorInfo
);Fills a RapidlyProcessorInfo struct with information about the processor's model configuration.
rapidlyGetNumOfOutputBusses
int32_t rapidlyGetNumOfOutputBusses(RapidlyProcessorHandle processorHandle);Returns: Number of output busses available.
rapidlyGetOutputBusName
void rapidlyGetOutputBusName(
RapidlyProcessorHandle processorHandle,
int32_t outputBusIndex,
char* outputBusName,
int32_t maxLength
);Gets the name of an output bus.
| Parameter | Description |
|---|---|
processorHandle | Handle to the processor. |
outputBusIndex | Index of the output bus (0 to numBusses - 1). |
outputBusName | Buffer to receive the name. |
maxLength | Size of the buffer including the null terminator. |
rapidlyGetVectorArithmeticWrapperName
void rapidlyGetVectorArithmeticWrapperName(
char* wrapperName,
int32_t maxLength
);Gets the name of the vector arithmetic library currently in use.
Parameter Constants
| Constant | Value | Description |
|---|---|---|
RAPIDLY_PARAM_MAXATTENUATION | 0x0001 | Maximum attenuation in dB. Range: (-∞, 0]. |
RAPIDLY_PARAM_SENSITIVITY | 0x0002 | Processing sensitivity. Range: -100% to 100%. 0% is neutral. |
RAPIDLY_PARAM_MASKEXTRAPOLATION | 0x0003 | Enable high-frequency mask extrapolation. ≥0.5 enables, <0.5 disables. |
RAPIDLY_PARAM_BUS_GAINS | 0x0100 | Base ID for output-bus gains. Add the bus index for a specific bus. Linear, range: 0 and up. |
RAPIDLY_PARAM_BUS_SENSITIVITIES | 0x0200 | Base ID for output-bus sensitivities. Add the bus index for a specific bus. Range: -100% to 100%. |
Performance
The Rapidly Audio Engine uses hardware-accelerated vector arithmetic when available:
- Intel IPP (Intel Performance Primitives)
- Apple vDSP (Accelerate framework)
- ARM NEON intrinsics
The engine falls back to optimized C++ when no hardware acceleration is available.
Custom Models
Rapidly provides general-purpose models for noise reduction and de-reverberation. For specialized requirements, we can train custom models optimized for your specific use case. Contact us for more information.