Skip to main content

Prerequisites

File-based separation

Use SourceSeparationTask for file-to-file processing:
#include "AudioShakeSDK.h"

AudioFileReader* input = new AudioFileReader("input.wav");
WAVOutput* output = new WAVOutput("./output/");

SourceSeparationTask task(
    "your_client_id",
    "your_client_secret",
    input,
    output,
    "path/to/model.crypt"
);

void onProgress(SourceSeparationTask* task, double progress, void* data) {
    printf("Progress: %.0f%%\n", progress * 100);
}

if (!task.run(onProgress)) {
    fprintf(stderr, "Error: %s\n", task.getErrorMessage());
}

Streaming separation

Use RingBufferInput and RingBufferOutput for real-time or streaming use cases:
RingBufferInput* input = new RingBufferInput(4096, true, 44100);
RingBufferOutput* output = new RingBufferOutput(4096, false);

SourceSeparationTask task(
    "your_client_id",
    "your_client_secret",
    input,
    output,
    "path/to/model.crypt"
);
Write audio frames into the input ring buffer, then read separated stems from the output ring buffer as processing proceeds.

Choosing a chunk size

Chunk size controls the trade-off between latency and throughput. Durations are approximate and vary by model.
FlagApprox. durationUse when
chunkNormal (default)~3 secBatch or file processing
chunk2X~1.5 secModerate latency
chunk4X~0.75 secLow latency
chunk8X~375 msReal-time
chunk16X~185 msUltra low latency
chunk32X~92 msUltra low latency
chunk64X~46 msLowest latency
Smaller chunks reduce latency but increase CPU/GPU overhead per unit of audio.