Bindings

C / C++

Native C interface for embedding the Rapidly SDK into desktop, server, and embedded applications.

The C / C++ binding is the most direct way to embed the Rapidly SDK. The same RapidlyEngine.h header drives pure C and C++ projects, and the engine ships as a single binary per platform that you link directly into your application. See Overview for what's inside the engine and where it runs.

Install

  • CMake 3.22 or later
  • Add the Rapidly include/ folder to your header search path
  • Link the binary for your target platform from bin/<platform>/

The ProcessFile example in the Rapidly SDK on GitHub is a complete working integration.

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);

Threading

Drive each processor from a single thread, and call rapidlyDeleteProcessor explicitly when done (C has no automatic cleanup). See One vs multiple engines for the universal threading rules.

Licensing

Call rapidlyAddLicense before constructing any processor. See Pricing for licensing options.

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.

ParameterDescription
licenseStringLicense 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.

ParameterDescription
modelFilepathPath to the .rapidly model file.
numOfChannelsNumber of audio channels to process.
sampleRateSample 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.

ParameterDescription
processorHandleHandle to the processor.
pcmChannelsArray of pointers to per-channel sample data.
numOfSamplesNumber 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, ...).

ParameterDescription
processorHandleHandle to the processor.
interleavedPCMPointer to interleaved sample data.
numOfSamplesNumber 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.

ParameterDescription
processorHandleHandle to the processor.
pcmChannelsArray of pointers to receive per-channel data.
numOfSamplesNumber 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.

ParameterDescription
processorHandleHandle to the processor.
interleavedPCMPointer to receive interleaved sample data.
numOfSamplesNumber 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.

ParameterDescription
processorHandleHandle to the processor.
outputBusIndexIndex of the output bus (0 to numBusses - 1).
outputBusNameBuffer to receive the name.
maxLengthSize of the buffer including the null terminator.

rapidlyGetVectorArithmeticWrapperName

void rapidlyGetVectorArithmeticWrapperName(
    char* wrapperName,
    int32_t maxLength
);

Gets the name of the hardware acceleration library currently in use (vDSP, IPP, or NEON).

Parameter constants

ConstantValueDescription
RAPIDLY_PARAM_MAXATTENUATION0x0001Maximum attenuation in dB. Range: (-∞, 0].
RAPIDLY_PARAM_SENSITIVITY0x0002Processing sensitivity. Range: -100% to 100%. 0% is neutral.
RAPIDLY_PARAM_MASKEXTRAPOLATION0x0003Enable high-frequency mask extrapolation. ≥0.5 enables, <0.5 disables.
RAPIDLY_PARAM_BUS_GAINS0x0100Base ID for output-bus gains. Add the bus index for a specific bus. Linear, range: 0 and up.
RAPIDLY_PARAM_BUS_SENSITIVITIES0x0200Base ID for output-bus sensitivities. Add the bus index for a specific bus. Range: -100% to 100%.