clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit 54bcf55d56219cc1714a07f276ac4e3ccd8ae2e8
parent 9033a64e86adb7b56e8cb1b8ca003ff0837d187f
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Mon, 24 May 2021 09:30:51 +0200

It is now possible to get interleaved audio buffer

Diffstat:
Mexamples/plugins/gain/gain.cc | 11+++++------
Minclude/clap/clap.h | 11+++++------
Minclude/clap/ext/audio-ports.h | 1+
3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/examples/plugins/gain/gain.cc b/examples/plugins/gain/gain.cc @@ -59,14 +59,13 @@ void Gain::deactivate() { void Gain::trackInfoChanged() { updateChannelCount(true); } clap_process_status Gain::process(const clap_process *process) { - auto **in = process->audio_inputs[0].data32; - auto **out = process->audio_outputs[0].data32; + float *in = process->audio_inputs[0].data32i; + float *out = process->audio_outputs[0].data32i; float k = 1; - - for (int i = 0; i < process->frames_count; ++i) { - for (int j = 0; j < channelCount_; ++j) - out[j][i] = k * in[j][i]; + const auto N = process->frames_count * channelCount_; + for (int i = 0; i < N; ++i) { + out[i] = k * in[i]; } return CLAP_PROCESS_CONTINUE_IF_NOT_QUIET; diff --git a/include/clap/clap.h b/include/clap/clap.h @@ -60,11 +60,11 @@ enum { typedef int32_t clap_process_status; typedef struct clap_audio_buffer { - // Either data32 or data64 will be set, but not both. - // If none are set, assume that the input has the value 0 for each samples. - // data[i] for channel i buffer - float ** data32; - double **data64; + // Only one of dataXXX pointer will be set. + float ** data32; // non-interleaved + float * data32i; // interleaved + double **data64; // non-interleaved + double * data64i; // interleaved int32_t channel_count; uint32_t latency; // latency from/to the audio interface uint64_t constant_mask; // mask & (1 << N) to test if channel N is constant @@ -183,7 +183,6 @@ typedef struct clap_plugin { bool (*activate)(struct clap_plugin *plugin, int sample_rate); void (*deactivate)(struct clap_plugin *plugin); - // Set to true before processing, and to false before sending the plugin to sleep. // [audio-thread] bool (*start_processing)(struct clap_plugin *plugin); diff --git a/include/clap/ext/audio-ports.h b/include/clap/ext/audio-ports.h @@ -20,6 +20,7 @@ typedef struct clap_audio_port_info { // and output, only for main input to main output int32_t channel_count; clap_chmap channel_map; + bool interleave; // selects interleaved buffer } clap_audio_port_info; // The audio ports scan has to be done while the plugin is deactivated.