@@ -27,16 +27,16 @@ | |||||
#include "CarlaJuceUtils.hpp" | #include "CarlaJuceUtils.hpp" | ||||
// Plugin Code | // Plugin Code | ||||
#include "distrho-3bandeq/DistrhoArtwork3BandEQ.cpp" | |||||
#include "distrho-3bandeq/DistrhoPlugin3BandEQ.cpp" | #include "distrho-3bandeq/DistrhoPlugin3BandEQ.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "distrho-3bandeq/DistrhoArtwork3BandEQ.cpp" | |||||
#include "distrho-3bandeq/DistrhoUI3BandEQ.cpp" | #include "distrho-3bandeq/DistrhoUI3BandEQ.cpp" | ||||
#endif | #endif | ||||
// DISTRHO Code | // DISTRHO Code | ||||
#define DISTRHO_PLUGIN_TARGET_CARLA | #define DISTRHO_PLUGIN_TARGET_CARLA | ||||
#include "DistrhoPluginMain.cpp" | #include "DistrhoPluginMain.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "DistrhoUIMain.cpp" | #include "DistrhoUIMain.cpp" | ||||
#endif | #endif | ||||
@@ -46,7 +46,7 @@ START_NAMESPACE_DISTRHO | |||||
static const NativePluginDescriptor _3bandeqDesc = { | static const NativePluginDescriptor _3bandeqDesc = { | ||||
/* category */ NATIVE_PLUGIN_CATEGORY_EQ, | /* category */ NATIVE_PLUGIN_CATEGORY_EQ, | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | ||||
|NATIVE_PLUGIN_HAS_UI | |NATIVE_PLUGIN_HAS_UI | ||||
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | ||||
@@ -209,11 +209,6 @@ void DistrhoPlugin3BandEQ::activate() | |||||
xLP = std::exp(-2.0f * kPI * freqLP / sr); | xLP = std::exp(-2.0f * kPI * freqLP / sr); | ||||
#ifdef DISTRHO_OS_WINDOWS | |||||
// don't ask me why, but this fixes a crash/exception below on windows... | |||||
printf("%f\n", -xLP); | |||||
#endif | |||||
a0LP = 1.0f - xLP; | a0LP = 1.0f - xLP; | ||||
b1LP = -xLP; | b1LP = -xLP; | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO 3BandEQ Plugin, based on 3BandEQ by Michael Gruhn | * DISTRHO 3BandEQ Plugin, based on 3BandEQ by Michael Gruhn | ||||
* Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU Lesser General Public | * modify it under the terms of the GNU Lesser General Public | ||||
@@ -24,16 +24,16 @@ namespace Art = DistrhoArtwork3BandEQ; | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
DistrhoUI3BandEQ::DistrhoUI3BandEQ() | DistrhoUI3BandEQ::DistrhoUI3BandEQ() | ||||
: UI(Art::backgroundWidth, Art::backgroundHeight), | |||||
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR), | |||||
: UI(Art::backgroundWidth, Art::backgroundHeight, true), | |||||
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, kImageFormatBGR), | |||||
fAboutWindow(this) | fAboutWindow(this) | ||||
{ | { | ||||
// about | // about | ||||
Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR); | |||||
Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, kImageFormatBGR); | |||||
fAboutWindow.setImage(aboutImage); | fAboutWindow.setImage(aboutImage); | ||||
// sliders | // sliders | ||||
Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight); | |||||
Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight, kImageFormatBGRA); | |||||
Point<int> sliderPosStart(57, 43); | Point<int> sliderPosStart(57, 43); | ||||
Point<int> sliderPosEnd(57, 43 + 160); | Point<int> sliderPosEnd(57, 43 + 160); | ||||
@@ -80,7 +80,7 @@ DistrhoUI3BandEQ::DistrhoUI3BandEQ() | |||||
fSliderMaster->setCallback(this); | fSliderMaster->setCallback(this); | ||||
// knobs | // knobs | ||||
Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight); | |||||
Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight, kImageFormatBGRA); | |||||
// knob Low-Mid | // knob Low-Mid | ||||
fKnobLowMid = new ImageKnob(this, knobImage, ImageKnob::Vertical); | fKnobLowMid = new ImageKnob(this, knobImage, ImageKnob::Vertical); | ||||
@@ -101,8 +101,8 @@ DistrhoUI3BandEQ::DistrhoUI3BandEQ() | |||||
fKnobMidHigh->setCallback(this); | fKnobMidHigh->setCallback(this); | ||||
// about button | // about button | ||||
Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight); | |||||
Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight); | |||||
Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight, kImageFormatBGRA); | |||||
Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight, kImageFormatBGRA); | |||||
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | ||||
fButtonAbout->setAbsolutePos(264, 300); | fButtonAbout->setAbsolutePos(264, 300); | ||||
fButtonAbout->setCallback(this); | fButtonAbout->setCallback(this); | ||||
@@ -161,7 +161,7 @@ void DistrhoUI3BandEQ::imageButtonClicked(ImageButton* button, int) | |||||
if (button != fButtonAbout) | if (button != fButtonAbout) | ||||
return; | return; | ||||
fAboutWindow.exec(); | |||||
fAboutWindow.runAsModal(); | |||||
} | } | ||||
void DistrhoUI3BandEQ::imageKnobDragStarted(ImageKnob* knob) | void DistrhoUI3BandEQ::imageKnobDragStarted(ImageKnob* knob) | ||||
@@ -196,7 +196,9 @@ void DistrhoUI3BandEQ::imageSliderValueChanged(ImageSlider* slider, float value) | |||||
void DistrhoUI3BandEQ::onDisplay() | void DistrhoUI3BandEQ::onDisplay() | ||||
{ | { | ||||
fImgBackground.draw(); | |||||
const GraphicsContext& context(getGraphicsContext()); | |||||
fImgBackground.draw(context); | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -27,16 +27,16 @@ | |||||
#include "CarlaJuceUtils.hpp" | #include "CarlaJuceUtils.hpp" | ||||
// Plugin Code | // Plugin Code | ||||
#include "distrho-3bandsplitter/DistrhoArtwork3BandSplitter.cpp" | |||||
#include "distrho-3bandsplitter/DistrhoPlugin3BandSplitter.cpp" | #include "distrho-3bandsplitter/DistrhoPlugin3BandSplitter.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "distrho-3bandsplitter/DistrhoArtwork3BandSplitter.cpp" | |||||
#include "distrho-3bandsplitter/DistrhoUI3BandSplitter.cpp" | #include "distrho-3bandsplitter/DistrhoUI3BandSplitter.cpp" | ||||
#endif | #endif | ||||
// DISTRHO Code | // DISTRHO Code | ||||
#define DISTRHO_PLUGIN_TARGET_CARLA | #define DISTRHO_PLUGIN_TARGET_CARLA | ||||
#include "DistrhoPluginMain.cpp" | #include "DistrhoPluginMain.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "DistrhoUIMain.cpp" | #include "DistrhoUIMain.cpp" | ||||
#endif | #endif | ||||
@@ -46,7 +46,7 @@ START_NAMESPACE_DISTRHO | |||||
static const NativePluginDescriptor _3bandsplitterDesc = { | static const NativePluginDescriptor _3bandsplitterDesc = { | ||||
/* category */ NATIVE_PLUGIN_CATEGORY_EQ, | /* category */ NATIVE_PLUGIN_CATEGORY_EQ, | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | ||||
|NATIVE_PLUGIN_HAS_UI | |NATIVE_PLUGIN_HAS_UI | ||||
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | ||||
@@ -209,11 +209,6 @@ void DistrhoPlugin3BandSplitter::activate() | |||||
xLP = std::exp(-2.0f * kPI * freqLP / sr); | xLP = std::exp(-2.0f * kPI * freqLP / sr); | ||||
#ifdef DISTRHO_OS_WINDOWS | |||||
// don't ask me why, but this fixes a crash/exception below on windows... | |||||
printf("%f\n", -xLP); | |||||
#endif | |||||
a0LP = 1.0f - xLP; | a0LP = 1.0f - xLP; | ||||
b1LP = -xLP; | b1LP = -xLP; | ||||
@@ -51,7 +51,7 @@ protected: | |||||
const char* getDescription() const override | const char* getDescription() const override | ||||
{ | { | ||||
return "3 Band Equalizer, splitted output version."; | |||||
return "3 Band Equalizer, split output version."; | |||||
} | } | ||||
const char* getMaker() const noexcept override | const char* getMaker() const noexcept override | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO 3BandSplitter Plugin, based on 3BandSplitter by Michael Gruhn | * DISTRHO 3BandSplitter Plugin, based on 3BandSplitter by Michael Gruhn | ||||
* Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU Lesser General Public | * modify it under the terms of the GNU Lesser General Public | ||||
@@ -24,16 +24,16 @@ namespace Art = DistrhoArtwork3BandSplitter; | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
DistrhoUI3BandSplitter::DistrhoUI3BandSplitter() | DistrhoUI3BandSplitter::DistrhoUI3BandSplitter() | ||||
: UI(Art::backgroundWidth, Art::backgroundHeight), | |||||
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR), | |||||
: UI(Art::backgroundWidth, Art::backgroundHeight, true), | |||||
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, kImageFormatBGR), | |||||
fAboutWindow(this) | fAboutWindow(this) | ||||
{ | { | ||||
// about | // about | ||||
Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR); | |||||
Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, kImageFormatBGR); | |||||
fAboutWindow.setImage(aboutImage); | fAboutWindow.setImage(aboutImage); | ||||
// sliders | // sliders | ||||
Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight); | |||||
Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight, kImageFormatBGRA); | |||||
Point<int> sliderPosStart(57, 43); | Point<int> sliderPosStart(57, 43); | ||||
Point<int> sliderPosEnd(57, 43 + 160); | Point<int> sliderPosEnd(57, 43 + 160); | ||||
@@ -80,7 +80,7 @@ DistrhoUI3BandSplitter::DistrhoUI3BandSplitter() | |||||
fSliderMaster->setCallback(this); | fSliderMaster->setCallback(this); | ||||
// knobs | // knobs | ||||
Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight); | |||||
Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight, kImageFormatBGRA); | |||||
// knob Low-Mid | // knob Low-Mid | ||||
fKnobLowMid = new ImageKnob(this, knobImage, ImageKnob::Vertical); | fKnobLowMid = new ImageKnob(this, knobImage, ImageKnob::Vertical); | ||||
@@ -101,8 +101,8 @@ DistrhoUI3BandSplitter::DistrhoUI3BandSplitter() | |||||
fKnobMidHigh->setCallback(this); | fKnobMidHigh->setCallback(this); | ||||
// about button | // about button | ||||
Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight); | |||||
Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight); | |||||
Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight, kImageFormatBGRA); | |||||
Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight, kImageFormatBGRA); | |||||
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | ||||
fButtonAbout->setAbsolutePos(264, 300); | fButtonAbout->setAbsolutePos(264, 300); | ||||
fButtonAbout->setCallback(this); | fButtonAbout->setCallback(this); | ||||
@@ -161,7 +161,7 @@ void DistrhoUI3BandSplitter::imageButtonClicked(ImageButton* button, int) | |||||
if (button != fButtonAbout) | if (button != fButtonAbout) | ||||
return; | return; | ||||
fAboutWindow.exec(); | |||||
fAboutWindow.runAsModal(); | |||||
} | } | ||||
void DistrhoUI3BandSplitter::imageKnobDragStarted(ImageKnob* knob) | void DistrhoUI3BandSplitter::imageKnobDragStarted(ImageKnob* knob) | ||||
@@ -196,7 +196,9 @@ void DistrhoUI3BandSplitter::imageSliderValueChanged(ImageSlider* slider, float | |||||
void DistrhoUI3BandSplitter::onDisplay() | void DistrhoUI3BandSplitter::onDisplay() | ||||
{ | { | ||||
fImgBackground.draw(); | |||||
const GraphicsContext& context(getGraphicsContext()); | |||||
fImgBackground.draw(context); | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -17,27 +17,14 @@ | |||||
// config fix | // config fix | ||||
#include "distrho-kars/DistrhoPluginInfo.h" | #include "distrho-kars/DistrhoPluginInfo.h" | ||||
#if DISTRHO_PLUGIN_HAS_UI && ! defined(HAVE_DGL) | |||||
# undef DISTRHO_PLUGIN_HAS_UI | |||||
# define DISTRHO_PLUGIN_HAS_UI 0 | |||||
#endif | |||||
#include "CarlaJuceUtils.hpp" | #include "CarlaJuceUtils.hpp" | ||||
// Plugin Code | // Plugin Code | ||||
#include "distrho-kars/DistrhoArtworkKars.cpp" | |||||
#include "distrho-kars/DistrhoPluginKars.cpp" | #include "distrho-kars/DistrhoPluginKars.cpp" | ||||
#ifdef HAVE_DGL | |||||
#include "distrho-kars/DistrhoUIKars.cpp" | |||||
#endif | |||||
// DISTRHO Code | // DISTRHO Code | ||||
#define DISTRHO_PLUGIN_TARGET_CARLA | #define DISTRHO_PLUGIN_TARGET_CARLA | ||||
#include "DistrhoPluginMain.cpp" | #include "DistrhoPluginMain.cpp" | ||||
#ifdef HAVE_DGL | |||||
#include "DistrhoUIMain.cpp" | |||||
#endif | |||||
START_NAMESPACE_DISTRHO | START_NAMESPACE_DISTRHO | ||||
@@ -45,16 +32,8 @@ START_NAMESPACE_DISTRHO | |||||
static const NativePluginDescriptor karsDesc = { | static const NativePluginDescriptor karsDesc = { | ||||
/* category */ NATIVE_PLUGIN_CATEGORY_SYNTH, | /* category */ NATIVE_PLUGIN_CATEGORY_SYNTH, | ||||
#ifdef HAVE_DGL | |||||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | |||||
|NATIVE_PLUGIN_IS_SYNTH | |||||
|NATIVE_PLUGIN_HAS_UI | |||||
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |||||
|NATIVE_PLUGIN_USES_PARENT_ID), | |||||
#else | |||||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | ||||
|NATIVE_PLUGIN_IS_SYNTH), | |NATIVE_PLUGIN_IS_SYNTH), | ||||
#endif | |||||
/* supports */ NATIVE_PLUGIN_SUPPORTS_NOTHING, | /* supports */ NATIVE_PLUGIN_SUPPORTS_NOTHING, | ||||
/* audioIns */ DISTRHO_PLUGIN_NUM_INPUTS, | /* audioIns */ DISTRHO_PLUGIN_NUM_INPUTS, | ||||
/* audioOuts */ DISTRHO_PLUGIN_NUM_OUTPUTS, | /* audioOuts */ DISTRHO_PLUGIN_NUM_OUTPUTS, | ||||
@@ -1,20 +0,0 @@ | |||||
/* (Auto-generated binary data file). */ | |||||
#ifndef BINARY_DISTRHOARTWORKKARS_HPP | |||||
#define BINARY_DISTRHOARTWORKKARS_HPP | |||||
namespace DistrhoArtworkKars | |||||
{ | |||||
extern const char* backgroundData; | |||||
const unsigned int backgroundDataSize = 379260; | |||||
const unsigned int backgroundWidth = 301; | |||||
const unsigned int backgroundHeight = 315; | |||||
extern const char* switchData; | |||||
const unsigned int switchDataSize = 61952; | |||||
const unsigned int switchWidth = 88; | |||||
const unsigned int switchHeight = 176; | |||||
} | |||||
#endif // BINARY_DISTRHOARTWORKKARS_HPP | |||||
@@ -21,11 +21,10 @@ | |||||
#define DISTRHO_PLUGIN_NAME "Kars" | #define DISTRHO_PLUGIN_NAME "Kars" | ||||
#define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/Kars" | #define DISTRHO_PLUGIN_URI "http://distrho.sf.net/plugins/Kars" | ||||
#define DISTRHO_PLUGIN_HAS_UI 1 | |||||
#define DISTRHO_PLUGIN_HAS_UI 0 | |||||
#define DISTRHO_PLUGIN_IS_RT_SAFE 1 | #define DISTRHO_PLUGIN_IS_RT_SAFE 1 | ||||
#define DISTRHO_PLUGIN_IS_SYNTH 1 | #define DISTRHO_PLUGIN_IS_SYNTH 1 | ||||
#define DISTRHO_PLUGIN_NUM_INPUTS 0 | #define DISTRHO_PLUGIN_NUM_INPUTS 0 | ||||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 1 | #define DISTRHO_PLUGIN_NUM_OUTPUTS 1 | ||||
#define DISTRHO_PLUGIN_USES_MODGUI 1 | |||||
#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED |
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Kars Plugin, based on karplong by Chris Cannam. | * DISTRHO Kars Plugin, based on karplong by Chris Cannam. | ||||
* Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2015-2019 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | * 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 | * or without fee is hereby granted, provided that the above copyright notice and this | ||||
@@ -15,6 +15,7 @@ | |||||
*/ | */ | ||||
#include "DistrhoPluginKars.hpp" | #include "DistrhoPluginKars.hpp" | ||||
#include "DistrhoPluginUtils.hpp" | |||||
START_NAMESPACE_DISTRHO | START_NAMESPACE_DISTRHO | ||||
@@ -23,12 +24,14 @@ START_NAMESPACE_DISTRHO | |||||
DistrhoPluginKars::DistrhoPluginKars() | DistrhoPluginKars::DistrhoPluginKars() | ||||
: Plugin(paramCount, 0, 0), // 0 programs, 0 states | : Plugin(paramCount, 0, 0), // 0 programs, 0 states | ||||
fSustain(false), | fSustain(false), | ||||
fRelease(0.01), | |||||
fVolume(75.0f), | |||||
fSampleRate(getSampleRate()), | fSampleRate(getSampleRate()), | ||||
fBlockStart(0) | fBlockStart(0) | ||||
{ | { | ||||
for (int i=kMaxNotes; --i >= 0;) | for (int i=kMaxNotes; --i >= 0;) | ||||
{ | { | ||||
fNotes[i].index = i; | |||||
fNotes[i].voice = i; | |||||
fNotes[i].setSampleRate(fSampleRate); | fNotes[i].setSampleRate(fSampleRate); | ||||
} | } | ||||
} | } | ||||
@@ -38,15 +41,35 @@ DistrhoPluginKars::DistrhoPluginKars() | |||||
void DistrhoPluginKars::initParameter(uint32_t index, Parameter& parameter) | void DistrhoPluginKars::initParameter(uint32_t index, Parameter& parameter) | ||||
{ | { | ||||
if (index != 0) | |||||
return; | |||||
parameter.hints = kParameterIsAutomatable|kParameterIsBoolean; | |||||
parameter.name = "Sustain"; | |||||
parameter.symbol = "sustain"; | |||||
parameter.ranges.def = 0.0f; | |||||
parameter.ranges.min = 0.0f; | |||||
parameter.ranges.max = 1.0f; | |||||
switch (index) | |||||
{ | |||||
case paramSustain: | |||||
parameter.hints = kParameterIsAutomatable|kParameterIsBoolean; | |||||
parameter.name = "Sustain"; | |||||
parameter.symbol = "sustain"; | |||||
parameter.ranges.def = 0.0f; | |||||
parameter.ranges.min = 0.0f; | |||||
parameter.ranges.max = 1.0f; | |||||
break; | |||||
case paramRelease: | |||||
parameter.hints = kParameterIsAutomatable; | |||||
parameter.name = "Release"; | |||||
parameter.symbol = "release"; | |||||
parameter.unit = "s"; | |||||
parameter.ranges.def = 0.01f; | |||||
parameter.ranges.min = 0.0f; | |||||
parameter.ranges.max = 5.0f; | |||||
break; | |||||
case paramVolume: | |||||
parameter.hints = kParameterIsAutomatable; | |||||
parameter.name = "Volume"; | |||||
parameter.symbol = "volume"; | |||||
parameter.unit = "%"; | |||||
parameter.ranges.def = 75.0f; | |||||
parameter.ranges.min = 0.0f; | |||||
parameter.ranges.max = 100.0f; | |||||
break; | |||||
} | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -54,18 +77,30 @@ void DistrhoPluginKars::initParameter(uint32_t index, Parameter& parameter) | |||||
float DistrhoPluginKars::getParameterValue(uint32_t index) const | float DistrhoPluginKars::getParameterValue(uint32_t index) const | ||||
{ | { | ||||
if (index != 0) | |||||
return 0.0f; | |||||
switch (index) | |||||
{ | |||||
case paramSustain: return fSustain ? 1.0f : 0.0f; | |||||
case paramRelease: return fRelease; | |||||
case paramVolume: return fVolume; | |||||
} | |||||
return fSustain ? 1.0f : 0.0f; | |||||
return 0.0f; | |||||
} | } | ||||
void DistrhoPluginKars::setParameterValue(uint32_t index, float value) | void DistrhoPluginKars::setParameterValue(uint32_t index, float value) | ||||
{ | { | ||||
if (index != 0) | |||||
return; | |||||
fSustain = value > 0.5f; | |||||
switch (index) | |||||
{ | |||||
case paramSustain: | |||||
fSustain = value > 0.5f; | |||||
break; | |||||
case paramRelease: | |||||
fRelease = value; | |||||
break; | |||||
case paramVolume: | |||||
fVolume = value; | |||||
break; | |||||
} | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -86,16 +121,16 @@ void DistrhoPluginKars::activate() | |||||
void DistrhoPluginKars::run(const float* const*, float** outputs, uint32_t frames, const MidiEvent* midiEvents, uint32_t midiEventCount) | void DistrhoPluginKars::run(const float* const*, float** outputs, uint32_t frames, const MidiEvent* midiEvents, uint32_t midiEventCount) | ||||
{ | { | ||||
uint8_t note, velo; | uint8_t note, velo; | ||||
float* out = outputs[0]; | |||||
std::memset(outputs[0], 0, sizeof(float)*frames); | |||||
for (uint32_t count, pos=0, curEventIndex=0; pos<frames;) | |||||
for (AudioMidiSyncHelper amsh(outputs, frames, midiEvents, midiEventCount); amsh.nextEvent();) | |||||
{ | { | ||||
for (;curEventIndex < midiEventCount && pos >= midiEvents[curEventIndex].frame; ++curEventIndex) | |||||
for (uint32_t i=0; i<amsh.midiEventCount; ++i) | |||||
{ | { | ||||
if (midiEvents[curEventIndex].size > MidiEvent::kDataSize) | |||||
if (amsh.midiEvents[i].size > MidiEvent::kDataSize) | |||||
continue; | continue; | ||||
const uint8_t* data = midiEvents[curEventIndex].data; | |||||
const uint8_t* data = amsh.midiEvents[i].data; | |||||
const uint8_t status = data[0] & 0xF0; | const uint8_t status = data[0] & 0xF0; | ||||
switch (status) | switch (status) | ||||
@@ -106,7 +141,7 @@ void DistrhoPluginKars::run(const float* const*, float** outputs, uint32_t frame | |||||
DISTRHO_SAFE_ASSERT_BREAK(note < 128); // kMaxNotes | DISTRHO_SAFE_ASSERT_BREAK(note < 128); // kMaxNotes | ||||
if (velo > 0) | if (velo > 0) | ||||
{ | { | ||||
fNotes[note].on = fBlockStart + midiEvents[curEventIndex].frame; | |||||
fNotes[note].on = fBlockStart; | |||||
fNotes[note].off = kNoteNull; | fNotes[note].off = kNoteNull; | ||||
fNotes[note].velocity = velo; | fNotes[note].velocity = velo; | ||||
break; | break; | ||||
@@ -115,35 +150,26 @@ void DistrhoPluginKars::run(const float* const*, float** outputs, uint32_t frame | |||||
case 0x80: | case 0x80: | ||||
note = data[1]; | note = data[1]; | ||||
DISTRHO_SAFE_ASSERT_BREAK(note < 128); // kMaxNotes | DISTRHO_SAFE_ASSERT_BREAK(note < 128); // kMaxNotes | ||||
fNotes[note].off = fBlockStart + midiEvents[curEventIndex].frame; | |||||
fNotes[note].off = fBlockStart; | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (curEventIndex < midiEventCount && midiEvents[curEventIndex].frame < frames) | |||||
count = midiEvents[curEventIndex].frame - pos; | |||||
else | |||||
count = frames - pos; | |||||
std::memset(out+pos, 0, sizeof(float)*count); | |||||
//for (uint32_t i=0; i<count; ++i) | |||||
// out[pos + i] = 0.0f; | |||||
float* const out = amsh.outputs[0]; | |||||
for (int i=kMaxNotes; --i >= 0;) | for (int i=kMaxNotes; --i >= 0;) | ||||
{ | { | ||||
if (fNotes[i].on != kNoteNull) | if (fNotes[i].on != kNoteNull) | ||||
addSamples(out, i, pos, count); | |||||
addSamples(out, i, amsh.frames); | |||||
} | } | ||||
pos += count; | |||||
fBlockStart += amsh.frames; | |||||
} | } | ||||
fBlockStart += frames; | |||||
} | } | ||||
void DistrhoPluginKars::addSamples(float* out, int voice, uint32_t offset, uint32_t count) | |||||
void DistrhoPluginKars::addSamples(float* out, int voice, uint32_t frames) | |||||
{ | { | ||||
const uint32_t start = fBlockStart + offset; | |||||
const uint32_t start = fBlockStart; | |||||
Note& note(fNotes[voice]); | Note& note(fNotes[voice]); | ||||
@@ -162,7 +188,7 @@ void DistrhoPluginKars::addSamples(float* out, int voice, uint32_t offset, uint3 | |||||
float gain, sample; | float gain, sample; | ||||
uint32_t index, size; | uint32_t index, size; | ||||
for (uint32_t i=0, s=start-note.on; i<count; ++i, ++s) | |||||
for (uint32_t i=0, s=start-note.on; i<frames; ++i, ++s) | |||||
{ | { | ||||
gain = vgain; | gain = vgain; | ||||
@@ -170,8 +196,8 @@ void DistrhoPluginKars::addSamples(float* out, int voice, uint32_t offset, uint3 | |||||
{ | { | ||||
// reuse index and size to save some performance. | // reuse index and size to save some performance. | ||||
// actual values are release and dist | // actual values are release and dist | ||||
index = 1 + uint32_t(0.01 * fSampleRate); // release, not index | |||||
size = i + start - note.off; // dist, not size | |||||
index = 1 + uint32_t(fRelease * fSampleRate); // release, not index | |||||
size = i + start - note.off; // dist, not size | |||||
if (size > index) | if (size > index) | ||||
{ | { | ||||
@@ -198,7 +224,7 @@ void DistrhoPluginKars::addSamples(float* out, int voice, uint32_t offset, uint3 | |||||
note.wavetable[index] = sample/2; | note.wavetable[index] = sample/2; | ||||
} | } | ||||
out[offset+i] += gain * sample; | |||||
out[i] += gain * sample * (fVolume / 100.0f); | |||||
} | } | ||||
} | } | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Kars Plugin, based on karplong by Chris Cannam. | * DISTRHO Kars Plugin, based on karplong by Chris Cannam. | ||||
* Copyright (C) 2015 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2015-2019 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | * 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 | * or without fee is hereby granted, provided that the above copyright notice and this | ||||
@@ -32,6 +32,8 @@ public: | |||||
enum Parameters | enum Parameters | ||||
{ | { | ||||
paramSustain = 0, | paramSustain = 0, | ||||
paramRelease, | |||||
paramVolume, | |||||
paramCount | paramCount | ||||
}; | }; | ||||
@@ -68,7 +70,7 @@ protected: | |||||
uint32_t getVersion() const noexcept override | uint32_t getVersion() const noexcept override | ||||
{ | { | ||||
return d_version(1, 0, 0); | |||||
return d_version(1, 1, 0); | |||||
} | } | ||||
int64_t getUniqueId() const noexcept override | int64_t getUniqueId() const noexcept override | ||||
@@ -97,6 +99,8 @@ protected: | |||||
private: | private: | ||||
bool fSustain; | bool fSustain; | ||||
float fRelease; | |||||
float fVolume; | |||||
double fSampleRate; | double fSampleRate; | ||||
uint32_t fBlockStart; | uint32_t fBlockStart; | ||||
@@ -104,16 +108,16 @@ private: | |||||
uint32_t on; | uint32_t on; | ||||
uint32_t off; | uint32_t off; | ||||
uint8_t velocity; | uint8_t velocity; | ||||
float index; | |||||
float size; | |||||
int sizei; | |||||
float* wavetable; | |||||
float voice; | |||||
float size; | |||||
int sizei; | |||||
float* wavetable; | |||||
Note() noexcept | Note() noexcept | ||||
: on(kNoteNull), | : on(kNoteNull), | ||||
off(kNoteNull), | off(kNoteNull), | ||||
velocity(0), | velocity(0), | ||||
index(0.0f), | |||||
voice(0.0f), | |||||
size(0.0f), | size(0.0f), | ||||
wavetable(nullptr) {} | wavetable(nullptr) {} | ||||
@@ -131,7 +135,7 @@ private: | |||||
if (wavetable != nullptr) | if (wavetable != nullptr) | ||||
delete[] wavetable; | delete[] wavetable; | ||||
const float frequency = 440.0f * std::pow(2.0f, (index - 69.0f) / 12.0f); | |||||
const float frequency = 440.0f * std::pow(2.0f, (voice - 69.0f) / 12.0f); | |||||
size = sampleRate / frequency; | size = sampleRate / frequency; | ||||
sizei = int(size)+1; | sizei = int(size)+1; | ||||
wavetable = new float[sizei]; | wavetable = new float[sizei]; | ||||
@@ -140,7 +144,7 @@ private: | |||||
} fNotes[kMaxNotes]; | } fNotes[kMaxNotes]; | ||||
void addSamples(float* out, int voice, uint32_t offset, uint32_t count); | |||||
void addSamples(float* out, int voice, uint32_t frames); | |||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoPluginKars) | DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoPluginKars) | ||||
}; | }; | ||||
@@ -1,77 +0,0 @@ | |||||
/* | |||||
* DISTRHO Kars Plugin, based on karplong by Chris Cannam. | |||||
* Copyright (C) 2015 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. | |||||
*/ | |||||
#include "DistrhoPluginKars.hpp" | |||||
#include "DistrhoUIKars.hpp" | |||||
START_NAMESPACE_DISTRHO | |||||
namespace Art = DistrhoArtworkKars; | |||||
// ----------------------------------------------------------------------- | |||||
DistrhoUIKars::DistrhoUIKars() | |||||
: UI(Art::backgroundWidth, Art::backgroundHeight), | |||||
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight) | |||||
{ | |||||
// sustain switch | |||||
Image switchImageNormal(Art::switchData, Art::switchWidth, Art::switchHeight/2); | |||||
Image switchImageDown(Art::switchData+(Art::switchWidth*Art::switchHeight/2*4), Art::switchWidth, Art::switchHeight/2); | |||||
fSwitchSustain = new ImageSwitch(this, switchImageNormal, switchImageDown); | |||||
fSwitchSustain->setAbsolutePos(Art::backgroundWidth/2-Art::switchWidth/2, Art::backgroundHeight/2-Art::switchHeight/4); | |||||
fSwitchSustain->setId(DistrhoPluginKars::paramSustain); | |||||
fSwitchSustain->setCallback(this); | |||||
} | |||||
// ----------------------------------------------------------------------- | |||||
// DSP Callbacks | |||||
void DistrhoUIKars::parameterChanged(uint32_t index, float value) | |||||
{ | |||||
if (index != 0) | |||||
return; | |||||
fSwitchSustain->setDown(value > 0.5f); | |||||
} | |||||
// ----------------------------------------------------------------------- | |||||
// Widget Callbacks | |||||
void DistrhoUIKars::imageSwitchClicked(ImageSwitch* imageSwitch, bool down) | |||||
{ | |||||
if (imageSwitch != fSwitchSustain) | |||||
return; | |||||
editParameter(DistrhoPluginKars::paramSustain, true); | |||||
setParameterValue(DistrhoPluginKars::paramSustain, down ? 1.0f : 0.0f); | |||||
editParameter(DistrhoPluginKars::paramSustain, false); | |||||
} | |||||
void DistrhoUIKars::onDisplay() | |||||
{ | |||||
fImgBackground.draw(); | |||||
} | |||||
// ----------------------------------------------------------------------- | |||||
UI* createUI() | |||||
{ | |||||
return new DistrhoUIKars(); | |||||
} | |||||
// ----------------------------------------------------------------------- | |||||
END_NAMESPACE_DISTRHO |
@@ -1,60 +0,0 @@ | |||||
/* | |||||
* DISTRHO Kars Plugin, based on karplong by Chris Cannam. | |||||
* Copyright (C) 2015 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. | |||||
*/ | |||||
#ifndef DISTRHO_UI_KARS_HPP_INCLUDED | |||||
#define DISTRHO_UI_KARS_HPP_INCLUDED | |||||
#include "DistrhoUI.hpp" | |||||
#include "ImageWidgets.hpp" | |||||
#include "DistrhoArtworkKars.hpp" | |||||
START_NAMESPACE_DISTRHO | |||||
// ----------------------------------------------------------------------- | |||||
class DistrhoUIKars : public UI, | |||||
public ImageSwitch::Callback | |||||
{ | |||||
public: | |||||
DistrhoUIKars(); | |||||
protected: | |||||
// ------------------------------------------------------------------- | |||||
// DSP Callbacks | |||||
void parameterChanged(uint32_t index, float value) override; | |||||
// ------------------------------------------------------------------- | |||||
// Widget Callbacks | |||||
void imageSwitchClicked(ImageSwitch* imageSwitch, bool down) override; | |||||
void onDisplay() override; | |||||
private: | |||||
Image fImgBackground; | |||||
ScopedPointer<ImageSwitch> fSwitchSustain; | |||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DistrhoUIKars) | |||||
}; | |||||
// ----------------------------------------------------------------------- | |||||
END_NAMESPACE_DISTRHO | |||||
#endif // DISTRHO_UI_KARS_HPP_INCLUDED |
@@ -26,16 +26,16 @@ | |||||
#include "CarlaJuceUtils.hpp" | #include "CarlaJuceUtils.hpp" | ||||
// Plugin Code | // Plugin Code | ||||
#include "distrho-nekobi/DistrhoArtworkNekobi.cpp" | |||||
#include "distrho-nekobi/DistrhoPluginNekobi.cpp" | #include "distrho-nekobi/DistrhoPluginNekobi.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "distrho-nekobi/DistrhoArtworkNekobi.cpp" | |||||
#include "distrho-nekobi/DistrhoUINekobi.cpp" | #include "distrho-nekobi/DistrhoUINekobi.cpp" | ||||
#endif | #endif | ||||
// DISTRHO Code | // DISTRHO Code | ||||
#define DISTRHO_PLUGIN_TARGET_CARLA | #define DISTRHO_PLUGIN_TARGET_CARLA | ||||
#include "DistrhoPluginMain.cpp" | #include "DistrhoPluginMain.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "DistrhoUIMain.cpp" | #include "DistrhoUIMain.cpp" | ||||
#endif | #endif | ||||
@@ -45,7 +45,7 @@ START_NAMESPACE_DISTRHO | |||||
static const NativePluginDescriptor nekobiDesc = { | static const NativePluginDescriptor nekobiDesc = { | ||||
/* category */ NATIVE_PLUGIN_CATEGORY_SYNTH, | /* category */ NATIVE_PLUGIN_CATEGORY_SYNTH, | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | ||||
|NATIVE_PLUGIN_IS_SYNTH | |NATIVE_PLUGIN_IS_SYNTH | ||||
|NATIVE_PLUGIN_HAS_UI | |NATIVE_PLUGIN_HAS_UI | ||||
@@ -27,6 +27,5 @@ | |||||
#define DISTRHO_PLUGIN_IS_SYNTH 1 | #define DISTRHO_PLUGIN_IS_SYNTH 1 | ||||
#define DISTRHO_PLUGIN_NUM_INPUTS 0 | #define DISTRHO_PLUGIN_NUM_INPUTS 0 | ||||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 1 | #define DISTRHO_PLUGIN_NUM_OUTPUTS 1 | ||||
#define DISTRHO_PLUGIN_USES_MODGUI 1 | |||||
#endif // DISTRHO_PLUGIN_INFO_H_INCLUDED | #endif // DISTRHO_PLUGIN_INFO_H_INCLUDED |
@@ -135,7 +135,6 @@ DistrhoPluginNekobi::DistrhoPluginNekobi() | |||||
fParams.decay = 75.0f; | fParams.decay = 75.0f; | ||||
fParams.accent = 25.0f; | fParams.accent = 25.0f; | ||||
fParams.volume = 75.0f; | fParams.volume = 75.0f; | ||||
fParams.bypass = false; | |||||
// Internal stuff | // Internal stuff | ||||
fSynth.waveform = 0.0f; | fSynth.waveform = 0.0f; | ||||
@@ -172,6 +171,7 @@ void DistrhoPluginNekobi::initParameter(uint32_t index, Parameter& parameter) | |||||
parameter.ranges.max = 1.0f; | parameter.ranges.max = 1.0f; | ||||
parameter.enumValues.count = 2; | parameter.enumValues.count = 2; | ||||
parameter.enumValues.restrictedMode = true; | parameter.enumValues.restrictedMode = true; | ||||
parameter.midiCC = 70; //Sound Variation | |||||
{ | { | ||||
ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[2]; | ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[2]; | ||||
enumValues[0].value = 0.0f; | enumValues[0].value = 0.0f; | ||||
@@ -188,6 +188,7 @@ void DistrhoPluginNekobi::initParameter(uint32_t index, Parameter& parameter) | |||||
parameter.ranges.def = 0.0f; | parameter.ranges.def = 0.0f; | ||||
parameter.ranges.min = -12.0f; | parameter.ranges.min = -12.0f; | ||||
parameter.ranges.max = 12.0f; | parameter.ranges.max = 12.0f; | ||||
parameter.midiCC = 75; | |||||
break; | break; | ||||
case paramCutoff: | case paramCutoff: | ||||
parameter.hints = kParameterIsAutomatable; // modified x2.5 | parameter.hints = kParameterIsAutomatable; // modified x2.5 | ||||
@@ -197,6 +198,7 @@ void DistrhoPluginNekobi::initParameter(uint32_t index, Parameter& parameter) | |||||
parameter.ranges.def = 25.0f; | parameter.ranges.def = 25.0f; | ||||
parameter.ranges.min = 0.0f; | parameter.ranges.min = 0.0f; | ||||
parameter.ranges.max = 100.0f; | parameter.ranges.max = 100.0f; | ||||
parameter.midiCC = 74; | |||||
break; | break; | ||||
case paramResonance: | case paramResonance: | ||||
parameter.hints = kParameterIsAutomatable; // modified x100 | parameter.hints = kParameterIsAutomatable; // modified x100 | ||||
@@ -206,6 +208,7 @@ void DistrhoPluginNekobi::initParameter(uint32_t index, Parameter& parameter) | |||||
parameter.ranges.def = 25.0f; | parameter.ranges.def = 25.0f; | ||||
parameter.ranges.min = 0.0f; | parameter.ranges.min = 0.0f; | ||||
parameter.ranges.max = 95.0f; | parameter.ranges.max = 95.0f; | ||||
parameter.midiCC = 71; | |||||
break; | break; | ||||
case paramEnvMod: | case paramEnvMod: | ||||
parameter.hints = kParameterIsAutomatable; // modified x100 | parameter.hints = kParameterIsAutomatable; // modified x100 | ||||
@@ -215,6 +218,7 @@ void DistrhoPluginNekobi::initParameter(uint32_t index, Parameter& parameter) | |||||
parameter.ranges.def = 50.0f; | parameter.ranges.def = 50.0f; | ||||
parameter.ranges.min = 0.0f; | parameter.ranges.min = 0.0f; | ||||
parameter.ranges.max = 100.0f; | parameter.ranges.max = 100.0f; | ||||
parameter.midiCC = 1; //Mod Wheel | |||||
break; | break; | ||||
case paramDecay: | case paramDecay: | ||||
parameter.hints = kParameterIsAutomatable; // was 0.000009 <-> 0.0005, log | parameter.hints = kParameterIsAutomatable; // was 0.000009 <-> 0.0005, log | ||||
@@ -224,6 +228,7 @@ void DistrhoPluginNekobi::initParameter(uint32_t index, Parameter& parameter) | |||||
parameter.ranges.def = 75.0f; | parameter.ranges.def = 75.0f; | ||||
parameter.ranges.min = 0.0f; | parameter.ranges.min = 0.0f; | ||||
parameter.ranges.max = 100.0f; | parameter.ranges.max = 100.0f; | ||||
parameter.midiCC = 72; | |||||
break; | break; | ||||
case paramAccent: | case paramAccent: | ||||
parameter.hints = kParameterIsAutomatable; // modified x100 | parameter.hints = kParameterIsAutomatable; // modified x100 | ||||
@@ -233,6 +238,7 @@ void DistrhoPluginNekobi::initParameter(uint32_t index, Parameter& parameter) | |||||
parameter.ranges.def = 25.0f; | parameter.ranges.def = 25.0f; | ||||
parameter.ranges.min = 0.0f; | parameter.ranges.min = 0.0f; | ||||
parameter.ranges.max = 100.0f; | parameter.ranges.max = 100.0f; | ||||
parameter.midiCC = 76; | |||||
break; | break; | ||||
case paramVolume: | case paramVolume: | ||||
parameter.hints = kParameterIsAutomatable; // modified x100 | parameter.hints = kParameterIsAutomatable; // modified x100 | ||||
@@ -242,9 +248,7 @@ void DistrhoPluginNekobi::initParameter(uint32_t index, Parameter& parameter) | |||||
parameter.ranges.def = 75.0f; | parameter.ranges.def = 75.0f; | ||||
parameter.ranges.min = 0.0f; | parameter.ranges.min = 0.0f; | ||||
parameter.ranges.max = 100.0f; | parameter.ranges.max = 100.0f; | ||||
break; | |||||
case paramBypass: | |||||
parameter.initDesignation(kParameterDesignationBypass); | |||||
parameter.midiCC = 7; //Volume | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -272,8 +276,6 @@ float DistrhoPluginNekobi::getParameterValue(uint32_t index) const | |||||
return fParams.accent; | return fParams.accent; | ||||
case paramVolume: | case paramVolume: | ||||
return fParams.volume; | return fParams.volume; | ||||
case paramBypass: | |||||
return fParams.bypass ? 1.0f : 0.0f; | |||||
} | } | ||||
return 0.0f; | return 0.0f; | ||||
@@ -323,14 +325,6 @@ void DistrhoPluginNekobi::setParameterValue(uint32_t index, float value) | |||||
fSynth.volume = value/100.0f; | fSynth.volume = value/100.0f; | ||||
DISTRHO_SAFE_ASSERT(fSynth.volume >= 0.0f && fSynth.volume <= 1.0f); | DISTRHO_SAFE_ASSERT(fSynth.volume >= 0.0f && fSynth.volume <= 1.0f); | ||||
break; | break; | ||||
case paramBypass: { | |||||
const bool bypass = (value > 0.5f); | |||||
if (fParams.bypass != bypass) | |||||
{ | |||||
fParams.bypass = bypass; | |||||
nekobee_synth_all_voices_off(&fSynth); | |||||
} | |||||
} break; | |||||
} | } | ||||
} | } | ||||
@@ -366,10 +360,6 @@ void DistrhoPluginNekobi::run(const float* const*, float** outputs, uint32_t fra | |||||
return; | return; | ||||
} | } | ||||
// ignore midi input if bypassed | |||||
if (fParams.bypass) | |||||
midiEventCount = 0; | |||||
while (framesDone < frames) | while (framesDone < frames) | ||||
{ | { | ||||
if (fSynth.nugget_remains == 0) | if (fSynth.nugget_remains == 0) | ||||
@@ -42,7 +42,6 @@ public: | |||||
paramDecay, | paramDecay, | ||||
paramAccent, | paramAccent, | ||||
paramVolume, | paramVolume, | ||||
paramBypass, | |||||
paramCount | paramCount | ||||
}; | }; | ||||
@@ -118,7 +117,6 @@ private: | |||||
float decay; | float decay; | ||||
float accent; | float accent; | ||||
float volume; | float volume; | ||||
bool bypass; | |||||
} fParams; | } fParams; | ||||
nekobee_synth_t fSynth; | nekobee_synth_t fSynth; | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others. | * DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others. | ||||
* Copyright (C) 2013-2015 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -25,19 +25,16 @@ namespace Art = DistrhoArtworkNekobi; | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
DistrhoUINekobi::DistrhoUINekobi() | DistrhoUINekobi::DistrhoUINekobi() | ||||
: UI(Art::backgroundWidth, Art::backgroundHeight), | |||||
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR), | |||||
: UI(Art::backgroundWidth, Art::backgroundHeight, true), | |||||
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, kImageFormatBGR), | |||||
fAboutWindow(this) | fAboutWindow(this) | ||||
{ | { | ||||
// FIXME | |||||
fNeko.setTimerSpeed(5); | |||||
// about | // about | ||||
Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR); | |||||
Image aboutImage(Art::aboutData, Art::aboutWidth, Art::aboutHeight, kImageFormatBGR); | |||||
fAboutWindow.setImage(aboutImage); | fAboutWindow.setImage(aboutImage); | ||||
// slider | // slider | ||||
Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight); | |||||
Image sliderImage(Art::sliderData, Art::sliderWidth, Art::sliderHeight, kImageFormatBGRA); | |||||
fSliderWaveform = new ImageSlider(this, sliderImage); | fSliderWaveform = new ImageSlider(this, sliderImage); | ||||
fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform); | fSliderWaveform->setId(DistrhoPluginNekobi::paramWaveform); | ||||
@@ -49,7 +46,7 @@ DistrhoUINekobi::DistrhoUINekobi() | |||||
fSliderWaveform->setCallback(this); | fSliderWaveform->setCallback(this); | ||||
// knobs | // knobs | ||||
Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight); | |||||
Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight, kImageFormatBGRA); | |||||
// knob Tuning | // knob Tuning | ||||
fKnobTuning = new ImageKnob(this, knobImage, ImageKnob::Vertical); | fKnobTuning = new ImageKnob(this, knobImage, ImageKnob::Vertical); | ||||
@@ -122,11 +119,19 @@ DistrhoUINekobi::DistrhoUINekobi() | |||||
fKnobVolume->setCallback(this); | fKnobVolume->setCallback(this); | ||||
// about button | // about button | ||||
Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight); | |||||
Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight); | |||||
Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight, kImageFormatBGRA); | |||||
Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight, kImageFormatBGRA); | |||||
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | ||||
fButtonAbout->setAbsolutePos(505, 5); | fButtonAbout->setAbsolutePos(505, 5); | ||||
fButtonAbout->setCallback(this); | fButtonAbout->setCallback(this); | ||||
// neko animation | |||||
addIdleCallback(this, 120); | |||||
} | |||||
DistrhoUINekobi::~DistrhoUINekobi() | |||||
{ | |||||
removeIdleCallback(this); | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -163,15 +168,6 @@ void DistrhoUINekobi::parameterChanged(uint32_t index, float value) | |||||
} | } | ||||
} | } | ||||
// ----------------------------------------------------------------------- | |||||
// UI Callbacks | |||||
void DistrhoUINekobi::uiIdle() | |||||
{ | |||||
if (fNeko.idle()) | |||||
repaint(); | |||||
} | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
// Widget Callbacks | // Widget Callbacks | ||||
@@ -180,7 +176,7 @@ void DistrhoUINekobi::imageButtonClicked(ImageButton* button, int) | |||||
if (button != fButtonAbout) | if (button != fButtonAbout) | ||||
return; | return; | ||||
fAboutWindow.exec(); | |||||
fAboutWindow.runAsModal(); | |||||
} | } | ||||
void DistrhoUINekobi::imageKnobDragStarted(ImageKnob* knob) | void DistrhoUINekobi::imageKnobDragStarted(ImageKnob* knob) | ||||
@@ -215,8 +211,19 @@ void DistrhoUINekobi::imageSliderValueChanged(ImageSlider* slider, float value) | |||||
void DistrhoUINekobi::onDisplay() | void DistrhoUINekobi::onDisplay() | ||||
{ | { | ||||
fImgBackground.draw(); | |||||
fNeko.draw(); | |||||
const GraphicsContext& context(getGraphicsContext()); | |||||
fImgBackground.draw(context); | |||||
fNeko.draw(context); | |||||
} | |||||
// ----------------------------------------------------------------------- | |||||
// Other Callbacks | |||||
void DistrhoUINekobi::idleCallback() | |||||
{ | |||||
if (fNeko.idle()) | |||||
repaint(); | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others. | * DISTRHO Nekobi Plugin, based on Nekobee by Sean Bolton and others. | ||||
* Copyright (C) 2013-2015 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -37,10 +37,12 @@ START_NAMESPACE_DISTRHO | |||||
class DistrhoUINekobi : public UI, | class DistrhoUINekobi : public UI, | ||||
public ImageButton::Callback, | public ImageButton::Callback, | ||||
public ImageKnob::Callback, | public ImageKnob::Callback, | ||||
public ImageSlider::Callback | |||||
public ImageSlider::Callback, | |||||
public IdleCallback | |||||
{ | { | ||||
public: | public: | ||||
DistrhoUINekobi(); | DistrhoUINekobi(); | ||||
~DistrhoUINekobi() override; | |||||
protected: | protected: | ||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
@@ -48,11 +50,6 @@ protected: | |||||
void parameterChanged(uint32_t index, float value) override; | void parameterChanged(uint32_t index, float value) override; | ||||
// ------------------------------------------------------------------- | |||||
// UI Callbacks | |||||
void uiIdle() override; | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
// Widget Callbacks | // Widget Callbacks | ||||
@@ -66,6 +63,11 @@ protected: | |||||
void onDisplay() override; | void onDisplay() override; | ||||
// ------------------------------------------------------------------- | |||||
// Other Callbacks | |||||
void idleCallback() override; | |||||
private: | private: | ||||
Image fImgBackground; | Image fImgBackground; | ||||
ImageAboutWindow fAboutWindow; | ImageAboutWindow fAboutWindow; | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* Neko widget animation | * Neko widget animation | ||||
* Copyright (C) 2013-2015 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2013-2021 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
@@ -21,7 +21,6 @@ | |||||
#include "DistrhoArtworkNekobi.hpp" | #include "DistrhoArtworkNekobi.hpp" | ||||
#include "Image.hpp" | #include "Image.hpp" | ||||
#include "Widget.hpp" | |||||
#include <cstdlib> // rand | #include <cstdlib> // rand | ||||
@@ -35,7 +34,6 @@ public: | |||||
NekoWidget() | NekoWidget() | ||||
: fPos(0), | : fPos(0), | ||||
fTimer(0), | fTimer(0), | ||||
fTimerSpeed(20), | |||||
fCurAction(kActionNone), | fCurAction(kActionNone), | ||||
fCurImage(&fImages.sit) | fCurImage(&fImages.sit) | ||||
{ | { | ||||
@@ -62,7 +60,7 @@ public: | |||||
} | } | ||||
} | } | ||||
void draw() | |||||
void draw(const GraphicsContext& context) | |||||
{ | { | ||||
int x = fPos+108; | int x = fPos+108; | ||||
int y = -2; | int y = -2; | ||||
@@ -73,16 +71,13 @@ public: | |||||
y += 12; | y += 12; | ||||
} | } | ||||
fCurImage->drawAt(x, y); | |||||
fCurImage->drawAt(context, x, y); | |||||
} | } | ||||
// returns true if needs repaint | // returns true if needs repaint | ||||
bool idle() | bool idle() | ||||
{ | { | ||||
if (++fTimer % fTimerSpeed != 0) // target is 20ms | |||||
return false; | |||||
if (fTimer == fTimerSpeed*9) | |||||
if (++fTimer == 10) | |||||
{ | { | ||||
if (fCurAction == kActionNone) | if (fCurAction == kActionNone) | ||||
fCurAction = static_cast<Action>(std::rand() % kActionCount); | fCurAction = static_cast<Action>(std::rand() % kActionCount); | ||||
@@ -158,12 +153,6 @@ public: | |||||
return true; | return true; | ||||
} | } | ||||
void setTimerSpeed(int speed) | |||||
{ | |||||
fTimer = 0; | |||||
fTimerSpeed = speed; | |||||
} | |||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
private: | private: | ||||
@@ -191,7 +180,6 @@ private: | |||||
int fPos; | int fPos; | ||||
int fTimer; | int fTimer; | ||||
int fTimerSpeed; | |||||
Action fCurAction; | Action fCurAction; | ||||
Image* fCurImage; | Image* fCurImage; | ||||
@@ -27,16 +27,16 @@ | |||||
#include "CarlaJuceUtils.hpp" | #include "CarlaJuceUtils.hpp" | ||||
// Plugin Code | // Plugin Code | ||||
#include "distrho-pingpongpan/DistrhoArtworkPingPongPan.cpp" | |||||
#include "distrho-pingpongpan/DistrhoPluginPingPongPan.cpp" | #include "distrho-pingpongpan/DistrhoPluginPingPongPan.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "distrho-pingpongpan/DistrhoArtworkPingPongPan.cpp" | |||||
#include "distrho-pingpongpan/DistrhoUIPingPongPan.cpp" | #include "distrho-pingpongpan/DistrhoUIPingPongPan.cpp" | ||||
#endif | #endif | ||||
// DISTRHO Code | // DISTRHO Code | ||||
#define DISTRHO_PLUGIN_TARGET_CARLA | #define DISTRHO_PLUGIN_TARGET_CARLA | ||||
#include "DistrhoPluginMain.cpp" | #include "DistrhoPluginMain.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "DistrhoUIMain.cpp" | #include "DistrhoUIMain.cpp" | ||||
#endif | #endif | ||||
@@ -46,7 +46,7 @@ START_NAMESPACE_DISTRHO | |||||
static const NativePluginDescriptor pingpongpanDesc = { | static const NativePluginDescriptor pingpongpanDesc = { | ||||
/* category */ NATIVE_PLUGIN_CATEGORY_UTILITY, | /* category */ NATIVE_PLUGIN_CATEGORY_UTILITY, | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | ||||
|NATIVE_PLUGIN_HAS_UI | |NATIVE_PLUGIN_HAS_UI | ||||
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | ||||
@@ -26,7 +26,6 @@ | |||||
#define DISTRHO_PLUGIN_NUM_INPUTS 2 | #define DISTRHO_PLUGIN_NUM_INPUTS 2 | ||||
#define DISTRHO_PLUGIN_NUM_OUTPUTS 2 | #define DISTRHO_PLUGIN_NUM_OUTPUTS 2 | ||||
#define DISTRHO_PLUGIN_WANT_PROGRAMS 1 | #define DISTRHO_PLUGIN_WANT_PROGRAMS 1 | ||||
#define DISTRHO_PLUGIN_USES_MODGUI 1 | |||||
#define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:SpatialPlugin" | #define DISTRHO_PLUGIN_LV2_CATEGORY "lv2:SpatialPlugin" | ||||
@@ -1,6 +1,6 @@ | |||||
/* | /* | ||||
* DISTRHO PingPongPan Plugin, based on PingPongPan by Michael Gruhn | * DISTRHO PingPongPan Plugin, based on PingPongPan by Michael Gruhn | ||||
* Copyright (C) 2012-2015 Filipe Coelho <falktx@falktx.com> | |||||
* Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com> | |||||
* | * | ||||
* This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
* modify it under the terms of the GNU Lesser General Public | * modify it under the terms of the GNU Lesser General Public | ||||
@@ -24,16 +24,16 @@ namespace Art = DistrhoArtworkPingPongPan; | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
DistrhoUIPingPongPan::DistrhoUIPingPongPan() | DistrhoUIPingPongPan::DistrhoUIPingPongPan() | ||||
: UI(Art::backgroundWidth, Art::backgroundHeight), | |||||
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, GL_BGR), | |||||
: UI(Art::backgroundWidth, Art::backgroundHeight, true), | |||||
fImgBackground(Art::backgroundData, Art::backgroundWidth, Art::backgroundHeight, kImageFormatBGR), | |||||
fAboutWindow(this) | fAboutWindow(this) | ||||
{ | { | ||||
// about | // about | ||||
Image imageAbout(Art::aboutData, Art::aboutWidth, Art::aboutHeight, GL_BGR); | |||||
Image imageAbout(Art::aboutData, Art::aboutWidth, Art::aboutHeight, kImageFormatBGR); | |||||
fAboutWindow.setImage(imageAbout); | fAboutWindow.setImage(imageAbout); | ||||
// knobs | // knobs | ||||
Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight); | |||||
Image knobImage(Art::knobData, Art::knobWidth, Art::knobHeight, kImageFormatBGRA); | |||||
// knob Low-Mid | // knob Low-Mid | ||||
fKnobFreq = new ImageKnob(this, knobImage, ImageKnob::Vertical); | fKnobFreq = new ImageKnob(this, knobImage, ImageKnob::Vertical); | ||||
@@ -54,8 +54,8 @@ DistrhoUIPingPongPan::DistrhoUIPingPongPan() | |||||
fKnobWidth->setCallback(this); | fKnobWidth->setCallback(this); | ||||
// about button | // about button | ||||
Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight); | |||||
Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight); | |||||
Image aboutImageNormal(Art::aboutButtonNormalData, Art::aboutButtonNormalWidth, Art::aboutButtonNormalHeight, kImageFormatBGRA); | |||||
Image aboutImageHover(Art::aboutButtonHoverData, Art::aboutButtonHoverWidth, Art::aboutButtonHoverHeight, kImageFormatBGRA); | |||||
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | ||||
fButtonAbout->setAbsolutePos(183, 8); | fButtonAbout->setAbsolutePos(183, 8); | ||||
fButtonAbout->setCallback(this); | fButtonAbout->setCallback(this); | ||||
@@ -98,7 +98,7 @@ void DistrhoUIPingPongPan::imageButtonClicked(ImageButton* button, int) | |||||
if (button != fButtonAbout) | if (button != fButtonAbout) | ||||
return; | return; | ||||
fAboutWindow.exec(); | |||||
fAboutWindow.runAsModal(); | |||||
} | } | ||||
void DistrhoUIPingPongPan::imageKnobDragStarted(ImageKnob* knob) | void DistrhoUIPingPongPan::imageKnobDragStarted(ImageKnob* knob) | ||||
@@ -118,7 +118,9 @@ void DistrhoUIPingPongPan::imageKnobValueChanged(ImageKnob* knob, float value) | |||||
void DistrhoUIPingPongPan::onDisplay() | void DistrhoUIPingPongPan::onDisplay() | ||||
{ | { | ||||
fImgBackground.draw(); | |||||
const GraphicsContext& context(getGraphicsContext()); | |||||
fImgBackground.draw(context); | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
@@ -28,7 +28,7 @@ | |||||
// Plugin Code | // Plugin Code | ||||
#include "distrho-vectorjuice/VectorJuicePlugin.cpp" | #include "distrho-vectorjuice/VectorJuicePlugin.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "distrho-vectorjuice/VectorJuiceArtwork.cpp" | #include "distrho-vectorjuice/VectorJuiceArtwork.cpp" | ||||
#include "distrho-vectorjuice/VectorJuiceUI.cpp" | #include "distrho-vectorjuice/VectorJuiceUI.cpp" | ||||
#endif | #endif | ||||
@@ -36,7 +36,7 @@ | |||||
// DISTRHO Code | // DISTRHO Code | ||||
#define DISTRHO_PLUGIN_TARGET_CARLA | #define DISTRHO_PLUGIN_TARGET_CARLA | ||||
#include "DistrhoPluginMain.cpp" | #include "DistrhoPluginMain.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "DistrhoUIMain.cpp" | #include "DistrhoUIMain.cpp" | ||||
#endif | #endif | ||||
@@ -46,7 +46,7 @@ START_NAMESPACE_DISTRHO | |||||
static const NativePluginDescriptor vectorjuiceDesc = { | static const NativePluginDescriptor vectorjuiceDesc = { | ||||
/* category */ NATIVE_PLUGIN_CATEGORY_UTILITY, | /* category */ NATIVE_PLUGIN_CATEGORY_UTILITY, | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | ||||
|NATIVE_PLUGIN_HAS_UI | |NATIVE_PLUGIN_HAS_UI | ||||
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | ||||
@@ -25,11 +25,9 @@ START_NAMESPACE_DISTRHO | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
VectorJuiceUI::VectorJuiceUI() | VectorJuiceUI::VectorJuiceUI() | ||||
: UI(), | |||||
: UI(VectorJuiceArtwork::backgroundWidth, VectorJuiceArtwork::backgroundHeight, true), | |||||
fAboutWindow(this) | fAboutWindow(this) | ||||
{ | { | ||||
setSize(VectorJuiceArtwork::backgroundWidth, VectorJuiceArtwork::backgroundHeight); | |||||
// xy params | // xy params | ||||
paramX = paramY = 0.5f; | paramX = paramY = 0.5f; | ||||
@@ -44,7 +42,7 @@ VectorJuiceUI::VectorJuiceUI() | |||||
fCanvasArea.setSize(368-24, 368-24); | fCanvasArea.setSize(368-24, 368-24); | ||||
// background | // background | ||||
fImgBackground = Image(VectorJuiceArtwork::backgroundData, VectorJuiceArtwork::backgroundWidth, VectorJuiceArtwork::backgroundHeight, GL_BGR); | |||||
fImgBackground = Image(VectorJuiceArtwork::backgroundData, VectorJuiceArtwork::backgroundWidth, VectorJuiceArtwork::backgroundHeight, kImageFormatBGR); | |||||
//roundlet | //roundlet | ||||
fImgRoundlet = Image(VectorJuiceArtwork::roundletData, VectorJuiceArtwork::roundletWidth, VectorJuiceArtwork::roundletHeight); | fImgRoundlet = Image(VectorJuiceArtwork::roundletData, VectorJuiceArtwork::roundletWidth, VectorJuiceArtwork::roundletHeight); | ||||
@@ -56,7 +54,7 @@ VectorJuiceUI::VectorJuiceUI() | |||||
fImgSubOrbit = Image(VectorJuiceArtwork::subOrbitData, VectorJuiceArtwork::subOrbitWidth, VectorJuiceArtwork::subOrbitHeight); | fImgSubOrbit = Image(VectorJuiceArtwork::subOrbitData, VectorJuiceArtwork::subOrbitWidth, VectorJuiceArtwork::subOrbitHeight); | ||||
// about | // about | ||||
Image aboutImage(VectorJuiceArtwork::aboutData, VectorJuiceArtwork::aboutWidth, VectorJuiceArtwork::aboutHeight, GL_BGR); | |||||
Image aboutImage(VectorJuiceArtwork::aboutData, VectorJuiceArtwork::aboutWidth, VectorJuiceArtwork::aboutHeight, kImageFormatBGR); | |||||
fAboutWindow.setImage(aboutImage); | fAboutWindow.setImage(aboutImage); | ||||
// about button | // about button | ||||
@@ -303,7 +301,7 @@ void VectorJuiceUI::imageButtonClicked(ImageButton* button, int) | |||||
if (button != fButtonAbout) | if (button != fButtonAbout) | ||||
return; | return; | ||||
fAboutWindow.exec(); | |||||
fAboutWindow.runAsModal(); | |||||
} | } | ||||
void VectorJuiceUI::imageKnobDragStarted(ImageKnob* knob) | void VectorJuiceUI::imageKnobDragStarted(ImageKnob* knob) | ||||
@@ -338,15 +336,17 @@ void VectorJuiceUI::imageSliderValueChanged(ImageSlider* slider, float value) | |||||
void VectorJuiceUI::onDisplay() | void VectorJuiceUI::onDisplay() | ||||
{ | { | ||||
fImgBackground.draw(); | |||||
const GraphicsContext& context(getGraphicsContext()); | |||||
fImgBackground.draw(context); | |||||
// get x, y mapped to XY area | // get x, y mapped to XY area | ||||
int x = fCanvasArea.getX() + paramX*fCanvasArea.getWidth() - fImgRoundlet.getWidth()/2; | |||||
int y = fCanvasArea.getY() + paramY*fCanvasArea.getHeight() - fImgRoundlet.getHeight()/2; | |||||
int nOrbitX = fCanvasArea.getX()+((orbitX)*fCanvasArea.getWidth())-15; | |||||
int nOrbitY = fCanvasArea.getY()+((orbitY)*fCanvasArea.getWidth())-15; | |||||
int nSubOrbitX = fCanvasArea.getX()+(subOrbitX*fCanvasArea.getWidth())-15; | |||||
int nSubOrbitY = fCanvasArea.getY()+(subOrbitY*fCanvasArea.getWidth())-14; | |||||
const int x = fCanvasArea.getX() + paramX*fCanvasArea.getWidth() - fImgRoundlet.getWidth()/2; | |||||
const int y = fCanvasArea.getY() + paramY*fCanvasArea.getHeight() - fImgRoundlet.getHeight()/2; | |||||
const int nOrbitX = fCanvasArea.getX()+((orbitX)*fCanvasArea.getWidth())-15; | |||||
const int nOrbitY = fCanvasArea.getY()+((orbitY)*fCanvasArea.getWidth())-15; | |||||
const int nSubOrbitX = fCanvasArea.getX()+(subOrbitX*fCanvasArea.getWidth())-15; | |||||
const int nSubOrbitY = fCanvasArea.getY()+(subOrbitY*fCanvasArea.getWidth())-14; | |||||
//draw lines, just for fun | //draw lines, just for fun | ||||
glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
@@ -362,13 +362,10 @@ void VectorJuiceUI::onDisplay() | |||||
glVertex2i(nSubOrbitX+15, nSubOrbitY+14); | glVertex2i(nSubOrbitX+15, nSubOrbitY+14); | ||||
glEnd(); | glEnd(); | ||||
// reset color | |||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | |||||
// draw roundlet and orbits | // draw roundlet and orbits | ||||
fImgRoundlet.drawAt(x, y); | |||||
fImgOrbit.drawAt(nOrbitX, nOrbitY); | |||||
fImgSubOrbit.drawAt(nSubOrbitX, nSubOrbitY); | |||||
fImgRoundlet.drawAt(context, x, y); | |||||
fImgOrbit.drawAt(context, nOrbitX, nOrbitY); | |||||
fImgSubOrbit.drawAt(context, nSubOrbitX, nSubOrbitY); | |||||
} | } | ||||
bool VectorJuiceUI::onMouse(const MouseEvent& ev) | bool VectorJuiceUI::onMouse(const MouseEvent& ev) | ||||
@@ -378,7 +375,9 @@ bool VectorJuiceUI::onMouse(const MouseEvent& ev) | |||||
if (ev.press) | if (ev.press) | ||||
{ | { | ||||
if (! fCanvasArea.contains(ev.pos)) | |||||
const double scaling = getWidth() / static_cast<double>(VectorJuiceArtwork::backgroundWidth); | |||||
if (! fCanvasArea.containsAfterScaling(ev.pos, scaling)) | |||||
return false; | return false; | ||||
fDragging = true; | fDragging = true; | ||||
@@ -401,6 +400,7 @@ bool VectorJuiceUI::onMotion(const MotionEvent& ev) | |||||
if (! fDragging) | if (! fDragging) | ||||
return false; | return false; | ||||
const double scaling = getWidth() / static_cast<double>(VectorJuiceArtwork::backgroundWidth); | |||||
const int x = ev.pos.getX(); | const int x = ev.pos.getX(); | ||||
const int y = ev.pos.getY(); | const int y = ev.pos.getY(); | ||||
@@ -419,8 +419,8 @@ bool VectorJuiceUI::onMotion(const MotionEvent& ev) | |||||
float newX = paramX; | float newX = paramX; | ||||
float newY = paramY; | float newY = paramY; | ||||
newX -= float(movedX)/fCanvasArea.getWidth(); | |||||
newY -= float(movedY)/fCanvasArea.getHeight(); | |||||
newX -= float(movedX)/fCanvasArea.getWidth()/scaling; | |||||
newY -= float(movedY)/fCanvasArea.getHeight()/scaling; | |||||
if (newX < 0.0f) | if (newX < 0.0f) | ||||
newX = 0.0f; | newX = 0.0f; | ||||
@@ -88,7 +88,7 @@ private: | |||||
bool fDragValid; | bool fDragValid; | ||||
int fLastX; | int fLastX; | ||||
int fLastY; | int fLastY; | ||||
DGL_NAMESPACE::Rectangle<int> fCanvasArea; | |||||
DGL_NAMESPACE::Rectangle<double> fCanvasArea; | |||||
float orbitX, orbitY, subOrbitX, subOrbitY; | float orbitX, orbitY, subOrbitX, subOrbitY; | ||||
}; | }; | ||||
@@ -27,16 +27,16 @@ | |||||
#include "CarlaJuceUtils.hpp" | #include "CarlaJuceUtils.hpp" | ||||
// Plugin Code | // Plugin Code | ||||
#include "distrho-wobblejuice/WobbleJuiceArtwork.cpp" | |||||
#include "distrho-wobblejuice/WobbleJuicePlugin.cpp" | #include "distrho-wobblejuice/WobbleJuicePlugin.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "distrho-wobblejuice/WobbleJuiceArtwork.cpp" | |||||
#include "distrho-wobblejuice/WobbleJuiceUI.cpp" | #include "distrho-wobblejuice/WobbleJuiceUI.cpp" | ||||
#endif | #endif | ||||
// DISTRHO Code | // DISTRHO Code | ||||
#define DISTRHO_PLUGIN_TARGET_CARLA | #define DISTRHO_PLUGIN_TARGET_CARLA | ||||
#include "DistrhoPluginMain.cpp" | #include "DistrhoPluginMain.cpp" | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
#include "DistrhoUIMain.cpp" | #include "DistrhoUIMain.cpp" | ||||
#endif | #endif | ||||
@@ -46,7 +46,7 @@ START_NAMESPACE_DISTRHO | |||||
static const NativePluginDescriptor wobblejuiceDesc = { | static const NativePluginDescriptor wobblejuiceDesc = { | ||||
/* category */ NATIVE_PLUGIN_CATEGORY_DYNAMICS, | /* category */ NATIVE_PLUGIN_CATEGORY_DYNAMICS, | ||||
#ifdef HAVE_DGL | |||||
#if DISTRHO_PLUGIN_HAS_UI | |||||
/* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | /* hints */ static_cast<NativePluginHints>(NATIVE_PLUGIN_IS_RTSAFE | ||||
|NATIVE_PLUGIN_HAS_UI | |NATIVE_PLUGIN_HAS_UI | ||||
|NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | |NATIVE_PLUGIN_NEEDS_UI_MAIN_THREAD | ||||
@@ -23,20 +23,18 @@ START_NAMESPACE_DISTRHO | |||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||
WobbleJuiceUI::WobbleJuiceUI() | WobbleJuiceUI::WobbleJuiceUI() | ||||
: UI(), | |||||
: UI(WobbleJuiceArtwork::backgroundWidth, WobbleJuiceArtwork::backgroundHeight, true), | |||||
fAboutWindow(this) | fAboutWindow(this) | ||||
{ | { | ||||
setSize(WobbleJuiceArtwork::backgroundWidth, WobbleJuiceArtwork::backgroundHeight); | |||||
// background | // background | ||||
fImgBackground = Image(WobbleJuiceArtwork::backgroundData, WobbleJuiceArtwork::backgroundWidth, WobbleJuiceArtwork::backgroundHeight, GL_BGR); | |||||
fImgBackground = Image(WobbleJuiceArtwork::backgroundData, WobbleJuiceArtwork::backgroundWidth, WobbleJuiceArtwork::backgroundHeight, kImageFormatBGR); | |||||
// about | // about | ||||
Image aboutImage(WobbleJuiceArtwork::aboutData, WobbleJuiceArtwork::aboutWidth, WobbleJuiceArtwork::aboutHeight, GL_BGR); | |||||
Image aboutImage(WobbleJuiceArtwork::aboutData, WobbleJuiceArtwork::aboutWidth, WobbleJuiceArtwork::aboutHeight, kImageFormatBGR); | |||||
fAboutWindow.setImage(aboutImage); | fAboutWindow.setImage(aboutImage); | ||||
// knobs | // knobs | ||||
Image knobImage(WobbleJuiceArtwork::knobData, WobbleJuiceArtwork::knobWidth, WobbleJuiceArtwork::knobHeight); | |||||
Image knobImage(WobbleJuiceArtwork::knobData, WobbleJuiceArtwork::knobWidth, WobbleJuiceArtwork::knobHeight, kImageFormatBGRA); | |||||
// knob Division | // knob Division | ||||
fKnobDivision = new ImageKnob(this, knobImage, ImageKnob::Vertical); | fKnobDivision = new ImageKnob(this, knobImage, ImageKnob::Vertical); | ||||
@@ -94,8 +92,8 @@ WobbleJuiceUI::WobbleJuiceUI() | |||||
fKnobDrive->setCallback(this); | fKnobDrive->setCallback(this); | ||||
// about button | // about button | ||||
Image aboutImageNormal(WobbleJuiceArtwork::aboutButtonNormalData, WobbleJuiceArtwork::aboutButtonNormalWidth, WobbleJuiceArtwork::aboutButtonNormalHeight); | |||||
Image aboutImageHover(WobbleJuiceArtwork::aboutButtonHoverData, WobbleJuiceArtwork::aboutButtonHoverWidth, WobbleJuiceArtwork::aboutButtonHoverHeight); | |||||
Image aboutImageNormal(WobbleJuiceArtwork::aboutButtonNormalData, WobbleJuiceArtwork::aboutButtonNormalWidth, WobbleJuiceArtwork::aboutButtonNormalHeight, kImageFormatBGRA); | |||||
Image aboutImageHover(WobbleJuiceArtwork::aboutButtonHoverData, WobbleJuiceArtwork::aboutButtonHoverWidth, WobbleJuiceArtwork::aboutButtonHoverHeight, kImageFormatBGRA); | |||||
fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | fButtonAbout = new ImageButton(this, aboutImageNormal, aboutImageHover, aboutImageHover); | ||||
fButtonAbout->setAbsolutePos(390, 20); | fButtonAbout->setAbsolutePos(390, 20); | ||||
fButtonAbout->setCallback(this); | fButtonAbout->setCallback(this); | ||||
@@ -154,7 +152,7 @@ void WobbleJuiceUI::imageButtonClicked(ImageButton* button, int) | |||||
if (button != fButtonAbout) | if (button != fButtonAbout) | ||||
return; | return; | ||||
fAboutWindow.exec(); | |||||
fAboutWindow.runAsModal(); | |||||
} | } | ||||
void WobbleJuiceUI::imageKnobDragStarted(ImageKnob* knob) | void WobbleJuiceUI::imageKnobDragStarted(ImageKnob* knob) | ||||
@@ -174,7 +172,9 @@ void WobbleJuiceUI::imageKnobValueChanged(ImageKnob* knob, float value) | |||||
void WobbleJuiceUI::onDisplay() | void WobbleJuiceUI::onDisplay() | ||||
{ | { | ||||
fImgBackground.draw(); | |||||
const GraphicsContext& context(getGraphicsContext()); | |||||
fImgBackground.draw(context); | |||||
} | } | ||||
// ----------------------------------------------------------------------- | // ----------------------------------------------------------------------- | ||||