@@ -76,6 +76,7 @@ private: | |||||
float fValue; | float fValue; | ||||
float fValueDef; | float fValueDef; | ||||
float fValueTmp; | float fValueTmp; | ||||
bool fUsingDefault; | |||||
bool fUsingLog; | bool fUsingLog; | ||||
Orientation fOrientation; | Orientation fOrientation; | ||||
@@ -32,6 +32,7 @@ ImageKnob::ImageKnob(Window& parent, const Image& image, Orientation orientation | |||||
fValue(0.5f), | fValue(0.5f), | ||||
fValueDef(fValue), | fValueDef(fValue), | ||||
fValueTmp(fValue), | fValueTmp(fValue), | ||||
fUsingDefault(false), | |||||
fUsingLog(false), | fUsingLog(false), | ||||
fOrientation(orientation), | fOrientation(orientation), | ||||
fRotationAngle(0), | fRotationAngle(0), | ||||
@@ -58,6 +59,7 @@ ImageKnob::ImageKnob(Widget* widget, const Image& image, Orientation orientation | |||||
fValue(0.5f), | fValue(0.5f), | ||||
fValueDef(fValue), | fValueDef(fValue), | ||||
fValueTmp(fValue), | fValueTmp(fValue), | ||||
fUsingDefault(false), | |||||
fUsingLog(false), | fUsingLog(false), | ||||
fOrientation(orientation), | fOrientation(orientation), | ||||
fRotationAngle(0), | fRotationAngle(0), | ||||
@@ -84,6 +86,7 @@ ImageKnob::ImageKnob(const ImageKnob& imageKnob) | |||||
fValue(imageKnob.fValue), | fValue(imageKnob.fValue), | ||||
fValueDef(imageKnob.fValueDef), | fValueDef(imageKnob.fValueDef), | ||||
fValueTmp(fValue), | fValueTmp(fValue), | ||||
fUsingDefault(imageKnob.fUsingDefault), | |||||
fUsingLog(imageKnob.fUsingLog), | fUsingLog(imageKnob.fUsingLog), | ||||
fOrientation(imageKnob.fOrientation), | fOrientation(imageKnob.fOrientation), | ||||
fRotationAngle(imageKnob.fRotationAngle), | fRotationAngle(imageKnob.fRotationAngle), | ||||
@@ -131,6 +134,7 @@ float ImageKnob::getValue() const noexcept | |||||
void ImageKnob::setDefault(float value) noexcept | void ImageKnob::setDefault(float value) noexcept | ||||
{ | { | ||||
fValueDef = value; | fValueDef = value; | ||||
fUsingDefault = true; | |||||
} | } | ||||
void ImageKnob::setRange(float min, float max) noexcept | void ImageKnob::setRange(float min, float max) noexcept | ||||
@@ -162,11 +166,6 @@ void ImageKnob::setRange(float min, float max) noexcept | |||||
} | } | ||||
} | } | ||||
if (fValueDef < min) | |||||
fValueDef = min; | |||||
else if (fValueDef > max) | |||||
fValueDef = max; | |||||
fMinimum = min; | fMinimum = min; | ||||
fMaximum = max; | fMaximum = max; | ||||
} | } | ||||
@@ -313,7 +312,7 @@ bool ImageKnob::onMouse(const MouseEvent& ev) | |||||
if (! contains(ev.pos)) | if (! contains(ev.pos)) | ||||
return false; | return false; | ||||
if (ev.mod & MODIFIER_SHIFT) | |||||
if ((ev.mod & MODIFIER_SHIFT) != 0 && fUsingDefault) | |||||
{ | { | ||||
setValue(fValueDef); | setValue(fValueDef); | ||||
fValueTmp = fValue; | fValueTmp = fValue; | ||||
@@ -80,6 +80,9 @@ double Plugin::d_getSampleRate() const noexcept | |||||
#if DISTRHO_PLUGIN_WANT_TIMEPOS | #if DISTRHO_PLUGIN_WANT_TIMEPOS | ||||
const TimePos& Plugin::d_getTimePos() const noexcept | const TimePos& Plugin::d_getTimePos() const noexcept | ||||
{ | { | ||||
// timePos outside run() may not be valid | |||||
DISTRHO_SAFE_ASSERT(pData->isProcessing); | |||||
return pData->timePos; | return pData->timePos; | ||||
} | } | ||||
#endif | #endif | ||||
@@ -36,6 +36,8 @@ extern double d_lastSampleRate; | |||||
// Plugin private data | // Plugin private data | ||||
struct Plugin::PrivateData { | struct Plugin::PrivateData { | ||||
bool isProcessing; | |||||
uint32_t parameterCount; | uint32_t parameterCount; | ||||
Parameter* parameters; | Parameter* parameters; | ||||
@@ -61,7 +63,8 @@ struct Plugin::PrivateData { | |||||
double sampleRate; | double sampleRate; | ||||
PrivateData() noexcept | PrivateData() noexcept | ||||
: parameterCount(0), | |||||
: isProcessing(false), | |||||
parameterCount(0), | |||||
parameters(nullptr), | parameters(nullptr), | ||||
#if DISTRHO_PLUGIN_WANT_PROGRAMS | #if DISTRHO_PLUGIN_WANT_PROGRAMS | ||||
programCount(0), | programCount(0), | ||||
@@ -353,18 +356,25 @@ public: | |||||
#if DISTRHO_PLUGIN_IS_SYNTH | #if DISTRHO_PLUGIN_IS_SYNTH | ||||
void run(const float** const inputs, float** const outputs, const uint32_t frames, const MidiEvent* const midiEvents, const uint32_t midiEventCount) | void run(const float** const inputs, float** const outputs, const uint32_t frames, const MidiEvent* const midiEvents, const uint32_t midiEventCount) | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr,); | |||||
DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr,); | ||||
fData->isProcessing = true; | |||||
fPlugin->d_run(inputs, outputs, frames, midiEvents, midiEventCount); | fPlugin->d_run(inputs, outputs, frames, midiEvents, midiEventCount); | ||||
fData->isProcessing = false; | |||||
} | } | ||||
#else | #else | ||||
void run(const float** const inputs, float** const outputs, const uint32_t frames) | void run(const float** const inputs, float** const outputs, const uint32_t frames) | ||||
{ | { | ||||
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr,); | |||||
DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr,); | DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr,); | ||||
fData->isProcessing = true; | |||||
fPlugin->d_run(inputs, outputs, frames); | fPlugin->d_run(inputs, outputs, frames); | ||||
fData->isProcessing = false; | |||||
} | } | ||||
#endif | #endif | ||||
// ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
void setBufferSize(const uint32_t bufferSize, bool doCallback = false) | void setBufferSize(const uint32_t bufferSize, bool doCallback = false) | ||||