diff --git a/templates/android/src/data.h b/templates/android/src/data.h index 4c99f3a..de2c91d 100644 --- a/templates/android/src/data.h +++ b/templates/android/src/data.h @@ -1,7 +1,7 @@ /* * Tibia * - * Copyright (C) 2024 Orastron Srl unipersonale + * Copyright (C) 2024, 2025 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 @@ -83,3 +83,7 @@ static struct { #endif #define JNI_FUNC(x) Java_{{=it.android.javaPackageName.replaceAll("_", "_1").replaceAll(".", "_")}}_MainActivity_##x + +{{?it.product.state && it.product.state.dspCustom}} +#define STATE_DSP_CUSTOM +{{?}} diff --git a/templates/android/src/jni.cpp b/templates/android/src/jni.cpp index a65dfa5..57fdd97 100644 --- a/templates/android/src/jni.cpp +++ b/templates/android/src/jni.cpp @@ -1,7 +1,7 @@ /* * Tibia * - * Copyright (C) 2023, 2024 Orastron Srl unipersonale + * Copyright (C) 2023-2025 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 @@ -189,6 +189,10 @@ JNIEXPORT jboolean JNICALL JNI_FUNC(nativeAudioStart)(JNIEnv* env, jobject thiz) { (void)env; (void)thiz; +#ifdef STATE_DSP_CUSTOM + (void)plugin_state_load; + (void)plugin_state_save; +#endif #if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0 # if NUM_CHANNELS_IN == 0 diff --git a/templates/cmd/src/data.h b/templates/cmd/src/data.h index ec9a573..7ea8781 100644 --- a/templates/cmd/src/data.h +++ b/templates/cmd/src/data.h @@ -1,7 +1,7 @@ /* * Tibia * - * Copyright (C) 2024 Orastron Srl unipersonale + * Copyright (C) 2024, 2025 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 @@ -83,3 +83,7 @@ static struct { {{~}} }; #endif + +{{?it.product.state && it.product.state.dspCustom}} +#define STATE_DSP_CUSTOM +{{?}} diff --git a/templates/cmd/src/main.c b/templates/cmd/src/main.c index 6f598f2..b5b50aa 100644 --- a/templates/cmd/src/main.c +++ b/templates/cmd/src/main.c @@ -1,7 +1,7 @@ /* * Tibia * - * Copyright (C) 2024 Orastron Srl unipersonale + * Copyright (C) 2024, 2025 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 @@ -162,6 +162,11 @@ float clampf(float x, float m, float M) { } int main(int argc, char * argv[]) { +#ifdef STATE_DSP_CUSTOM + (void)plugin_state_load; + (void)plugin_state_save; +#endif + #if PARAMETERS_N > 0 for (size_t i = 0; i < PARAMETERS_N; i++) param_values[i] = param_data[i].def; diff --git a/templates/daisy-seed/src/data.h b/templates/daisy-seed/src/data.h index ea0e3ec..69a7f39 100644 --- a/templates/daisy-seed/src/data.h +++ b/templates/daisy-seed/src/data.h @@ -1,7 +1,7 @@ /* * Tibia * - * Copyright (C) 2024 Orastron Srl unipersonale + * Copyright (C) 2024, 2025 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 @@ -98,3 +98,7 @@ static int midi_cc_maps[NUM_PARAMETERS] = { {{~it.daisy_seed.midiCCMaps :p}}{{=p # endif #endif + +{{?it.product.state && it.product.state.dspCustom}} +#define STATE_DSP_CUSTOM +{{?}} diff --git a/templates/daisy-seed/src/main.cpp b/templates/daisy-seed/src/main.cpp index 43253b3..2be97b9 100644 --- a/templates/daisy-seed/src/main.cpp +++ b/templates/daisy-seed/src/main.cpp @@ -1,7 +1,7 @@ /* * Tibia * - * Copyright (C) 2023, 2024 Orastron Srl unipersonale + * Copyright (C) 2023-2025 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 @@ -150,6 +150,11 @@ static void AudioCallback( } int main() { +#ifdef STATE_DSP_CUSTOM + (void)plugin_state_load; + (void)plugin_state_save; +#endif + hardware.Configure(); hardware.Init(); diff --git a/templates/ios/src/data.h b/templates/ios/src/data.h index 8b3d2a1..b5d9594 100644 --- a/templates/ios/src/data.h +++ b/templates/ios/src/data.h @@ -1,7 +1,7 @@ /* * Tibia * - * Copyright (C) 2024 Orastron Srl unipersonale + * Copyright (C) 2024, 2025 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 @@ -81,3 +81,7 @@ static struct { {{~}} }; #endif + +{{?it.product.state && it.product.state.dspCustom}} +#define STATE_DSP_CUSTOM +{{?}} diff --git a/templates/ios/src/native.mm b/templates/ios/src/native.mm index b7c1ebe..5b87d5c 100644 --- a/templates/ios/src/native.mm +++ b/templates/ios/src/native.mm @@ -1,7 +1,7 @@ /* * Tibia * - * Copyright (C) 2023, 2024 Orastron Srl unipersonale + * Copyright (C) 2023-2025 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 @@ -190,6 +190,11 @@ void (^midiReceiveBlock)(const MIDIEventList *evtlist, void *srcConnRefCon) = ^( extern "C" char audioStart() { +#ifdef STATE_DSP_CUSTOM + (void)plugin_state_load; + (void)plugin_state_save; +#endif + #if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0 # if NUM_CHANNELS_IN == 0 deviceConfig = ma_device_config_init(ma_device_type_playback); diff --git a/templates/web/src/data.h b/templates/web/src/data.h index d97fd2d..48c6258 100644 --- a/templates/web/src/data.h +++ b/templates/web/src/data.h @@ -1,7 +1,7 @@ /* * Tibia * - * Copyright (C) 2024 Orastron Srl unipersonale + * Copyright (C) 2024, 2025 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 @@ -44,3 +44,7 @@ static size_t param_out_index[DATA_PRODUCT_PARAMETERS_OUTPUT_N] = { {{~it.product.parameters :p:i}}{{?p.direction == "output"}}{{=i}}, {{?}}{{~}} }; #endif + +{{?it.product.state && it.product.state.dspCustom}} +#define DATA_STATE_DSP_CUSTOM +{{?}} diff --git a/templates/web/src/processor.c b/templates/web/src/processor.c index a559be3..de9f9e9 100644 --- a/templates/web/src/processor.c +++ b/templates/web/src/processor.c @@ -1,7 +1,7 @@ /* * Tibia * - * Copyright (C) 2022-2024 Orastron Srl unipersonale + * Copyright (C) 2022-2025 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 @@ -46,6 +46,11 @@ typedef struct { } instance; instance * processor_new(float sample_rate) { +#ifdef DATA_STATE_DSP_CUSTOM + (void)plugin_state_load; + (void)plugin_state_save; +#endif + instance * i = malloc(sizeof(instance)); if (i == NULL) return NULL; diff --git a/test/plugin.h b/test/plugin.h index b815ca0..6ba7c33 100644 --- a/test/plugin.h +++ b/test/plugin.h @@ -19,7 +19,6 @@ */ #include -#include typedef struct plugin { float sample_rate; @@ -154,6 +153,12 @@ static int plugin_state_save(plugin *instance, const plugin_state_callbacks *cbs return cbs->write(cbs->handle, (const char *)data, 13); } +static char x_isnan(float x) { + union { uint32_t u; float f; } v; + v.f = x; + return ((v.u & 0x7f800000) == 0x7f800000) && (v.u & 0x7fffff); +} + static int plugin_state_load(const plugin_state_callbacks *cbs, const char *data, size_t length) { if (length != 13) return -1; @@ -162,7 +167,7 @@ static int plugin_state_load(const plugin_state_callbacks *cbs, const char *data const float delay = parse_float(d + 4); const float cutoff = parse_float(d + 8); const float bypass = d[12] ? 1.f : 0.f; - if (isnan(gain) || isnan(delay) || isnan(cutoff)) + if (x_isnan(gain) || x_isnan(delay) || x_isnan(cutoff)) return -1; cbs->lock(cbs->handle); cbs->set_parameter(cbs->handle, plugin_parameter_gain, gain);