Signed-off-by: falkTX <falktx@falktx.com>pull/321/head
| @@ -1,45 +0,0 @@ | |||||
| /** | |||||
| * One-pole LPF for smooth parameter changes | |||||
| * | |||||
| * https://www.musicdsp.org/en/latest/Filters/257-1-pole-lpf-for-smooth-parameter-changes.html | |||||
| */ | |||||
| #ifndef C_PARAM_SMOOTH_H | |||||
| #define C_PARAM_SMOOTH_H | |||||
| #include <math.h> | |||||
| #define TWO_PI 6.283185307179586476925286766559f | |||||
| class CParamSmooth { | |||||
| public: | |||||
| CParamSmooth(float smoothingTimeMs, float samplingRate) | |||||
| : t(smoothingTimeMs) | |||||
| { | |||||
| setSampleRate(samplingRate); | |||||
| } | |||||
| ~CParamSmooth() { } | |||||
| void setSampleRate(float samplingRate) { | |||||
| if (samplingRate != fs) { | |||||
| fs = samplingRate; | |||||
| a = exp(-TWO_PI / (t * 0.001f * samplingRate)); | |||||
| b = 1.0f - a; | |||||
| z = 0.0f; | |||||
| } | |||||
| } | |||||
| inline void flush() { | |||||
| z = 0.0f; | |||||
| } | |||||
| inline float process(float in) { | |||||
| return z = (in * b) + (z * a); | |||||
| } | |||||
| private: | |||||
| float a, b, t, z; | |||||
| double fs = 0.0; | |||||
| }; | |||||
| #endif // #ifndef C_PARAM_SMOOTH_H | |||||
| @@ -1,145 +0,0 @@ | |||||
| /* | |||||
| * Simple Gain audio effect for DISTRHO Plugin Framework (DPF) | |||||
| * SPDX-License-Identifier: MIT | |||||
| * | |||||
| * Copyright (C) 2021 Jean Pierre Cimalando <jp-dev@inbox.ru> | |||||
| * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
| * | |||||
| * Permission to use, copy, modify, and/or distribute this software for any purpose with | |||||
| * or without fee is hereby granted, provided that the above copyright notice and this | |||||
| * permission notice appear in all copies. | |||||
| * | |||||
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD | |||||
| * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN | |||||
| * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL | |||||
| * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER | |||||
| * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | |||||
| * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |||||
| */ | |||||
| /** | |||||
| The plugin name.@n | |||||
| This is used to identify your plugin before a Plugin instance can be created. | |||||
| @note This macro is required. | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_NAME "ImGuiSimpleGain" | |||||
| /** | |||||
| Number of audio inputs the plugin has. | |||||
| @note This macro is required. | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_NUM_INPUTS 2 | |||||
| /** | |||||
| Number of audio outputs the plugin has. | |||||
| @note This macro is required. | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_NUM_OUTPUTS 2 | |||||
| /** | |||||
| The plugin URI when exporting in LV2 format. | |||||
| @note This macro is required. | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_URI "http://distrho.sf.net/examples/imguisimplegain" | |||||
| /** | |||||
| Wherever the plugin has a custom %UI. | |||||
| @see DISTRHO_UI_USE_NANOVG | |||||
| @see UI | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_HAS_UI 1 | |||||
| /** | |||||
| Wherever the plugin processing is realtime-safe.@n | |||||
| TODO - list rtsafe requirements | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_IS_RT_SAFE 1 | |||||
| /** | |||||
| Wherever the plugin is a synth.@n | |||||
| @ref DISTRHO_PLUGIN_WANT_MIDI_INPUT is automatically enabled when this is too. | |||||
| @see DISTRHO_PLUGIN_WANT_MIDI_INPUT | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_IS_SYNTH 0 | |||||
| /** | |||||
| Enable direct access between the %UI and plugin code. | |||||
| @see UI::getPluginInstancePointer() | |||||
| @note DO NOT USE THIS UNLESS STRICTLY NECESSARY!! | |||||
| Try to avoid it at all costs! | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_WANT_DIRECT_ACCESS 0 | |||||
| /** | |||||
| Wherever the plugin introduces latency during audio or midi processing. | |||||
| @see Plugin::setLatency(uint32_t) | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_WANT_LATENCY 0 | |||||
| /** | |||||
| Wherever the plugin wants MIDI input.@n | |||||
| This is automatically enabled if @ref DISTRHO_PLUGIN_IS_SYNTH is true. | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_WANT_MIDI_INPUT 0 | |||||
| /** | |||||
| Wherever the plugin wants MIDI output. | |||||
| @see Plugin::writeMidiEvent(const MidiEvent&) | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_WANT_MIDI_OUTPUT 0 | |||||
| /** | |||||
| Wherever the plugin provides its own internal programs. | |||||
| @see Plugin::initProgramName(uint32_t, String&) | |||||
| @see Plugin::loadProgram(uint32_t) | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_WANT_PROGRAMS 0 | |||||
| /** | |||||
| Wherever the plugin uses internal non-parameter data. | |||||
| @see Plugin::initState(uint32_t, String&, String&) | |||||
| @see Plugin::setState(const char*, const char*) | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_WANT_STATE 0 | |||||
| /** | |||||
| Wherever the plugin wants time position information from the host. | |||||
| @see Plugin::getTimePosition() | |||||
| */ | |||||
| #define DISTRHO_PLUGIN_WANT_TIMEPOS 0 | |||||
| /** | |||||
| Wherever the %UI uses NanoVG for drawing instead of the default raw OpenGL calls.@n | |||||
| When enabled your %UI instance will subclass @ref NanoWidget instead of @ref Widget. | |||||
| */ | |||||
| #define DISTRHO_UI_USE_NANOVG 0 | |||||
| /** | |||||
| The %UI URI when exporting in LV2 format.@n | |||||
| By default this is set to @ref DISTRHO_PLUGIN_URI with "#UI" as suffix. | |||||
| */ | |||||
| #define DISTRHO_UI_URI DISTRHO_PLUGIN_URI "#UI" | |||||
| /** | |||||
| Wherever the %UI uses a custom toolkit implementation based on OpenGL.@n | |||||
| When enabled, the macros @ref DISTRHO_UI_CUSTOM_INCLUDE_PATH and @ref DISTRHO_UI_CUSTOM_WIDGET_TYPE are required. | |||||
| */ | |||||
| #define DISTRHO_UI_USE_CUSTOM 1 | |||||
| /** | |||||
| The include path to the header file used by the custom toolkit implementation. | |||||
| This path must be relative to dpf/distrho/DistrhoUI.hpp | |||||
| @see DISTRHO_UI_USE_CUSTOM | |||||
| */ | |||||
| #define DISTRHO_UI_CUSTOM_INCLUDE_PATH "DearImGui.hpp" | |||||
| /** | |||||
| The top-level-widget typedef to use for the custom toolkit. | |||||
| This widget class MUST be a subclass of DGL TopLevelWindow class. | |||||
| It is recommended that you keep this widget class inside the DGL namespace, | |||||
| and define widget type as e.g. DGL_NAMESPACE::MyCustomTopLevelWidget. | |||||
| @see DISTRHO_UI_USE_CUSTOM | |||||
| */ | |||||
| #define DISTRHO_UI_CUSTOM_WIDGET_TYPE DGL_NAMESPACE::ImGuiTopLevelWidget | |||||
| #define DISTRHO_UI_USER_RESIZABLE 1 | |||||
| @@ -1,41 +0,0 @@ | |||||
| #!/usr/bin/make -f | |||||
| # Makefile for DISTRHO Plugins # | |||||
| # ---------------------------- # | |||||
| # Created by falkTX, Christopher Arndt, and Patrick Desaulniers | |||||
| # | |||||
| # -------------------------------------------------------------- | |||||
| # Project name, used for binaries | |||||
| NAME = d_ImGuiSimpleGain | |||||
| # -------------------------------------------------------------- | |||||
| # Files to build | |||||
| FILES_DSP = \ | |||||
| PluginSimpleGain.cpp | |||||
| FILES_UI = \ | |||||
| UISimpleGain.cpp \ | |||||
| ../../../DPF-Widgets/opengl/DearImGui.cpp | |||||
| # -------------------------------------------------------------- | |||||
| # Do some magic | |||||
| include ../../Makefile.plugins.mk | |||||
| # path to DPF-Widgets | |||||
| BUILD_CXX_FLAGS += -I../../../DPF-Widgets/opengl/ | |||||
| # -------------------------------------------------------------- | |||||
| # Enable all selected plugin types | |||||
| TARGETS += jack lv2_sep vst2 vst3 | |||||
| ifeq ($(HAVE_LIBLO),true) | |||||
| TARGETS += dssi | |||||
| endif # HAVE_LIBLO | |||||
| all: $(TARGETS) | |||||
| # -------------------------------------------------------------- | |||||
| @@ -1,130 +0,0 @@ | |||||
| /* | |||||
| * Simple Gain audio effect based on DISTRHO Plugin Framework (DPF) | |||||
| * | |||||
| * SPDX-License-Identifier: MIT | |||||
| * | |||||
| * Copyright (C) 2021 Jean Pierre Cimalando <jp-dev@inbox.ru> | |||||
| * | |||||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |||||
| * of this software and associated documentation files (the "Software"), to | |||||
| * deal in the Software without restriction, including without limitation the | |||||
| * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |||||
| * sell copies of the Software, and to permit persons to whom the Software is | |||||
| * furnished to do so, subject to the following conditions: | |||||
| * | |||||
| * The above copyright notice and this permission notice shall be included in | |||||
| * all copies or substantial portions of the Software. | |||||
| * | |||||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||||
| * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |||||
| * IN THE SOFTWARE. | |||||
| */ | |||||
| #include "PluginSimpleGain.hpp" | |||||
| START_NAMESPACE_DISTRHO | |||||
| // ----------------------------------------------------------------------- | |||||
| PluginSimpleGain::PluginSimpleGain() | |||||
| : Plugin(paramCount, 0, 0), // parameters, programs, states | |||||
| fSampleRate(getSampleRate()), | |||||
| fGainDB(0.0f), | |||||
| fGainLinear(1.0f) | |||||
| { | |||||
| fSmoothGain = new CParamSmooth(20.0f, fSampleRate); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| // Init | |||||
| void PluginSimpleGain::initParameter(uint32_t index, Parameter& parameter) | |||||
| { | |||||
| DISTRHO_SAFE_ASSERT_RETURN(index == 0,); | |||||
| parameter.ranges.min = -90.0f; | |||||
| parameter.ranges.max = 30.0f; | |||||
| parameter.ranges.def = -0.0f; | |||||
| parameter.hints = kParameterIsAutomatable; | |||||
| parameter.name = "Gain"; | |||||
| parameter.shortName = "Gain"; | |||||
| parameter.symbol = "gain"; | |||||
| parameter.unit = "dB"; | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| // Internal data | |||||
| /** | |||||
| Get the current value of a parameter. | |||||
| */ | |||||
| float PluginSimpleGain::getParameterValue(uint32_t index) const | |||||
| { | |||||
| DISTRHO_SAFE_ASSERT_RETURN(index == 0, 0.0f); | |||||
| return fGainDB; | |||||
| } | |||||
| /** | |||||
| Change a parameter value. | |||||
| */ | |||||
| void PluginSimpleGain::setParameterValue(uint32_t index, float value) | |||||
| { | |||||
| DISTRHO_SAFE_ASSERT_RETURN(index == 0,); | |||||
| fGainDB = value; | |||||
| fGainLinear = DB_CO(CLAMP(value, -90.0, 30.0)); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| // Process | |||||
| void PluginSimpleGain::activate() | |||||
| { | |||||
| fSmoothGain->flush(); | |||||
| } | |||||
| void PluginSimpleGain::run(const float** inputs, float** outputs, uint32_t frames) | |||||
| { | |||||
| // get the left and right audio inputs | |||||
| const float* const inpL = inputs[0]; | |||||
| const float* const inpR = inputs[1]; | |||||
| // get the left and right audio outputs | |||||
| float* const outL = outputs[0]; | |||||
| float* const outR = outputs[1]; | |||||
| // apply gain against all samples | |||||
| for (uint32_t i=0; i < frames; ++i) | |||||
| { | |||||
| const float gain = fSmoothGain->process(fGainLinear); | |||||
| outL[i] = inpL[i] * gain; | |||||
| outR[i] = inpR[i] * gain; | |||||
| } | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| /** | |||||
| Optional callback to inform the plugin about a sample rate change. | |||||
| */ | |||||
| void PluginSimpleGain::sampleRateChanged(double newSampleRate) | |||||
| { | |||||
| fSampleRate = newSampleRate; | |||||
| fSmoothGain->setSampleRate(newSampleRate); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| Plugin* createPlugin() | |||||
| { | |||||
| return new PluginSimpleGain(); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| END_NAMESPACE_DISTRHO | |||||
| @@ -1,135 +0,0 @@ | |||||
| /* | |||||
| * Simple Gain audio effect based on DISTRHO Plugin Framework (DPF) | |||||
| * | |||||
| * SPDX-License-Identifier: MIT | |||||
| * | |||||
| * Copyright (C) 2021 Jean Pierre Cimalando <jp-dev@inbox.ru> | |||||
| * | |||||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |||||
| * of this software and associated documentation files (the "Software"), to | |||||
| * deal in the Software without restriction, including without limitation the | |||||
| * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |||||
| * sell copies of the Software, and to permit persons to whom the Software is | |||||
| * furnished to do so, subject to the following conditions: | |||||
| * | |||||
| * The above copyright notice and this permission notice shall be included in | |||||
| * all copies or substantial portions of the Software. | |||||
| * | |||||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||||
| * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |||||
| * IN THE SOFTWARE. | |||||
| */ | |||||
| #ifndef PLUGIN_SIMPLEGAIN_H | |||||
| #define PLUGIN_SIMPLEGAIN_H | |||||
| #include "DistrhoPlugin.hpp" | |||||
| #include "CParamSmooth.hpp" | |||||
| #include "extra/ScopedPointer.hpp" | |||||
| START_NAMESPACE_DISTRHO | |||||
| #ifndef MIN | |||||
| #define MIN(a,b) ( (a) < (b) ? (a) : (b) ) | |||||
| #endif | |||||
| #ifndef MAX | |||||
| #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) | |||||
| #endif | |||||
| #ifndef CLAMP | |||||
| #define CLAMP(v, min, max) (MIN((max), MAX((min), (v)))) | |||||
| #endif | |||||
| #ifndef DB_CO | |||||
| #define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f) | |||||
| #endif | |||||
| // ----------------------------------------------------------------------- | |||||
| class PluginSimpleGain : public Plugin { | |||||
| public: | |||||
| enum Parameters { | |||||
| paramGain = 0, | |||||
| paramCount | |||||
| }; | |||||
| PluginSimpleGain(); | |||||
| protected: | |||||
| // ------------------------------------------------------------------- | |||||
| // Information | |||||
| const char* getLabel() const noexcept override | |||||
| { | |||||
| return "SimpleGain"; | |||||
| } | |||||
| const char* getDescription() const override | |||||
| { | |||||
| return "A simple audio volume gain plugin with ImGui for its GUI"; | |||||
| } | |||||
| const char* getMaker() const noexcept override | |||||
| { | |||||
| return "Jean Pierre Cimalando, falkTX"; | |||||
| } | |||||
| const char* getLicense() const noexcept override | |||||
| { | |||||
| return "MIT"; | |||||
| } | |||||
| uint32_t getVersion() const noexcept override | |||||
| { | |||||
| return d_version(1, 0, 0); | |||||
| } | |||||
| int64_t getUniqueId() const noexcept override | |||||
| { | |||||
| return d_cconst('d', 'I', 'm', 'G'); | |||||
| } | |||||
| // ------------------------------------------------------------------- | |||||
| // Init | |||||
| void initParameter(uint32_t index, Parameter& parameter) override; | |||||
| // ------------------------------------------------------------------- | |||||
| // Internal data | |||||
| float getParameterValue(uint32_t index) const override; | |||||
| void setParameterValue(uint32_t index, float value) override; | |||||
| // ------------------------------------------------------------------- | |||||
| // Optional | |||||
| // Optional callback to inform the plugin about a sample rate change. | |||||
| void sampleRateChanged(double newSampleRate) override; | |||||
| // ------------------------------------------------------------------- | |||||
| // Process | |||||
| void activate() override; | |||||
| void run(const float**, float** outputs, uint32_t frames) override; | |||||
| // ------------------------------------------------------------------- | |||||
| private: | |||||
| double fSampleRate; | |||||
| float fGainDB; | |||||
| float fGainLinear; | |||||
| ScopedPointer<CParamSmooth> fSmoothGain; | |||||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginSimpleGain) | |||||
| }; | |||||
| // ----------------------------------------------------------------------- | |||||
| END_NAMESPACE_DISTRHO | |||||
| #endif // #ifndef PLUGIN_SIMPLEGAIN_H | |||||
| @@ -1,106 +0,0 @@ | |||||
| /* | |||||
| * Simple Gain audio effect based on DISTRHO Plugin Framework (DPF) | |||||
| * | |||||
| * SPDX-License-Identifier: MIT | |||||
| * | |||||
| * Copyright (C) 2021 Jean Pierre Cimalando <jp-dev@inbox.ru> | |||||
| * | |||||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |||||
| * of this software and associated documentation files (the "Software"), to | |||||
| * deal in the Software without restriction, including without limitation the | |||||
| * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |||||
| * sell copies of the Software, and to permit persons to whom the Software is | |||||
| * furnished to do so, subject to the following conditions: | |||||
| * | |||||
| * The above copyright notice and this permission notice shall be included in | |||||
| * all copies or substantial portions of the Software. | |||||
| * | |||||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||||
| * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |||||
| * IN THE SOFTWARE. | |||||
| */ | |||||
| #include "UISimpleGain.hpp" | |||||
| START_NAMESPACE_DISTRHO | |||||
| // ----------------------------------------------------------------------- | |||||
| // Init / Deinit | |||||
| UISimpleGain::UISimpleGain() | |||||
| : UI(600, 400), | |||||
| fGain(0.0f), | |||||
| fResizeHandle(this) | |||||
| { | |||||
| setGeometryConstraints(600, 400, true); | |||||
| // hide handle if UI is resizable | |||||
| if (isResizable()) | |||||
| fResizeHandle.hide(); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| // DSP/Plugin callbacks | |||||
| /** | |||||
| A parameter has changed on the plugin side. | |||||
| This is called by the host to inform the UI about parameter changes. | |||||
| */ | |||||
| void UISimpleGain::parameterChanged(uint32_t index, float value) | |||||
| { | |||||
| DISTRHO_SAFE_ASSERT_RETURN(index == 0,); | |||||
| fGain = value; | |||||
| repaint(); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| // Widget callbacks | |||||
| /** | |||||
| A function called to draw the view contents. | |||||
| */ | |||||
| void UISimpleGain::onImGuiDisplay() | |||||
| { | |||||
| const float width = getWidth(); | |||||
| const float height = getHeight(); | |||||
| const float margin = 20.0f * getScaleFactor(); | |||||
| ImGui::SetNextWindowPos(ImVec2(margin, margin)); | |||||
| ImGui::SetNextWindowSize(ImVec2(width - 2 * margin, height - 2 * margin)); | |||||
| if (ImGui::Begin("Simple gain", nullptr, ImGuiWindowFlags_NoResize)) | |||||
| { | |||||
| static char aboutText[256] = "This is a demo plugin made with ImGui.\n"; | |||||
| ImGui::InputTextMultiline("About", aboutText, sizeof(aboutText)); | |||||
| if (ImGui::SliderFloat("Gain (dB)", &fGain, -90.0f, 30.0f)) | |||||
| { | |||||
| if (ImGui::IsItemActivated()) | |||||
| editParameter(0, true); | |||||
| setParameterValue(0, fGain); | |||||
| } | |||||
| if (ImGui::IsItemDeactivated()) | |||||
| { | |||||
| editParameter(0, false); | |||||
| } | |||||
| } | |||||
| ImGui::End(); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| UI* createUI() | |||||
| { | |||||
| return new UISimpleGain(); | |||||
| } | |||||
| // ----------------------------------------------------------------------- | |||||
| END_NAMESPACE_DISTRHO | |||||
| @@ -1,56 +0,0 @@ | |||||
| /* | |||||
| * Simple Gain audio effect based on DISTRHO Plugin Framework (DPF) | |||||
| * | |||||
| * SPDX-License-Identifier: MIT | |||||
| * | |||||
| * Copyright (C) 2021 Jean Pierre Cimalando <jp-dev@inbox.ru> | |||||
| * | |||||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | |||||
| * of this software and associated documentation files (the "Software"), to | |||||
| * deal in the Software without restriction, including without limitation the | |||||
| * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | |||||
| * sell copies of the Software, and to permit persons to whom the Software is | |||||
| * furnished to do so, subject to the following conditions: | |||||
| * | |||||
| * The above copyright notice and this permission notice shall be included in | |||||
| * all copies or substantial portions of the Software. | |||||
| * | |||||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||||
| * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |||||
| * IN THE SOFTWARE. | |||||
| */ | |||||
| #ifndef UI_SIMPLEGAIN_H | |||||
| #define UI_SIMPLEGAIN_H | |||||
| #include "DistrhoUI.hpp" | |||||
| #include "../generic/ResizeHandle.hpp" | |||||
| START_NAMESPACE_DISTRHO | |||||
| class UISimpleGain : public UI | |||||
| { | |||||
| public: | |||||
| UISimpleGain(); | |||||
| protected: | |||||
| // DSP/Plugin callbacks | |||||
| void parameterChanged(uint32_t, float value) override; | |||||
| // Widget callbacks | |||||
| void onImGuiDisplay() override; | |||||
| private: | |||||
| float fGain; | |||||
| ResizeHandle fResizeHandle; | |||||
| DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UISimpleGain) | |||||
| }; | |||||
| END_NAMESPACE_DISTRHO | |||||
| #endif | |||||