From 3dd1a835011f1001a6d4cb19f0928e0e308b3cf4 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Mon, 5 Aug 2024 09:31:28 +0200 Subject: [PATCH 1/2] ios doc --- notes | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/notes b/notes index fb857f6..e6b5d04 100644 --- a/notes +++ b/notes @@ -5,18 +5,21 @@ company { web: not used cmd: not used android: not used + ios: not used url: VST3: PFactoryInfo.url LV2: manifest.ttl doap:maintainer rdfs:seeAlso web: not used cmd: not used android: not used + ios: not used email: VST3: PFactoryInfo.email LV2: manifest.ttl doap:maintainer foaf:mbox web: not used cmd: not used android: not used + ios: not used } product { @@ -26,24 +29,28 @@ product { web: web-demo and <h1> cmd: not used android: index.html <title>, AndroidManifest.xml <application> <activity> android:label + ios: index.html <title> version: VST3: PClassInfo{2,W}.version (first 3 numbers) LV2: not used web: not used cmd: not used android: not used + ios: not used buildVersion: VST3: PClassInfo{2,W}.version (last number) LV2: not used web: not used cmd: not used android: not used + ios: not used bundleName: VST3: plugin folder name, plugin .dll name, Info.plist LV2: plugin folder name, plugin .dll name, manifest.ttl plugin lv2:binary web: registerProcessor(), output file names cmd: executable file name android: .so/.apk filenames + ios: xcodegen name and target name, xcodeproj filename buses: [ { name: @@ -53,6 +60,7 @@ product { web: not used cmd: not used android: not used + ios: not used shortName: bus short name string, required VST3: not used @@ -60,6 +68,7 @@ product { web: not used cmd: not used android: not used + ios: not used id: bus unique id string, required VST3; not used @@ -67,6 +76,7 @@ product { web: not used cmd: not used android: not used + ios: not used direction: "input" or "output", required VST3: BusInfo flags - lots of implications @@ -74,6 +84,7 @@ product { web: AudioWorkletNode.{numberOfInputs,numberOfOutputs,outputChannelCount} - lots of implications cmd: lots of places android: lots of places + ios: lots of places type: "audio" or "midi", required VST3: BusInfo mediaType, ParameterInfo (channel pressure, pitch bend params) - lots of implications @@ -81,6 +92,7 @@ product { web: AudioWorkletNode.{numberOfInputs,numberOfOutputs,outputChannelCount} - lots of implications cmd: lots of places android: lots of places + ios: lots of places channels: "mono" or "stereo", audio type only, required VST3: BusInfo channelCount, plugin get/set bus arrangements @@ -88,6 +100,7 @@ product { web: AudioWorkletNode.outputChannelCount - lots of implications cmd: lots of places android: lots of places + ios: lots of places sidechain: bus is not part of main audio path (sidechain)? boolean, default false VST3: BusInfo busType @@ -102,6 +115,7 @@ product { web: web-demo choice of audio I/O buses cmd: choice of audio I/O buses android: choice of audio I/O buses + ios: choice of audio I/O buses control: bus is the "primary control channel" (send cmds, receive responses)? boolean, midi type only, default false VST3: not used @@ -109,6 +123,7 @@ product { web: not used cmd: not used android: not used + ios: not used optional: bus is optionally connected? boolean, default false VST3: BusInfo flags, plugin initialize, activate bus, set active @@ -116,6 +131,7 @@ product { web: not used cmd: whether to pass NULLs if not chosen audio I/O buses android: whether to pass NULLs if not chosen audio I/O buses + ios: whether to pass NULLs if not chosen audio I/O buses } ] parameters: [ @@ -127,6 +143,7 @@ product { web: AudioWorkletProcessor.parameterDescriptors, web-demo <label> cmd: not used android: index.html <label> + ios: index.html <label> shortName: parameter short name string, required VST3: ParameterInfo shortTitle @@ -134,6 +151,7 @@ product { web: not used cmd: not used android: not used + ios: not used id: parameter unique id string, required VST3; not used @@ -141,6 +159,7 @@ product { web: not used cmd: command line parameter name etc. android: not used + ios: not used direction: "input" or "output", required VST3: ParameterInfo flags - lots of implications @@ -148,6 +167,7 @@ product { web: AudioWorkletProcessor.parameterDescriptors, web-demo <range> readonly/input listener - lots of implications cmd: lots of places android: lots of places + ios: lots of places isBypass: parameter is bypass/enabled? boolean - lots of implications, default false VST3: ParameterInfo, controller get/set parameter/state @@ -155,6 +175,7 @@ product { web: AudoWorkletProcessor.process(), web-demo <range> min/max/step cmd: set parameter android: JNI set parameter, index.html <range> min/max/step + ios: native set parameter, index.html <range> min/max/step isLatency: parameter is latency output? boolean - lots of implications, default false VST3: TBD @@ -162,6 +183,7 @@ product { web: not (yet) used cmd: not (yet) used android: not (yet) used + ios: not (yet) used defaultValue: default value, number, mapped, required for non-bypass VST3: ParameterInfo defaultNormalizedValue, controller initialize @@ -169,6 +191,7 @@ product { web: AudioWorkletProcessor.parameterDescriptors, processor_new(), web-demo initial <range> value and value <span> innerText cmd: default parameter value android: JNI set parameter initial value, index.html initial <range> value + ios: native set parameter initial value, index.html initial <range> value minimum: minimum value, number, mapped, required for non-bypass VST3: ParameterInfo stepCount, defaultNormalizedValue, controller get/set parameter (value clamped) @@ -176,6 +199,7 @@ product { web: AudioWorkletProcessor.parameterDescriptors, AudioWorkletProcessor.process() (value clamped), web-demo <range> mapping cmd: set parameter (value clamped) android: JNI set parameter (value clamped), index.html <range> mapping + ios: native set parameter (value clamped), index.html <range> mapping maximum: maximum value, number, mapped, required for non-bypass VST3: ParameterInfo stepCount, defaultNormalizedValue, controller get/set parameter (value clamped) @@ -183,6 +207,7 @@ product { web: AudioWorkletProcessor.parameterDescriptors, AudioWorkletProcessor.process() (value clamped), web-demo <range> mapping cmd: set parameter (value clamped) android: JNI set parameter (value clamped), index.html <range> mapping + ios: native set parameter (value clamped), index.html <range> mapping toggled: parameter is on/off? boolean, default false VST3: ParameterInfo stepCount, controller set parameter/state @@ -190,6 +215,7 @@ product { web: AudoWorkletProcessor.process(), web-demo <range> min/max/step cmd: set parameter android: JNI set parameter, index.html <range> min/max/step + ios: native set parameter, index.html <range> min/max/step optional: parameter is optionally connected? boolean, default false VST3: not used @@ -197,6 +223,7 @@ product { web: not used cmd: not used android: not used + ios: not used integer: parameter values are integers? boolean, default false VST3: ParameterInfo stepCount, controller set parameter/state @@ -204,6 +231,7 @@ product { web: AudoWorkletProcessor.process(), web-demo <range> step cmd: set parameter android: JNI set parameter, index.html <range> step + ios: native set parameter, index.html <range> step scalePoints: { "label1": value1, "label2", value2, ... } labeled values, default none @@ -212,6 +240,7 @@ product { web: not (yet) used cmd: not (yet) used android: not (yet) used + ios: not (yet) used list: parameter is a list (using scalePoints values)? default false VST3: TBD (+approx to closest?) @@ -219,6 +248,7 @@ product { web: TBD (approx to closest? dropdown? both?) cmd: not (yet) used android: not (yet) used + ios: not (yet) used unit: unit of measure (from predefined list, see tibia-index.js), default "" VST3: ParameterInfo units @@ -226,6 +256,7 @@ product { web: web-demo value <span> innerText cmd: not (yet) used android: not (yet) used + ios: not (yet) used map: "linear" vs "logarithmic" VST3: many places (requires libm) @@ -233,6 +264,7 @@ product { web: web-demo <range> values cmd: not used android: index.html <range> values + ios: index.html <range> values } ] } From ed187c94dd75fc9d83c40781418a08e02d633411 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo <stefano.dangelo@orastron.com> Date: Mon, 26 Aug 2024 17:29:35 +0200 Subject: [PATCH 2/2] plugin api in common template and plugin_parameter enum --- templates/android/src/jni.cpp | 8 +---- templates/cmd/src/main.c | 8 +---- templates/common/src/plugin_api.h | 49 +++++++++++++++++++++++++++++++ templates/common/tibia-index.js | 26 ++++++++++++++++ templates/daisy-seed/src/main.cpp | 8 +---- templates/ios/src/native.mm | 8 +---- templates/lv2/src/lv2.c | 18 +----------- templates/vst3/src/vst3.c | 18 +----------- templates/web/src/processor.c | 8 +---- test/plugin.h | 8 ++--- test/run.sh | 7 +++++ 11 files changed, 93 insertions(+), 73 deletions(-) create mode 100644 templates/common/src/plugin_api.h create mode 100644 templates/common/tibia-index.js diff --git a/templates/android/src/jni.cpp b/templates/android/src/jni.cpp index f935597..a65dfa5 100644 --- a/templates/android/src/jni.cpp +++ b/templates/android/src/jni.cpp @@ -21,14 +21,8 @@ #include <stdlib.h> #include <stdint.h> -typedef struct { - void * handle; - const char * format; - const char * (*get_bindir)(void *handle); - const char * (*get_datadir)(void *handle); -} plugin_callbacks; - #include "data.h" +#include "plugin_api.h" #include "plugin.h" #include <string.h> diff --git a/templates/cmd/src/main.c b/templates/cmd/src/main.c index 97a9ed1..6f598f2 100644 --- a/templates/cmd/src/main.c +++ b/templates/cmd/src/main.c @@ -21,14 +21,8 @@ #include <stdlib.h> #include <stdint.h> -typedef struct { - void * handle; - const char * format; - const char * (*get_bindir)(void *handle); - const char * (*get_datadir)(void *handle); -} plugin_callbacks; - #include "data.h" +#include "plugin_api.h" #include "plugin.h" #include <stdio.h> diff --git a/templates/common/src/plugin_api.h b/templates/common/src/plugin_api.h new file mode 100644 index 0000000..dcd696b --- /dev/null +++ b/templates/common/src/plugin_api.h @@ -0,0 +1,49 @@ +/* + * Tibia + * + * Copyright (C) 2024 Orastron Srl unipersonale + * + * Tibia is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * Tibia is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tibia. If not, see <http://www.gnu.org/licenses/>. + * + * File author: Stefano D'Angelo + */ + +#ifndef PLUGIN_API_H +#define PLUGIN_API_H + +typedef struct { + void * handle; + const char * format; + const char * (*get_bindir)(void *handle); + const char * (*get_datadir)(void *handle); +} plugin_callbacks; + +typedef struct { + void * handle; + const char * format; + const char * (*get_bindir)(void *handle); + const char * (*get_datadir)(void *handle); + void (*set_parameter_begin)(void *handle, size_t index); + void (*set_parameter)(void *handle, size_t index, float value); + void (*set_parameter_end)(void *handle, size_t index); +} plugin_ui_callbacks; + +{{?it.product.parameters.length > 0}} +enum { + {{~it.product.parameters :p}} + plugin_parameter_{{=p.id}}, + {{~}} +}; +{{?}} + +#endif diff --git a/templates/common/tibia-index.js b/templates/common/tibia-index.js new file mode 100644 index 0000000..1dfd137 --- /dev/null +++ b/templates/common/tibia-index.js @@ -0,0 +1,26 @@ +/* + * Tibia + * + * Copyright (C) 2024 Orastron Srl unipersonale + * + * Tibia is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * Tibia is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Tibia. If not, see <http://www.gnu.org/licenses/>. + * + * File author: Stefano D'Angelo + */ + +var path = require("path"); +var sep = path.sep; + +module.exports = function (data, api) { + api.generateFileFromTemplateFile(`src${sep}plugin_api.h`, `src${sep}plugin_api.h`, data); +}; diff --git a/templates/daisy-seed/src/main.cpp b/templates/daisy-seed/src/main.cpp index 7e218a7..43253b3 100644 --- a/templates/daisy-seed/src/main.cpp +++ b/templates/daisy-seed/src/main.cpp @@ -21,14 +21,8 @@ #include <stdlib.h> #include <stdint.h> -typedef struct { - void * handle; - const char * format; - const char * (*get_bindir)(void *handle); - const char * (*get_datadir)(void *handle); -} plugin_callbacks; - #include "data.h" +#include "plugin_api.h" #include "plugin.h" #include <string.h> diff --git a/templates/ios/src/native.mm b/templates/ios/src/native.mm index 509328f..b7c1ebe 100644 --- a/templates/ios/src/native.mm +++ b/templates/ios/src/native.mm @@ -21,14 +21,8 @@ #include <stdlib.h> #include <stdint.h> -typedef struct { - void * handle; - const char * format; - const char * (*get_bindir)(void *handle); - const char * (*get_datadir)(void *handle); -} plugin_callbacks; - #include "data.h" +#include "plugin_api.h" #include "plugin.h" #if PARAMETERS_N > 0 #include <algorithm> diff --git a/templates/lv2/src/lv2.c b/templates/lv2/src/lv2.c index 03d46d4..787c25b 100644 --- a/templates/lv2/src/lv2.c +++ b/templates/lv2/src/lv2.c @@ -21,24 +21,8 @@ #include <stdlib.h> #include <stdint.h> -typedef struct { - void * handle; - const char * format; - const char * (*get_bindir)(void *handle); - const char * (*get_datadir)(void *handle); -} plugin_callbacks; - -typedef struct { - void * handle; - const char * format; - const char * (*get_bindir)(void *handle); - const char * (*get_datadir)(void *handle); - void (*set_parameter_begin)(void *handle, size_t index); - void (*set_parameter)(void *handle, size_t index, float value); - void (*set_parameter_end)(void *handle, size_t index); -} plugin_ui_callbacks; - #include "data.h" +#include "plugin_api.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-function" #include "plugin.h" diff --git a/templates/vst3/src/vst3.c b/templates/vst3/src/vst3.c index 9e8d180..f695277 100644 --- a/templates/vst3/src/vst3.c +++ b/templates/vst3/src/vst3.c @@ -21,29 +21,13 @@ #include <stdlib.h> #include <stdint.h> -typedef struct { - void * handle; - const char * format; - const char * (*get_bindir)(void *handle); - const char * (*get_datadir)(void *handle); -} plugin_callbacks; - -typedef struct { - void * handle; - const char * format; - const char * (*get_bindir)(void *handle); - const char * (*get_datadir)(void *handle); - void (*set_parameter_begin)(void *handle, size_t index); - void (*set_parameter)(void *handle, size_t index, float value); - void (*set_parameter_end)(void *handle, size_t index); -} plugin_ui_callbacks; - #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" #include "vst3_c_api.h" #pragma GCC diagnostic pop #include "data.h" +#include "plugin_api.h" #include "plugin.h" #ifdef DATA_UI # include "plugin_ui.h" diff --git a/templates/web/src/processor.c b/templates/web/src/processor.c index e658695..a559be3 100644 --- a/templates/web/src/processor.c +++ b/templates/web/src/processor.c @@ -21,14 +21,8 @@ #include <stddef.h> #include <stdint.h> -typedef struct { - void * handle; - const char * format; - const char * (*get_bindir)(void *handle); - const char * (*get_datadir)(void *handle); -} plugin_callbacks; - #include "data.h" +#include "plugin_api.h" #include "plugin.h" #include "string.h" diff --git a/test/plugin.h b/test/plugin.h index ffbbb13..56adce4 100644 --- a/test/plugin.h +++ b/test/plugin.h @@ -68,17 +68,17 @@ static void plugin_reset(plugin *instance) { static void plugin_set_parameter(plugin *instance, size_t index, float value) { switch (index) { - case 0: + case plugin_parameter_gain: //approx instance->gain = powf(10.f, 0.05f * value); instance->gain = ((2.6039890429412597e-4f * value + 0.032131027163547855f) * value + 1.f) / ((0.0012705124328080768f * value - 0.0666763481312185f) * value + 1.f); break; - case 1: + case plugin_parameter_delay: instance->delay = 0.001f * value; break; - case 2: + case plugin_parameter_cutoff: instance->cutoff = value; break; - case 3: + case plugin_parameter_bypass: instance->bypass = value >= 0.5f; break; } diff --git a/test/run.sh b/test/run.sh index 50f3173..4b3eeb8 100755 --- a/test/run.sh +++ b/test/run.sh @@ -1,32 +1,39 @@ #!/bin/sh dir=`dirname $0` +$dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/common $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 cp $dir/plugin.h $dir/plugin_ui.h $dir/../out/vst3/src +$dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/common $dir/../out/lv2 $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/lv2-make.json $dir/../templates/lv2-make $dir/../out/lv2 cp $dir/plugin.h $dir/plugin_ui.h $dir/../out/lv2/src +$dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/common $dir/../out/web $dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/web $dir/../out/web $dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/web-make $dir/../out/web $dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/web-demo $dir/../out/web cp $dir/plugin.h $dir/../out/web/src +$dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/common $dir/../out/android $dir/../tibia $dir/product.json,$dir/company.json,$dir/android.json $dir/../templates/android $dir/../out/android $dir/../tibia $dir/product.json,$dir/company.json,$dir/android.json,$dir/android-make.json $dir/../templates/android-make $dir/../out/android cp $dir/keystore.jks $dir/../out/android cp $dir/plugin.h $dir/../out/android/src +$dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/common $dir/../out/ios $dir/../tibia $dir/product.json,$dir/company.json,$dir/ios.json $dir/../templates/ios $dir/../out/ios $dir/../tibia $dir/product.json,$dir/company.json,$dir/ios.json,$dir/ios-make.json $dir/../templates/ios-make $dir/../out/ios cp $dir/plugin.h $dir/../out/ios/src +$dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/common $dir/../out/cmd $dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/cmd $dir/../out/cmd $dir/../tibia $dir/product.json,$dir/company.json,$dir/cmd-make.json $dir/../templates/cmd-make $dir/../out/cmd cp $dir/plugin.h $dir/../out/cmd/src +$dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/common $dir/../out/daisy-seed $dir/../tibia $dir/product.json,$dir/company.json,$dir/daisy-seed.json $dir/../templates/daisy-seed $dir/../out/daisy-seed $dir/../tibia $dir/product.json,$dir/company.json,$dir/daisy-seed.json,$dir/daisy-seed-make.json $dir/../templates/daisy-seed-make $dir/../out/daisy-seed cp $dir/plugin.h $dir/../out/daisy-seed/src