Compare commits

..

2 Commits

Author SHA1 Message Date
5d07c39170 vst3 cpu meter 2024-07-04 10:02:20 +02:00
ebf2a2052c vst3 indentation/alignment 2024-07-04 09:48:34 +02:00
3 changed files with 295 additions and 263 deletions

View File

@ -211,6 +211,10 @@ static struct {
{{~}} {{~}}
}; };
{{?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
#endif #endif

View File

@ -22,17 +22,17 @@
#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;
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);
void (*set_parameter)(void *handle, size_t index, float value); void (*set_parameter)(void *handle, size_t index, float value);
} plugin_ui_callbacks; } plugin_ui_callbacks;
@ -64,6 +64,10 @@ typedef struct {
#include <pmmintrin.h> #include <pmmintrin.h>
#endif #endif
#ifdef PARAM_OUT_CPU_INDEX
# include "fatica.h"
#endif
// COM in C doc: // COM in C doc:
// https://github.com/rubberduck-vba/Rubberduck/wiki/COM-in-plain-C // https://github.com/rubberduck-vba/Rubberduck/wiki/COM-in-plain-C
// https://devblogs.microsoft.com/oldnewthing/20040205-00/?p=40733 // https://devblogs.microsoft.com/oldnewthing/20040205-00/?p=40733
@ -193,21 +197,21 @@ static double parameterAdjust(int i, double v) {
} }
typedef struct pluginInstance { typedef struct pluginInstance {
Steinberg_Vst_IComponentVtbl * vtblIComponent; Steinberg_Vst_IComponentVtbl *vtblIComponent;
Steinberg_Vst_IAudioProcessorVtbl * vtblIAudioProcessor; Steinberg_Vst_IAudioProcessorVtbl *vtblIAudioProcessor;
Steinberg_Vst_IProcessContextRequirementsVtbl * vtblIProcessContextRequirements; Steinberg_Vst_IProcessContextRequirementsVtbl *vtblIProcessContextRequirements;
Steinberg_uint32 refs; Steinberg_uint32 refs;
Steinberg_FUnknown * context; Steinberg_FUnknown *context;
plugin p; plugin p;
float sampleRate; float sampleRate;
#if DATA_PRODUCT_PARAMETERS_N > 0 #if DATA_PRODUCT_PARAMETERS_N > 0
float parameters[DATA_PRODUCT_PARAMETERS_N]; float parameters[DATA_PRODUCT_PARAMETERS_N];
#endif #endif
#if DATA_PRODUCT_CHANNELS_AUDIO_INPUT_N > 0 #if DATA_PRODUCT_CHANNELS_AUDIO_INPUT_N > 0
const float * inputs[DATA_PRODUCT_CHANNELS_AUDIO_INPUT_N]; const float *inputs[DATA_PRODUCT_CHANNELS_AUDIO_INPUT_N];
#endif #endif
#if DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N > 0 #if DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N > 0
float * outputs[DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N]; float *outputs[DATA_PRODUCT_CHANNELS_AUDIO_OUTPUT_N];
#endif #endif
#if DATA_PRODUCT_BUSES_AUDIO_INPUT_N > 0 #if DATA_PRODUCT_BUSES_AUDIO_INPUT_N > 0
char inputsActive[DATA_PRODUCT_BUSES_AUDIO_INPUT_N]; char inputsActive[DATA_PRODUCT_BUSES_AUDIO_INPUT_N];
@ -221,7 +225,10 @@ typedef struct pluginInstance {
#if DATA_PRODUCT_BUSES_MIDI_OUTPUT_N > 0 #if DATA_PRODUCT_BUSES_MIDI_OUTPUT_N > 0
char midiOutputsActive[DATA_PRODUCT_BUSES_MIDI_OUTPUT_N]; char midiOutputsActive[DATA_PRODUCT_BUSES_MIDI_OUTPUT_N];
#endif #endif
void * mem; void *mem;
#ifdef PARAM_OUT_CPU_INDEX
float cpu_meter;
#endif
} pluginInstance; } pluginInstance;
static Steinberg_Vst_IComponentVtbl pluginVtblIComponent; static Steinberg_Vst_IComponentVtbl pluginVtblIComponent;
@ -320,6 +327,9 @@ static Steinberg_tresult pluginInitialize(void *thisInterface, struct Steinberg_
p->midiOutputsActive[i] = 0; p->midiOutputsActive[i] = 0;
#endif #endif
p->mem = NULL; p->mem = NULL;
#ifdef PARAM_OUT_CPU_INDEX
p->cpu_meter = 0.f;
#endif
return Steinberg_kResultOk; return Steinberg_kResultOk;
} }
@ -738,6 +748,10 @@ static void processParams(pluginInstance *p, struct Steinberg_Vst_ProcessData *d
static Steinberg_tresult pluginProcess(void* thisInterface, struct Steinberg_Vst_ProcessData* data) { static Steinberg_tresult pluginProcess(void* thisInterface, struct Steinberg_Vst_ProcessData* data) {
TRACE("plugin IAudioProcessor process\n"); TRACE("plugin IAudioProcessor process\n");
#ifdef PARAM_OUT_CPU_INDEX
const unsigned long long processTimeStart = fatica_time_process();
#endif
#if defined(__aarch64__) #if defined(__aarch64__)
uint64_t fpcr; uint64_t fpcr;
__asm__ __volatile__ ("mrs %0, fpcr" : "=r"(fpcr)); __asm__ __volatile__ ("mrs %0, fpcr" : "=r"(fpcr));
@ -813,7 +827,13 @@ static Steinberg_tresult pluginProcess(void* thisInterface, struct Steinberg_Vst
for (Steinberg_int32 i = 0; i < DATA_PRODUCT_PARAMETERS_N; i++) { for (Steinberg_int32 i = 0; i < DATA_PRODUCT_PARAMETERS_N; i++) {
if (!(parameterInfo[i].flags & Steinberg_Vst_ParameterInfo_ParameterFlags_kIsReadOnly)) if (!(parameterInfo[i].flags & Steinberg_Vst_ParameterInfo_ParameterFlags_kIsReadOnly))
continue; continue;
float v = plugin_get_parameter(&p->p, parameterData[i].index); float v;
# ifdef PARAM_OUT_CPU_INDEX
if (i == PARAM_OUT_CPU_INDEX)
v = p->cpu_meter;
else
# endif
v = plugin_get_parameter(&p->p, parameterData[i].index);
if (v == p->parameters[i]) if (v == p->parameters[i])
continue; continue;
p->parameters[i] = v; p->parameters[i] = v;
@ -837,6 +857,13 @@ static Steinberg_tresult pluginProcess(void* thisInterface, struct Steinberg_Vst
_MM_SET_DENORMALS_ZERO_MODE(denormals_zero_mode); _MM_SET_DENORMALS_ZERO_MODE(denormals_zero_mode);
#endif #endif
#ifdef PARAM_OUT_CPU_INDEX
const unsigned long long processTimeEnd = fatica_time_process();
const unsigned long long processTime100n = processTimeEnd - processTimeStart;
const double processTimeS = ((double) processTime100n) * 1.0e-7;
p->cpu_meter = p->cpu_meter * 0.9f + ((float) (processTimeS * p->sampleRate)) * 0.1f;
#endif
return Steinberg_kResultOk; return Steinberg_kResultOk;
} }
@ -900,19 +927,19 @@ static Steinberg_Vst_IProcessContextRequirementsVtbl pluginVtblIProcessContextRe
typedef struct plugView plugView; typedef struct plugView plugView;
typedef struct controller { typedef struct controller {
Steinberg_Vst_IEditControllerVtbl * vtblIEditController; Steinberg_Vst_IEditControllerVtbl *vtblIEditController;
Steinberg_Vst_IMidiMappingVtbl * vtblIMidiMapping; Steinberg_Vst_IMidiMappingVtbl *vtblIMidiMapping;
#ifdef DATA_UI #ifdef DATA_UI
//Steinberg_Vst_IConnectionPointVtbl * vtblIConnectionPoint; //Steinberg_Vst_IConnectionPointVtbl * vtblIConnectionPoint;
#endif #endif
Steinberg_uint32 refs; Steinberg_uint32 refs;
Steinberg_FUnknown * context; Steinberg_FUnknown *context;
#if DATA_PRODUCT_PARAMETERS_N + DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0 #if DATA_PRODUCT_PARAMETERS_N + DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0
double parameters[DATA_PRODUCT_PARAMETERS_N + 3 * DATA_PRODUCT_BUSES_MIDI_INPUT_N]; double parameters[DATA_PRODUCT_PARAMETERS_N + 3 * DATA_PRODUCT_BUSES_MIDI_INPUT_N];
#endif #endif
struct Steinberg_Vst_IComponentHandler * componentHandler; struct Steinberg_Vst_IComponentHandler *componentHandler;
#ifdef DATA_UI #ifdef DATA_UI
plugView ** views; plugView **views;
size_t viewsCount; size_t viewsCount;
#endif #endif
} controller; } controller;
@ -926,9 +953,9 @@ static Steinberg_Vst_IEditControllerVtbl controllerVtblIEditController;
# include <X11/Xlib.h> # include <X11/Xlib.h>
typedef struct { typedef struct {
Steinberg_ITimerHandlerVtbl * vtblITimerHandler; Steinberg_ITimerHandlerVtbl *vtblITimerHandler;
Steinberg_uint32 refs; Steinberg_uint32 refs;
void * data; void *data;
void (*cb)(void *data); void (*cb)(void *data);
} timerHandler; } timerHandler;
@ -998,15 +1025,15 @@ static Steinberg_ITimerHandlerVtbl timerHandlerVtblITimerHandler = {
# endif # endif
typedef struct plugView { typedef struct plugView {
Steinberg_IPlugViewVtbl * vtblIPlugView; Steinberg_IPlugViewVtbl *vtblIPlugView;
Steinberg_uint32 refs; Steinberg_uint32 refs;
Steinberg_IPlugFrame * frame; Steinberg_IPlugFrame *frame;
plugin_ui * ui; plugin_ui *ui;
controller * ctrl; controller *ctrl;
# ifdef __linux__ # ifdef __linux__
Steinberg_IRunLoop * runLoop; Steinberg_IRunLoop *runLoop;
timerHandler timer; timerHandler timer;
Display * display; Display *display;
# elif defined(__APPLE__) # elif defined(__APPLE__)
CFRunLoopTimerRef timer; CFRunLoopTimerRef timer;
# elif defined(_WIN32) || defined(__CYGWIN__) # elif defined(_WIN32) || defined(__CYGWIN__)
@ -1455,7 +1482,7 @@ static Steinberg_tresult controllerInitialize(void* thisInterface, struct Steinb
#endif #endif
#if DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0 #if DATA_PRODUCT_BUSES_MIDI_INPUT_N > 0
for (int i = DATA_PRODUCT_PARAMETERS_N; i < DATA_PRODUCT_PARAMETERS_N + 3 * DATA_PRODUCT_BUSES_MIDI_INPUT_N; i += 3) { for (int i = DATA_PRODUCT_PARAMETERS_N; i < DATA_PRODUCT_PARAMETERS_N + 3 * DATA_PRODUCT_BUSES_MIDI_INPUT_N; i += 3) {
c->parameters[i] = 0.0; c->parameters[i ] = 0.0;
c->parameters[i + 1] = 0.5; c->parameters[i + 1] = 0.5;
c->parameters[i + 2] = 0.0; c->parameters[i + 2] = 0.0;
} }

View File

@ -3,6 +3,7 @@
dir=`dirname $0` dir=`dirname $0`
$dir/../tibia $dir/product.json,$dir/company.json,$dir/vst3.json $dir/../templates/vst3 $dir/../out/vst3 $dir/../tibia $dir/product.json,$dir/company.json,$dir/vst3.json $dir/../templates/vst3 $dir/../out/vst3
$dir/../tibia $dir/product.json,$dir/company.json,$dir/vst3.json,$dir/vst3-make.json $dir/../templates/vst3-make $dir/../out/vst3 $dir/../tibia $dir/product.json,$dir/company.json,$dir/vst3.json,$dir/vst3-make.json $dir/../templates/vst3-make $dir/../out/vst3
cp $dir/../templates/common/* $dir/../out/vst3/src/
cp $dir/plugin.h $dir/plugin_ui.h $dir/../out/vst3/src cp $dir/plugin.h $dir/plugin_ui.h $dir/../out/vst3/src
$dir/../tibia $dir/product.json,$dir/company.json,$dir/lv2.json $dir/../templates/lv2 $dir/../out/lv2 $dir/../tibia $dir/product.json,$dir/company.json,$dir/lv2.json $dir/../templates/lv2 $dir/../out/lv2