Merge remote-tracking branch 'origin/main' into cpumeter

This commit is contained in:
Paolo Marrone 2024-08-29 16:01:47 +02:00
commit c0106cccd8
12 changed files with 415 additions and 462 deletions

63
notes
View File

@ -4,22 +4,22 @@ company {
LV2: manifest.ttl doap:maintainer foaf:name LV2: manifest.ttl doap:maintainer foaf:name
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
url: url:
VST3: PFactoryInfo.url VST3: PFactoryInfo.url
LV2: manifest.ttl doap:maintainer rdfs:seeAlso LV2: manifest.ttl doap:maintainer rdfs:seeAlso
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
email: email:
VST3: PFactoryInfo.email VST3: PFactoryInfo.email
LV2: manifest.ttl doap:maintainer foaf:mbox LV2: manifest.ttl doap:maintainer foaf:mbox
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
} }
product { product {
@ -28,29 +28,29 @@ product {
LV2: manifest.ttl plugin doap:name LV2: manifest.ttl plugin doap:name
web: web-demo <title> and <h1> web: web-demo <title> and <h1>
cmd: not used cmd: not used
ios: index.html <title>
android: index.html <title>, AndroidManifest.xml <application> <activity> android:label android: index.html <title>, AndroidManifest.xml <application> <activity> android:label
ios: index.html <title>
version: version:
VST3: PClassInfo{2,W}.version (first 3 numbers) VST3: PClassInfo{2,W}.version (first 3 numbers)
LV2: not used LV2: not used
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
buildVersion: buildVersion:
VST3: PClassInfo{2,W}.version (last number) VST3: PClassInfo{2,W}.version (last number)
LV2: not used LV2: not used
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
bundleName: bundleName:
VST3: plugin folder name, plugin .dll name, Info.plist VST3: plugin folder name, plugin .dll name, Info.plist
LV2: plugin folder name, plugin .dll name, manifest.ttl plugin lv2:binary LV2: plugin folder name, plugin .dll name, manifest.ttl plugin lv2:binary
web: registerProcessor(), output file names web: registerProcessor(), output file names
cmd: executable file name cmd: executable file name
ios: project.yml name/target, vars.mk BUNDLE_NAME
android: .so/.apk filenames android: .so/.apk filenames
ios: xcodegen name and target name, xcodeproj filename
buses: [ buses: [
{ {
name: name:
@ -59,24 +59,24 @@ product {
LV2: manifest.ttl lv2:port lv2:name LV2: manifest.ttl lv2:port lv2:name
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
shortName: shortName:
bus short name string, required bus short name string, required
VST3: not used VST3: not used
LV2: manifest.ttl lv2:port lv2:shortName LV2: manifest.ttl lv2:port lv2:shortName
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
id: id:
bus unique id string, required bus unique id string, required
VST3; not used VST3; not used
LV2: manifest.ttl lv2:port lv2:symbol (resulting ports can have _l or _r appended) LV2: manifest.ttl lv2:port lv2:symbol (resulting ports can have _l or _r appended)
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
direction: direction:
"input" or "output", required "input" or "output", required
VST3: BusInfo flags - lots of implications VST3: BusInfo flags - lots of implications
@ -115,24 +115,24 @@ product {
LV2: manifest.ttl lv2:port a lv2:CVPort LV2: manifest.ttl lv2:port a lv2:CVPort
web: web-demo choice of audio I/O buses web: web-demo choice of audio I/O buses
cmd: choice of audio I/O buses cmd: choice of audio I/O buses
ios: choice of audio I/O buses
android: choice of audio I/O buses android: choice of audio I/O buses
ios: choice of audio I/O buses
control: control:
bus is the "primary control channel" (send cmds, receive responses)? boolean, midi type only, default false bus is the "primary control channel" (send cmds, receive responses)? boolean, midi type only, default false
VST3: not used VST3: not used
LV2: manifest.ttl lv2:port lv2:designation lv2:control LV2: manifest.ttl lv2:port lv2:designation lv2:control
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
optional: optional:
bus is optionally connected? boolean, default false bus is optionally connected? boolean, default false
VST3: BusInfo flags, plugin initialize, activate bus, set active VST3: BusInfo flags, plugin initialize, activate bus, set active
LV2: manifest.ttl lv2:port lv2:portProperty lv2:connectionOptional LV2: manifest.ttl lv2:port lv2:portProperty lv2:connectionOptional
web: not used web: not used
cmd: whether to pass NULLs if not chosen audio I/O buses cmd: whether to pass NULLs if not chosen audio I/O buses
ios: whether to pass NULLs if not chosen audio I/O buses
android: 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: [ parameters: [
@ -143,24 +143,24 @@ product {
LV2: manifest.ttl lv2:port lv2:name LV2: manifest.ttl lv2:port lv2:name
web: AudioWorkletProcessor.parameterDescriptors, web-demo <label> web: AudioWorkletProcessor.parameterDescriptors, web-demo <label>
cmd: not used cmd: not used
ios: index.html
android: index.html <label> android: index.html <label>
ios: index.html <label>
shortName: shortName:
parameter short name string, required parameter short name string, required
VST3: ParameterInfo shortTitle VST3: ParameterInfo shortTitle
LV2: manifest.ttl lv2:port lv2:shortName LV2: manifest.ttl lv2:port lv2:shortName
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
id: id:
parameter unique id string, required parameter unique id string, required
VST3; not used VST3; not used
LV2: manifest.ttl lv2:port lv2:symbol (bypass ports used "enabled") LV2: manifest.ttl lv2:port lv2:symbol (bypass ports used "enabled")
web: not used web: not used
cmd: command line parameter name etc. cmd: command line parameter name etc.
ios: not used
android: not used android: not used
ios: not used
direction: direction:
"input" or "output", required "input" or "output", required
VST3: ParameterInfo flags - lots of implications VST3: ParameterInfo flags - lots of implications
@ -175,24 +175,16 @@ product {
LV2: manifest.ttl lv2:port, run() (set parameter) LV2: manifest.ttl lv2:port, run() (set parameter)
web: AudoWorkletProcessor.process(), web-demo <range> min/max/step web: AudoWorkletProcessor.process(), web-demo <range> min/max/step
cmd: set parameter cmd: set parameter
ios: native.mm set parameter, index.html <range> min/max/step
android: JNI set parameter, index.html <range> min/max/step android: JNI set parameter, index.html <range> min/max/step
ios: native.mm set parameter, index.html <range> min/max/step
isLatency: isLatency:
parameter is latency output? boolean - lots of implications, default false parameter is latency output? boolean - lots of implications, default false
VST3: TBD VST3: TBD
LV2: manifest.ttl lv2:port, TBD round output value LV2: manifest.ttl lv2:port, TBD round output value
web: not (yet) used web: not (yet) used
cmd: not (yet) used cmd: not (yet) used
ios: not used
android: not (yet) used android: not (yet) used
isCpumeter: ios: not (yet) used
parameter is output cpu meter? boolean. It must be an output parameter. It is handled within the wrappers, and not by the plugin user code
VST3: data.h, vst3.c
LV2: data.h, lv2.c
web: processor.js
cmd: TODO
ios: data.h native.mm
android: data.h jni.cpp
defaultValue: defaultValue:
default value, number, mapped, required for non-bypass default value, number, mapped, required for non-bypass
VST3: ParameterInfo defaultNormalizedValue, controller initialize VST3: ParameterInfo defaultNormalizedValue, controller initialize
@ -201,46 +193,47 @@ product {
cmd: default parameter value cmd: default parameter value
ios: native.mm set parameter initial value, index.html initial <range> value ios: native.mm set parameter initial value, index.html initial <range> value
android: JNI set parameter initial value, index.html initial <range> 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:
minimum value, number, mapped, required for non-bypass minimum value, number, mapped, required for non-bypass
VST3: ParameterInfo stepCount, defaultNormalizedValue, controller get/set parameter (value clamped) VST3: ParameterInfo stepCount, defaultNormalizedValue, controller get/set parameter (value clamped)
LV2: manifest.ttl lv2:port lv2:minimum, run() (set parameter, value clamped) LV2: manifest.ttl lv2:port lv2:minimum, run() (set parameter, value clamped)
web: AudioWorkletProcessor.parameterDescriptors, AudioWorkletProcessor.process() (value clamped), web-demo <range> mapping web: AudioWorkletProcessor.parameterDescriptors, AudioWorkletProcessor.process() (value clamped), web-demo <range> mapping
cmd: set parameter (value clamped) cmd: set parameter (value clamped)
ios: native.mm set parameter (value clamped), index.html <range> mapping
android: JNI set parameter (value clamped), index.html <range> mapping android: JNI set parameter (value clamped), index.html <range> mapping
ios: native set parameter (value clamped), index.html <range> mapping
maximum: maximum:
maximum value, number, mapped, required for non-bypass maximum value, number, mapped, required for non-bypass
VST3: ParameterInfo stepCount, defaultNormalizedValue, controller get/set parameter (value clamped) VST3: ParameterInfo stepCount, defaultNormalizedValue, controller get/set parameter (value clamped)
LV2: manifest.ttl lv2:port lv2:maximum, run() (set parameter, value clamped) LV2: manifest.ttl lv2:port lv2:maximum, run() (set parameter, value clamped)
web: AudioWorkletProcessor.parameterDescriptors, AudioWorkletProcessor.process() (value clamped), web-demo <range> mapping web: AudioWorkletProcessor.parameterDescriptors, AudioWorkletProcessor.process() (value clamped), web-demo <range> mapping
cmd: set parameter (value clamped) cmd: set parameter (value clamped)
ios: native.mm set parameter (value clamped), index.html <range> mapping
android: JNI set parameter (value clamped), index.html <range> mapping android: JNI set parameter (value clamped), index.html <range> mapping
ios: native set parameter (value clamped), index.html <range> mapping
toggled: toggled:
parameter is on/off? boolean, default false parameter is on/off? boolean, default false
VST3: ParameterInfo stepCount, controller set parameter/state VST3: ParameterInfo stepCount, controller set parameter/state
LV2: manifest.ttl lv2:port lv2:portProperty lv2:toggled, run() (set parameter) LV2: manifest.ttl lv2:port lv2:portProperty lv2:toggled, run() (set parameter)
web: AudoWorkletProcessor.process(), web-demo <range> min/max/step web: AudoWorkletProcessor.process(), web-demo <range> min/max/step
cmd: set parameter cmd: set parameter
ios: native.mm set parameter, index.html <range> min/max/step
android: JNI set parameter, index.html <range> min/max/step android: JNI set parameter, index.html <range> min/max/step
ios: native set parameter, index.html <range> min/max/step
optional: optional:
parameter is optionally connected? boolean, default false parameter is optionally connected? boolean, default false
VST3: not used VST3: not used
LV2: manifest.ttl lv2:port lv2:portProperty lv2:connectionOptional LV2: manifest.ttl lv2:port lv2:portProperty lv2:connectionOptional
web: not used web: not used
cmd: not used cmd: not used
ios: not used
android: not used android: not used
ios: not used
integer: integer:
parameter values are integers? boolean, default false parameter values are integers? boolean, default false
VST3: ParameterInfo stepCount, controller set parameter/state VST3: ParameterInfo stepCount, controller set parameter/state
LV2: manifest.ttl lv2:port lv2:portProperty lv2:integer, run() (set parameter) LV2: manifest.ttl lv2:port lv2:portProperty lv2:integer, run() (set parameter)
web: AudoWorkletProcessor.process(), web-demo <range> step web: AudoWorkletProcessor.process(), web-demo <range> step
cmd: set parameter cmd: set parameter
ios: native.mm set parameter, index.html <range> step
android: JNI set parameter, index.html <range> step android: JNI set parameter, index.html <range> step
ios: native set parameter, index.html <range> step
scalePoints: scalePoints:
{ "label1": value1, "label2", value2, ... } { "label1": value1, "label2", value2, ... }
labeled values, default none labeled values, default none
@ -248,32 +241,32 @@ product {
LV2: manifest.ttl lv2:port lv2:scalePoint LV2: manifest.ttl lv2:port lv2:scalePoint
web: not (yet) used web: not (yet) used
cmd: not (yet) used cmd: not (yet) used
ios: not (yet) used
android: not (yet) used android: not (yet) used
ios: not (yet) used
list: list:
parameter is a list (using scalePoints values)? default false parameter is a list (using scalePoints values)? default false
VST3: TBD (+approx to closest?) VST3: TBD (+approx to closest?)
LV2: manifest.ttl lv2:port lv2:enumeration - run() (set parameter) TBD? LV2: manifest.ttl lv2:port lv2:enumeration - run() (set parameter) TBD?
web: TBD (approx to closest? dropdown? both?) web: TBD (approx to closest? dropdown? both?)
cmd: not (yet) used cmd: not (yet) used
ios: not (yet) used
android: not (yet) used android: not (yet) used
ios: not (yet) used
unit: unit:
unit of measure (from predefined list, see tibia-index.js), default "" unit of measure (from predefined list, see tibia-index.js), default ""
VST3: ParameterInfo units VST3: ParameterInfo units
LV2: manifest.ttl lv2:port units:unit LV2: manifest.ttl lv2:port units:unit
web: web-demo value <span> innerText web: web-demo value <span> innerText
cmd: not (yet) used cmd: not (yet) used
ios: not (yet) used
android: not (yet) used android: not (yet) used
ios: not (yet) used
map: map:
"linear" vs "logarithmic" "linear" vs "logarithmic"
VST3: many places (requires libm) VST3: many places (requires libm)
LV2: manifest.ttl lv2:port lv2:portProperty pprops:logarithmic LV2: manifest.ttl lv2:port lv2:portProperty pprops:logarithmic
web: web-demo <range> values web: web-demo <range> values
cmd: not used cmd: not used
ios: index.html <range> values
android: index.html <range> values android: index.html <range> values
ios: index.html <range> values
} }
] ]
} }

View File

@ -21,9 +21,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include "callbacks.h"
#include "data.h" #include "data.h"
#include "plugin_api.h"
#include "plugin.h" #include "plugin.h"
#include <string.h> #include <string.h>
@ -47,11 +46,8 @@
#if NUM_MIDI_INPUTS > 0 #if NUM_MIDI_INPUTS > 0
# include <vector> # include <vector>
# include <amidi/AMidi.h>
#endif
#ifdef PARAM_OUT_CPU_INDEX # include <amidi/AMidi.h>
# include "fatica.h"
#endif #endif
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
@ -100,18 +96,10 @@ std::vector<PortData> midiPorts;
# define MIDI_BUFFER_SIZE 1024 # define MIDI_BUFFER_SIZE 1024
uint8_t midiBuffer[MIDI_BUFFER_SIZE]; uint8_t midiBuffer[MIDI_BUFFER_SIZE];
#endif #endif
#ifdef PARAM_OUT_CPU_INDEX
float cpu_meter = 0.f;
float sample_rate = 1.f;
#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) {
(void)pDevice; (void)pDevice;
#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));
@ -128,15 +116,8 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
if (mutex.try_lock()) { if (mutex.try_lock()) {
# if PARAMETERS_N > 0 # if PARAMETERS_N > 0
for (size_t i = 0; i < PARAMETERS_N; i++) { for (size_t i = 0; i < PARAMETERS_N; i++) {
if (param_data[i].out) { if (param_data[i].out)
# ifdef PARAM_OUT_CPU_INDEX
if (i == PARAM_OUT_CPU_INDEX) {
param_values_prev[i] = param_values[i] = cpu_meter;
continue;
}
# endif
param_values_prev[i] = param_values[i] = plugin_get_parameter(&instance, i); param_values_prev[i] = param_values[i] = plugin_get_parameter(&instance, i);
}
else if (param_values_prev[i] != param_values[i]) { else if (param_values_prev[i] != param_values[i]) {
plugin_set_parameter(&instance, i, param_values[i]); plugin_set_parameter(&instance, i, param_values[i]);
param_values_prev[i] = param_values[i]; param_values_prev[i] = param_values[i];
@ -201,13 +182,6 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
_MM_SET_FLUSH_ZERO_MODE(flush_zero_mode); _MM_SET_FLUSH_ZERO_MODE(flush_zero_mode);
_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;
cpu_meter = cpu_meter * 0.9f + ((float) (processTimeS * sample_rate)) * 0.1f;
#endif
} }
extern "C" extern "C"
@ -269,10 +243,6 @@ JNI_FUNC(nativeAudioStart)(JNIEnv* env, jobject thiz) {
#endif #endif
plugin_set_sample_rate(&instance, (float)device.sampleRate); plugin_set_sample_rate(&instance, (float)device.sampleRate);
#ifdef PARAM_OUT_CPU_INDEX
sample_rate = (float)device.sampleRate;
#endif
size_t req = plugin_mem_req(&instance); size_t req = plugin_mem_req(&instance);
if (req != 0) { if (req != 0) {
mem = malloc(req); mem = malloc(req);

View File

@ -21,9 +21,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include "callbacks.h"
#include "data.h" #include "data.h"
#include "plugin_api.h"
#include "plugin.h" #include "plugin.h"
#include <stdio.h> #include <stdio.h>

View File

@ -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

View File

@ -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);
};

View File

@ -21,9 +21,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include "callbacks.h"
#include "data.h" #include "data.h"
#include "plugin_api.h"
#include "plugin.h" #include "plugin.h"
#include <string.h> #include <string.h>

View File

@ -21,9 +21,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include "callbacks.h"
#include "data.h" #include "data.h"
#include "plugin_api.h"
#include "plugin.h" #include "plugin.h"
#if PARAMETERS_N > 0 #if PARAMETERS_N > 0
#include <algorithm> #include <algorithm>
@ -36,9 +35,6 @@
#define MA_NO_RUNTIME_LINKING #define MA_NO_RUNTIME_LINKING
#include "miniaudio.h" #include "miniaudio.h"
#define BLOCK_SIZE 32 #define BLOCK_SIZE 32
#ifdef PARAM_OUT_CPU_INDEX
# include "fatica.h"
#endif
static ma_device device; static ma_device device;
static ma_device_config deviceConfig; static ma_device_config deviceConfig;
@ -82,18 +78,10 @@ MIDIPortRef midiPort = NULL;
uint8_t midiBuffer[MIDIBUFFERLEN]; uint8_t midiBuffer[MIDIBUFFERLEN];
int midiBuffer_i = 0; int midiBuffer_i = 0;
#endif #endif
#ifdef PARAM_OUT_CPU_INDEX
float cpu_meter = 0.f;
float sample_rate = 1.f;
#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) {
(void)pDevice; (void)pDevice;
#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));
@ -104,15 +92,8 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
if (mutex.try_lock()) { if (mutex.try_lock()) {
# if PARAMETERS_N > 0 # if PARAMETERS_N > 0
for (size_t i = 0; i < PARAMETERS_N; i++) { for (size_t i = 0; i < PARAMETERS_N; i++) {
if (param_data[i].out) { if (param_data[i].out)
# ifdef PARAM_OUT_CPU_INDEX
if (i == PARAM_OUT_CPU_INDEX) {
param_values_prev[i] = param_values[i] = cpu_meter;
continue;
}
# endif
param_values_prev[i] = param_values[i] = plugin_get_parameter(&instance, i); param_values_prev[i] = param_values[i] = plugin_get_parameter(&instance, i);
}
else if (param_values_prev[i] != param_values[i]) { else if (param_values_prev[i] != param_values[i]) {
plugin_set_parameter(&instance, i, param_values[i]); plugin_set_parameter(&instance, i, param_values[i]);
param_values_prev[i] = param_values[i]; param_values_prev[i] = param_values[i];
@ -171,13 +152,6 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
#if defined(__aarch64__) #if defined(__aarch64__)
__asm__ __volatile__ ("msr fpcr, %0" : : "r"(fpcr)); __asm__ __volatile__ ("msr fpcr, %0" : : "r"(fpcr));
#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;
cpu_meter = cpu_meter * 0.9f + ((float) (processTimeS * sample_rate)) * 0.1f;
#endif
} }
#if (NUM_MIDI_INPUTS > 0) #if (NUM_MIDI_INPUTS > 0)
@ -296,9 +270,6 @@ char audioStart() {
#endif #endif
plugin_set_sample_rate(&instance, (float)device.sampleRate); plugin_set_sample_rate(&instance, (float)device.sampleRate);
#ifdef PARAM_OUT_CPU_INDEX
sample_rate = (float)device.sampleRate;
#endif
size_t req = plugin_mem_req(&instance); size_t req = plugin_mem_req(&instance);
if (req != 0) { if (req != 0) {

View File

@ -21,9 +21,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include "callbacks.h"
#include "data.h" #include "data.h"
#include "plugin_api.h"
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-function"
#include "plugin.h" #include "plugin.h"
@ -53,10 +52,6 @@
# include <pmmintrin.h> # include <pmmintrin.h>
#endif #endif
#ifdef PARAM_OUT_CPU_INDEX
# include "fatica.h"
#endif
static inline float clampf(float x, float m, float M) { static inline float clampf(float x, float m, float M) {
return x < m ? m : (x > M ? M : x); return x < m ? m : (x > M ? M : x);
} }
@ -98,10 +93,6 @@ typedef struct {
#if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0 #if DATA_PRODUCT_MIDI_INPUTS_N + DATA_PRODUCT_MIDI_OUTPUTS_N > 0
LV2_URID uri_midi_MidiEvent; LV2_URID uri_midi_MidiEvent;
#endif #endif
#ifdef PARAM_OUT_CPU_INDEX
float cpu_meter;
float sample_rate;
#endif
} plugin_instance; } plugin_instance;
static const char * get_bundle_path_cb(void *handle) { static const char * get_bundle_path_cb(void *handle) {
@ -177,10 +168,6 @@ static LV2_Handle instantiate(const struct LV2_Descriptor * descriptor, double s
for (uint32_t i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++) for (uint32_t i = 0; i < DATA_PRODUCT_CONTROL_INPUTS_N + DATA_PRODUCT_CONTROL_OUTPUTS_N; i++)
instance->c[i] = NULL; instance->c[i] = NULL;
#endif #endif
#ifdef PARAM_OUT_CPU_INDEX
instance->cpu_meter = 0.f;
instance->sample_rate = sample_rate;
#endif
return instance; return instance;
@ -243,10 +230,6 @@ static void activate(LV2_Handle instance) {
static void run(LV2_Handle instance, uint32_t sample_count) { static void run(LV2_Handle instance, uint32_t sample_count) {
plugin_instance * i = (plugin_instance *)instance; plugin_instance * i = (plugin_instance *)instance;
#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));
@ -301,16 +284,9 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
#if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0 #if DATA_PRODUCT_CONTROL_OUTPUTS_N > 0
for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_OUTPUTS_N; j++) { for (uint32_t j = 0; j < DATA_PRODUCT_CONTROL_OUTPUTS_N; j++) {
uint32_t k = param_out_index[j]; uint32_t k = param_out_index[j];
if (i->c[k] != NULL) { if (i->c[k] != NULL)
# ifdef PARAM_OUT_CPU_INDEX
if (k == PARAM_OUT_CPU_INDEX) {
*i->c[k] = i->cpu_meter;
continue;
}
# endif
*i->c[k] = plugin_get_parameter(&i->p, k); *i->c[k] = plugin_get_parameter(&i->p, k);
} }
}
#else #else
(void)plugin_get_parameter; (void)plugin_get_parameter;
#endif #endif
@ -321,14 +297,6 @@ static void run(LV2_Handle instance, uint32_t sample_count) {
_MM_SET_FLUSH_ZERO_MODE(flush_zero_mode); _MM_SET_FLUSH_ZERO_MODE(flush_zero_mode);
_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;
i->cpu_meter = i->cpu_meter * 0.9f + ((float) (processTimeS * i->sample_rate)) * 0.1f;
#endif
} }
static void cleanup(LV2_Handle instance) { static void cleanup(LV2_Handle instance) {

View File

@ -21,14 +21,13 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include "callbacks.h"
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic" #pragma GCC diagnostic ignored "-Wpedantic"
#include "vst3_c_api.h" #include "vst3_c_api.h"
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#include "data.h" #include "data.h"
#include "plugin_api.h"
#include "plugin.h" #include "plugin.h"
#ifdef DATA_UI #ifdef DATA_UI
# include "plugin_ui.h" # include "plugin_ui.h"
@ -54,10 +53,6 @@
#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
@ -220,9 +215,6 @@ typedef struct pluginInstance {
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;
@ -324,9 +316,6 @@ static Steinberg_tresult pluginInitialize(void *thisInterface, struct Steinberg_
# endif # endif
#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;
} }
@ -748,10 +737,6 @@ 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));
@ -839,13 +824,7 @@ 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; float v = plugin_get_parameter(&p->p, parameterData[i].index);
# 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;
@ -869,13 +848,6 @@ 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;
} }

View File

@ -21,9 +21,8 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "callbacks.h"
#include "data.h" #include "data.h"
#include "plugin_api.h"
#include "plugin.h" #include "plugin.h"
#include "string.h" #include "string.h"

View File

@ -68,17 +68,17 @@ static void plugin_reset(plugin *instance) {
static void plugin_set_parameter(plugin *instance, size_t index, float value) { static void plugin_set_parameter(plugin *instance, size_t index, float value) {
switch (index) { switch (index) {
case 0: case plugin_parameter_gain:
//approx instance->gain = powf(10.f, 0.05f * value); //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); instance->gain = ((2.6039890429412597e-4f * value + 0.032131027163547855f) * value + 1.f) / ((0.0012705124328080768f * value - 0.0666763481312185f) * value + 1.f);
break; break;
case 1: case plugin_parameter_delay:
instance->delay = 0.001f * value; instance->delay = 0.001f * value;
break; break;
case 2: case plugin_parameter_cutoff:
instance->cutoff = value; instance->cutoff = value;
break; break;
case 3: case plugin_parameter_bypass:
instance->bypass = value >= 0.5f; instance->bypass = value >= 0.5f;
break; break;
} }

View File

@ -1,32 +1,39 @@
#!/bin/sh #!/bin/sh
dir=`dirname $0` 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/../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/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/../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/../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 $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 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 $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-make $dir/../out/web
$dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/web-demo $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 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/../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 $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/keystore.jks $dir/../out/android
cp $dir/plugin.h $dir/../out/android/src 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/../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 $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 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/../templates/cmd $dir/../out/cmd
$dir/../tibia $dir/product.json,$dir/company.json,$dir/cmd-make.json $dir/../templates/cmd-make $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 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/../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 $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 cp $dir/plugin.h $dir/../out/daisy-seed/src