/* * Carla Native Plugins * Copyright (C) 2012-2020 Filipe Coelho * * This program 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; either version 2 of * the License, or any later version. * * This program 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. * * For a full copy of the GNU General Public License see the doc/GPL.txt file. */ #include "CarlaNative.h" #include #include #include #include // ----------------------------------------------------------------------- typedef enum { // all versions PARAM_LIMITER = 0, PARAM_COUNT } CvToAudioParams; typedef struct { bool limiterOn; } CvToAudioHandle; // ----------------------------------------------------------------------- static NativePluginHandle cv2audio_instantiate(const NativeHostDescriptor* host) { CvToAudioHandle* const handle = (CvToAudioHandle*)malloc(sizeof(CvToAudioHandle)); if (handle == NULL) return NULL; handle->limiterOn = true; return handle; // unused (void)host; } #define handlePtr ((CvToAudioHandle*)handle) static void cv2audio_cleanup(NativePluginHandle handle) { free(handlePtr); } static uint32_t cv2audio_get_parameter_count(NativePluginHandle handle) { return PARAM_COUNT; // unused (void)handle; } static const NativeParameter* cv2audio_get_parameter_info(NativePluginHandle handle, uint32_t index) { if (index > PARAM_COUNT) return NULL; static NativeParameter param; param.hints = NATIVE_PARAMETER_IS_ENABLED|NATIVE_PARAMETER_IS_AUTOMABLE; param.unit = NULL; param.scalePointCount = 0; param.scalePoints = NULL; switch (index) { case PARAM_LIMITER: param.name = "Briwall Limiter"; param.hints |= NATIVE_PARAMETER_IS_BOOLEAN; param.ranges.def = 1.0f; param.ranges.min = 0.0f; param.ranges.max = 1.0f; param.ranges.step = 1.0f; param.ranges.stepSmall = 1.0f; param.ranges.stepLarge = 1.0f; break; } return ¶m; // unused (void)handle; } static float cv2audio_get_parameter_value(NativePluginHandle handle, uint32_t index) { switch (index) { case PARAM_LIMITER: return handlePtr->limiterOn ? 1.0f : 0.0f; default: return 0.0f; } } static void cv2audio_set_parameter_value(NativePluginHandle handle, uint32_t index, float value) { switch (index) { case PARAM_LIMITER: handlePtr->limiterOn = (value >= 0.5f); break; } } static const NativePortRange* cv2audio_get_buffer_port_range(NativePluginHandle handle, uint32_t index, bool isOutput) { if (isOutput) return NULL; static NativePortRange npr; switch (index) { case 0: npr.minimum = -1.0f; npr.maximum = 1.0f; return ⊀ default: return NULL; } // unused (void)handle; } static const char* cv2audio_get_buffer_port_name(NativePluginHandle handle, uint32_t index, bool isOutput) { if (index != 0) return NULL; return isOutput ? "Audio Output" : "CV Input"; // unused (void)handle; } // FIXME for v3.0, use const for the input buffer static void cv2audio_process(NativePluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, const NativeMidiEvent* midiEvents, uint32_t midiEventCount) { const float* const inBuf = inBuffer[0]; /**/ float* const outBuf = outBuffer[0]; if (handlePtr->limiterOn) { for (uint32_t i=0; i