| @@ -43,6 +43,9 @@ protected: | |||||
| : NativePluginClass(host), | : NativePluginClass(host), | ||||
| fParamCount(paramCount-2), // volume and pan handled by host | fParamCount(paramCount-2), // volume and pan handled by host | ||||
| fProgramCount(programCount), | fProgramCount(programCount), | ||||
| fParamValues(new uchar[paramCount]), | |||||
| fParamsChanged(new bool[paramCount]), | |||||
| fNextProgram(-1), | |||||
| fBufferSize(getBufferSize()), | fBufferSize(getBufferSize()), | ||||
| fSampleRate(getSampleRate()), | fSampleRate(getSampleRate()), | ||||
| fFilterParams(nullptr), | fFilterParams(nullptr), | ||||
| @@ -57,6 +60,8 @@ protected: | |||||
| FloatVectorOperations::clear(efxoutl, ibufferSize); | FloatVectorOperations::clear(efxoutl, ibufferSize); | ||||
| FloatVectorOperations::clear(efxoutr, ibufferSize); | FloatVectorOperations::clear(efxoutr, ibufferSize); | ||||
| std::memset(fParamsChanged, 0, sizeof(bool)*fParamCount); | |||||
| doReinit(true); | doReinit(true); | ||||
| } | } | ||||
| @@ -109,16 +114,13 @@ protected: | |||||
| { | { | ||||
| const int ivalue(roundToIntAccurate(carla_fixedValue(0.0f, 127.0f, value))); | const int ivalue(roundToIntAccurate(carla_fixedValue(0.0f, 127.0f, value))); | ||||
| fEffect->changepar(static_cast<int>(index+2), static_cast<uchar>(ivalue)); | |||||
| fParamValues[index] = static_cast<uchar>(ivalue); | |||||
| fParamsChanged[index] = true; | |||||
| } | } | ||||
| void setMidiProgram(const uint8_t, const uint32_t, const uint32_t program) final | void setMidiProgram(const uint8_t, const uint32_t, const uint32_t program) final | ||||
| { | { | ||||
| fEffect->setpreset(static_cast<uchar>(program)); | |||||
| // reset volume and pan | |||||
| fEffect->changepar(0, 127); | |||||
| fEffect->changepar(1, 64); | |||||
| fNextProgram = program; | |||||
| } | } | ||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| @@ -143,6 +145,32 @@ protected: | |||||
| else | else | ||||
| FloatVectorOperations::multiply(outBuffer[1], 0.5f, iframes); | FloatVectorOperations::multiply(outBuffer[1], 0.5f, iframes); | ||||
| const int32_t nextProgram = fNextProgram; | |||||
| fNextProgram = -1; | |||||
| if (nextProgram >= 0) | |||||
| { | |||||
| fEffect->setpreset(static_cast<uchar>(nextProgram)); | |||||
| // reset volume and pan | |||||
| fEffect->changepar(0, 127); | |||||
| fEffect->changepar(1, 64); | |||||
| // ignore next | |||||
| std::memset(fParamsChanged, 0, sizeof(bool)*fParamCount); | |||||
| } | |||||
| else | |||||
| { | |||||
| for (int i=0, count=static_cast<int>(fParamCount); i<count; ++i) | |||||
| { | |||||
| if (! fParamsChanged[i]) | |||||
| continue; | |||||
| fEffect->changepar(i+2, fParamValues[i]); | |||||
| fParamsChanged[i] = false; | |||||
| } | |||||
| } | |||||
| fEffect->out(Stereo<float*>(inBuffer[0], inBuffer[1])); | fEffect->out(Stereo<float*>(inBuffer[0], inBuffer[1])); | ||||
| FloatVectorOperations::addWithMultiply(outBuffer[0], efxoutl, 0.5f, iframes); | FloatVectorOperations::addWithMultiply(outBuffer[0], efxoutl, 0.5f, iframes); | ||||
| @@ -200,6 +228,9 @@ protected: | |||||
| if (firstInit) | if (firstInit) | ||||
| { | { | ||||
| fEffect->setpreset(0); | fEffect->setpreset(0); | ||||
| for (int i=0, count=static_cast<int>(fParamCount); i<count; ++i) | |||||
| fParamValues[i] = fEffect->getpar(i+2); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -217,6 +248,10 @@ protected: | |||||
| const uint32_t fParamCount; | const uint32_t fParamCount; | ||||
| const uint32_t fProgramCount; | const uint32_t fProgramCount; | ||||
| uchar* const fParamValues; | |||||
| bool* const fParamsChanged; | |||||
| int32_t fNextProgram; | |||||
| uint32_t fBufferSize; | uint32_t fBufferSize; | ||||
| double fSampleRate; | double fSampleRate; | ||||