better indentation

This commit is contained in:
Paolo Marrone 2024-07-03 17:32:34 +02:00
parent 0fa25e8dc7
commit 8ffbd207fe
3 changed files with 98 additions and 94 deletions

View File

@ -18,66 +18,70 @@
* File author: Stefano D'Angelo * File author: Stefano D'Angelo
*/ */
#define NUM_AUDIO_BUSES_IN {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "input").length}} #define NUM_AUDIO_BUSES_IN {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "input").length}}
#define NUM_AUDIO_BUSES_OUT {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "output").length}} #define NUM_AUDIO_BUSES_OUT {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "output").length}}
#define AUDIO_BUS_IN {{=it.product.buses.findIndex(x => x.type == "audio" && x.direction == "input" && !x.cv && !x.sidechain && !x.optional)}} #define AUDIO_BUS_IN {{=it.product.buses.findIndex(x => x.type == "audio" && x.direction == "input" && !x.cv && !x.sidechain && !x.optional)}}
#define AUDIO_BUS_OUT {{=it.product.buses.findIndex(x => x.type == "audio" && x.direction == "output" && !x.cv && !x.sidechain && !x.optional)}} #define AUDIO_BUS_OUT {{=it.product.buses.findIndex(x => x.type == "audio" && x.direction == "output" && !x.cv && !x.sidechain && !x.optional)}}
#define NUM_CHANNELS_IN {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "input" && !x.cv && !x.sidechain && !x.optional).length > 0 ? (it.product.buses.filter(x => x.type == "audio" && x.direction == "input" && !x.cv && !x.sidechain && !x.optional)[0].channels == "mono" ? 1 : 2) : 0}} #define NUM_CHANNELS_IN {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "input" && !x.cv && !x.sidechain && !x.optional).length > 0 ? (it.product.buses.filter(x => x.type == "audio" && x.direction == "input" && !x.cv && !x.sidechain && !x.optional)[0].channels == "mono" ? 1 : 2) : 0}}
#define NUM_CHANNELS_OUT {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "output" && !x.cv && !x.sidechain && !x.optional).length > 0 ? (it.product.buses.filter(x => x.type == "audio" && x.direction == "output" && !x.cv && !x.sidechain && !x.optional)[0].channels == "mono" ? 1 : 2) : 0}} #define NUM_CHANNELS_OUT {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "output" && !x.cv && !x.sidechain && !x.optional).length > 0 ? (it.product.buses.filter(x => x.type == "audio" && x.direction == "output" && !x.cv && !x.sidechain && !x.optional)[0].channels == "mono" ? 1 : 2) : 0}}
#define NUM_NON_OPT_CHANNELS_IN {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "input" && !x.optional).reduce((a, x) => a + (x.channels == "mono" ? 1 : 2), 0)}} #define NUM_NON_OPT_CHANNELS_IN {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "input" && !x.optional).reduce((a, x) => a + (x.channels == "mono" ? 1 : 2), 0)}}
#define NUM_NON_OPT_CHANNELS_OUT {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "output" && !x.optional).reduce((a, x) => a + (x.channels == "mono" ? 1 : 2), 0)}} #define NUM_NON_OPT_CHANNELS_OUT {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "output" && !x.optional).reduce((a, x) => a + (x.channels == "mono" ? 1 : 2), 0)}}
#define NUM_ALL_CHANNELS_IN {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "input").reduce((a, x) => a + (x.channels == "mono" ? 1 : 2), 0)}} #define NUM_ALL_CHANNELS_IN {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "input").reduce((a, x) => a + (x.channels == "mono" ? 1 : 2), 0)}}
#define NUM_ALL_CHANNELS_OUT {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "output").reduce((a, x) => a + (x.channels == "mono" ? 1 : 2), 0)}} #define NUM_ALL_CHANNELS_OUT {{=it.product.buses.filter(x => x.type == "audio" && x.direction == "output").reduce((a, x) => a + (x.channels == "mono" ? 1 : 2), 0)}}
#define NUM_MIDI_INPUTS {{=it.product.buses.filter(x => x.type == "midi" && x.direction == "input").length}} #define NUM_MIDI_INPUTS {{=it.product.buses.filter(x => x.type == "midi" && x.direction == "input").length}}
#define MIDI_BUS_IN {{=it.product.buses.findIndex(x => x.type == "midi" && x.direction == "input")}} #define MIDI_BUS_IN {{=it.product.buses.findIndex(x => x.type == "midi" && x.direction == "input")}}
#if NUM_AUDIO_BUSES_IN + NUM_AUDIO_BUSES_OUT > 0 #if NUM_AUDIO_BUSES_IN + NUM_AUDIO_BUSES_OUT > 0
static struct { static struct {
size_t index; size_t index;
char out; char out;
char optional; char optional;
char channels; char channels;
} audio_bus_data[NUM_AUDIO_BUSES_IN + NUM_AUDIO_BUSES_OUT] = { } audio_bus_data[NUM_AUDIO_BUSES_IN + NUM_AUDIO_BUSES_OUT] = {
{{~it.product.buses :b:i}} {{~it.product.buses :b:i}}
{{?b.type == "audio"}} {{?b.type == "audio"}}
{ {
/* .index = */ {{=i}}, /* .index = */ {{=i}},
/* .out = */ {{=b.direction == "output" ? 1 : 0}}, /* .out = */ {{=b.direction == "output" ? 1 : 0}},
/* .optional = */ {{=b.optional ? 1 : 0}}, /* .optional = */ {{=b.optional ? 1 : 0}},
/* .channels = */ {{=b.channels == "mono" ? 1 : 2}} /* .channels = */ {{=b.channels == "mono" ? 1 : 2}}
}, },
{{?}} {{?}}
{{~}} {{~}}
}; };
#endif #endif
#define PARAMETERS_N {{=it.product.parameters.length}} #define PARAMETERS_N {{=it.product.parameters.length}}
#if PARAMETERS_N > 0 #if PARAMETERS_N > 0
# define PARAM_BYPASS 1 # define PARAM_BYPASS 1
# define PARAM_TOGGLED (1<<1) # define PARAM_TOGGLED (1<<1)
# define PARAM_INTEGER (1<<2) # define PARAM_INTEGER (1<<2)
static struct { static struct {
char out; char out;
float def; float def;
float min; float min;
float max; float max;
uint32_t flags; uint32_t flags;
} param_data[PARAMETERS_N] = { } param_data[PARAMETERS_N] = {
{{~it.product.parameters :p}} {{~it.product.parameters :p}}
{ {
/* .out = */ {{=p.direction == "output" ? 1 : 0}}, /* .out = */ {{=p.direction == "output" ? 1 : 0}},
/* .def = */ {{=p.defaultValue.toExponential()}}, /* .def = */ {{=p.defaultValue.toExponential()}},
/* .min = */ {{=p.minimum.toExponential()}}f, /* .min = */ {{=p.minimum.toExponential()}}f,
/* .max = */ {{=p.maximum.toExponential()}}f, /* .max = */ {{=p.maximum.toExponential()}}f,
/* .flags = */ {{?p.isBypass}}PARAM_BYPASS{{??p.isLatency}}PARAM_INTEGER{{??}}0{{?p.toggled}} | PARAM_TOGGLED{{?}}{{?p.integer}} | PARAM_INTEGER{{?}}{{?}} /* .flags = */ {{?p.isBypass}}PARAM_BYPASS{{??p.isLatency}}PARAM_INTEGER{{??}}0{{?p.toggled}} | PARAM_TOGGLED{{?}}{{?p.integer}} | PARAM_INTEGER{{?}}{{?}}
}, },
{{~}} {{~}}
}; };
{{?it.product.parameters.find(x => x.direction == "output" && x.isCpumeter)}}
# define PARAM_OUT_CPU_INDEX {{=it.product.parameters.indexOf(it.product.parameters.find(x => x.direction == "output" && x.isCpumeter))}}
{{?}}
#endif #endif

View File

@ -22,10 +22,10 @@
#include <stdint.h> #include <stdint.h>
typedef struct { typedef struct {
void * handle; void *handle;
const char * format; const char *format;
const char * (*get_bindir)(void *handle); const char *(*get_bindir)(void *handle);
const char * (*get_datadir)(void *handle); const char *(*get_datadir)(void *handle);
} plugin_callbacks; } plugin_callbacks;
#include "data.h" #include "data.h"
@ -42,47 +42,47 @@ typedef struct {
#include "miniaudio.h" #include "miniaudio.h"
#define BLOCK_SIZE 32 #define BLOCK_SIZE 32
static ma_device device; static ma_device device;
static ma_device_config deviceConfig; static ma_device_config deviceConfig;
char device_inited = 0; char device_inited = 0;
static plugin instance; static plugin instance;
static void * mem; static void *mem;
#if NUM_NON_OPT_CHANNELS_IN > NUM_CHANNELS_IN #if NUM_NON_OPT_CHANNELS_IN > NUM_CHANNELS_IN
float zero[BLOCK_SIZE]; float zero[BLOCK_SIZE];
#endif #endif
#if NUM_CHANNELS_IN > 0 #if NUM_CHANNELS_IN > 0
float x_buf[NUM_CHANNELS_IN * BLOCK_SIZE]; float x_buf[NUM_CHANNELS_IN * BLOCK_SIZE];
float * x_in[NUM_CHANNELS_IN]; float *x_in[NUM_CHANNELS_IN];
#endif #endif
#if NUM_ALL_CHANNELS_IN > 0 #if NUM_ALL_CHANNELS_IN > 0
const float * x[NUM_ALL_CHANNELS_IN]; const float *x[NUM_ALL_CHANNELS_IN];
#else #else
const float ** x; const float **x;
#endif #endif
#if NUM_NON_OPT_CHANNELS_OUT > 0 #if NUM_NON_OPT_CHANNELS_OUT > 0
float y_buf[NUM_NON_OPT_CHANNELS_OUT * BLOCK_SIZE]; float y_buf[NUM_NON_OPT_CHANNELS_OUT * BLOCK_SIZE];
#endif #endif
#if NUM_CHANNELS_OUT > 0 #if NUM_CHANNELS_OUT > 0
float * y_out[NUM_CHANNELS_OUT]; float *y_out[NUM_CHANNELS_OUT];
#endif #endif
#if NUM_ALL_CHANNELS_OUT > 0 #if NUM_ALL_CHANNELS_OUT > 0
float * y[NUM_ALL_CHANNELS_OUT]; float *y[NUM_ALL_CHANNELS_OUT];
#else #else
float ** y; float **y;
#endif #endif
#if PARAMETERS_N > 0 #if PARAMETERS_N > 0
std::mutex mutex; std::mutex mutex;
float param_values[PARAMETERS_N]; float param_values[PARAMETERS_N];
float param_values_prev[PARAMETERS_N]; float param_values_prev[PARAMETERS_N];
#endif #endif
#if NUM_MIDI_INPUTS > 0 #if NUM_MIDI_INPUTS > 0
CFStringRef midiClientName = NULL; CFStringRef midiClientName = NULL;
MIDIClientRef midiClient = NULL; MIDIClientRef midiClient = NULL;
CFStringRef midiInputName = NULL; CFStringRef midiInputName = NULL;
MIDIPortRef midiPort = NULL; MIDIPortRef midiPort = NULL;
#define MIDIBUFFERLEN 1023 #define MIDIBUFFERLEN 1023
uint8_t midiBuffer[MIDIBUFFERLEN]; uint8_t midiBuffer[MIDIBUFFERLEN];
int midiBuffer_i = 0; int midiBuffer_i = 0;
#endif #endif
static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) { static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) {
@ -182,7 +182,7 @@ void (^midiReceiveBlock)(const MIDIEventList *evtlist, void *srcConnRefCon) = ^(
continue; continue;
mutex.lock(); mutex.lock();
if (midiBuffer_i < MIDIBUFFERLEN - 3) { if (midiBuffer_i < MIDIBUFFERLEN - 3) {
midiBuffer[midiBuffer_i ] = t[2]; midiBuffer[midiBuffer_i ] = t[2];
midiBuffer[midiBuffer_i + 1] = t[1]; midiBuffer[midiBuffer_i + 1] = t[1];
midiBuffer[midiBuffer_i + 2] = t[0]; midiBuffer[midiBuffer_i + 2] = t[0];
midiBuffer_i += 3; midiBuffer_i += 3;
@ -208,26 +208,26 @@ char audioStart() {
deviceConfig = ma_device_config_init(ma_device_type_playback); deviceConfig = ma_device_config_init(ma_device_type_playback);
#endif #endif
deviceConfig.periodSizeInFrames = BLOCK_SIZE; deviceConfig.periodSizeInFrames = BLOCK_SIZE;
deviceConfig.periods = 1; deviceConfig.periods = 1;
deviceConfig.performanceProfile = ma_performance_profile_low_latency; deviceConfig.performanceProfile = ma_performance_profile_low_latency;
deviceConfig.noPreSilencedOutputBuffer = 1; deviceConfig.noPreSilencedOutputBuffer = 1;
deviceConfig.noClip = 0; deviceConfig.noClip = 0;
deviceConfig.noDisableDenormals = 0; deviceConfig.noDisableDenormals = 0;
deviceConfig.noFixedSizedCallback = 1; deviceConfig.noFixedSizedCallback = 1;
deviceConfig.dataCallback = data_callback; deviceConfig.dataCallback = data_callback;
deviceConfig.capture.pDeviceID = NULL; deviceConfig.capture.pDeviceID = NULL;
deviceConfig.capture.format = ma_format_f32; deviceConfig.capture.format = ma_format_f32;
deviceConfig.capture.channels = NUM_CHANNELS_IN; deviceConfig.capture.channels = NUM_CHANNELS_IN;
deviceConfig.capture.shareMode = ma_share_mode_shared; deviceConfig.capture.shareMode = ma_share_mode_shared;
deviceConfig.playback.pDeviceID = NULL; deviceConfig.playback.pDeviceID = NULL;
deviceConfig.playback.format = ma_format_f32; deviceConfig.playback.format = ma_format_f32;
#if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0 #if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0
deviceConfig.playback.channels = NUM_CHANNELS_OUT; deviceConfig.playback.channels = NUM_CHANNELS_OUT;
#else #else
deviceConfig.playback.channels = 1; // Fake & muted deviceConfig.playback.channels = 1; // Fake & muted
#endif #endif
deviceConfig.playback.shareMode = ma_share_mode_shared; deviceConfig.playback.shareMode = ma_share_mode_shared;
if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS)
return false; return false;
@ -260,10 +260,10 @@ char audioStart() {
#endif #endif
plugin_callbacks cbs = { plugin_callbacks cbs = {
/* .handle = */ NULL, /* .handle = */ NULL,
/* .format = */ "ios", /* .format = */ "ios",
/* .get_bindir = */ NULL, /* .get_bindir = */ NULL,
/* .get_datadir = */ NULL /* .get_datadir = */ NULL
}; };
plugin_init(&instance, &cbs); plugin_init(&instance, &cbs);

View File

@ -19,19 +19,19 @@
*/ */
typedef struct plugin { typedef struct plugin {
float sample_rate; float sample_rate;
size_t delay_line_length; size_t delay_line_length;
float gain; float gain;
float delay; float delay;
float cutoff; float cutoff;
char bypass; char bypass;
float * delay_line; float *delay_line;
size_t delay_line_cur; size_t delay_line_cur;
float z1; float z1;
float cutoff_k; float cutoff_k;
float yz1; float yz1;
} plugin; } plugin;
static void plugin_init(plugin *instance, plugin_callbacks *cbs) { static void plugin_init(plugin *instance, plugin_callbacks *cbs) {