From b1a5e31102eabff0f13f940d07bdbdec70ec70c2 Mon Sep 17 00:00:00 2001 From: Dune Desormeaux Date: Mon, 24 Jul 2023 16:14:19 -0700 Subject: [PATCH 1/4] Only unlock corresponding parameter when knob is turned rather than GT/LT logic --- .../pd/kontrolrack/devices/Organelle.cpp | 77 ++++++++++--------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/mec-kontrol/pd/kontrolrack/devices/Organelle.cpp b/mec-kontrol/pd/kontrolrack/devices/Organelle.cpp index de5137b..e3de18c 100644 --- a/mec-kontrol/pd/kontrolrack/devices/Organelle.cpp +++ b/mec-kontrol/pd/kontrolrack/devices/Organelle.cpp @@ -313,49 +313,52 @@ void OParamMode::changePot(unsigned pot, float rawvalue) { if (rawvalue != std::numeric_limits::max()) { float value = rawvalue / MAX_POT_VALUE; calc = param->calcFloat(value); + if (rawvalue != pots_->rawValue[pot]) { + pots_->locked_[pot] = Pots::K_UNLOCKED; + } //std::cerr << "changePot " << pot << " " << value << " cv " << calc.floatValue() << " pv " << param->current().floatValue() << std::endl; } pots_->rawValue[pot] = rawvalue; - if (pots_->locked_[pot] != Pots::K_UNLOCKED) { - //if pot is locked, determined if we can unlock it - if (calc == param->current()) { - pots_->locked_[pot] = Pots::K_UNLOCKED; - //std::cerr << "unlock condition met == " << pot << std::endl; - } else if (pots_->locked_[pot] == Pots::K_GT) { - if (calc > param->current()) { - pots_->locked_[pot] = Pots::K_UNLOCKED; - //std::cerr << "unlock condition met gt " << pot << std::endl; - } - } else if (pots_->locked_[pot] == Pots::K_LT) { - if (calc < param->current()) { - pots_->locked_[pot] = Pots::K_UNLOCKED; - //std::cerr << "unlock condition met lt " << pot << std::endl; - } - } else if (pots_->locked_[pot] == Pots::K_LOCKED) { - //std::cerr << "pot locked " << pot << " pv " << param->current().floatValue() << " cv " << calc.floatValue() << std::endl; - // initial locked, determine unlock condition - if (calc == param->current()) { - // pot value at current value, unlock it - pots_->locked_[pot] = Pots::K_UNLOCKED; - //std::cerr << "set unlock condition == " << pot << std::endl; - } else if (rawvalue == std::numeric_limits::max()) { - // stay locked , we need a real value ;) - // init state - //std::cerr << "cannot set unlock condition " << pot << std::endl; - } else if (calc > param->current()) { - // pot starts greater than param, so wait for it to go less than - pots_->locked_[pot] = Pots::K_LT; - //std::cerr << "set unlock condition lt " << pot << std::endl; - } else { - // pot starts less than param, so wait for it to go greater than - pots_->locked_[pot] = Pots::K_GT; - //std::cerr << "set unlock condition gt " << pot << std::endl; - } - } - } + // if (pots_->locked_[pot] != Pots::K_UNLOCKED) { + // //if pot is locked, determined if we can unlock it + // if (calc == param->current()) { + // pots_->locked_[pot] = Pots::K_UNLOCKED; + // //std::cerr << "unlock condition met == " << pot << std::endl; + // } else if (pots_->locked_[pot] == Pots::K_GT) { + // if (calc > param->current()) { + // pots_->locked_[pot] = Pots::K_UNLOCKED; + // //std::cerr << "unlock condition met gt " << pot << std::endl; + // } + // } else if (pots_->locked_[pot] == Pots::K_LT) { + // if (calc < param->current()) { + // pots_->locked_[pot] = Pots::K_UNLOCKED; + // //std::cerr << "unlock condition met lt " << pot << std::endl; + // } + // } else if (pots_->locked_[pot] == Pots::K_LOCKED) { + // //std::cerr << "pot locked " << pot << " pv " << param->current().floatValue() << " cv " << calc.floatValue() << std::endl; + // // initial locked, determine unlock condition + // if (calc == param->current()) { + // // pot value at current value, unlock it + // pots_->locked_[pot] = Pots::K_UNLOCKED; + // //std::cerr << "set unlock condition == " << pot << std::endl; + // } else if (rawvalue == std::numeric_limits::max()) { + // // stay locked , we need a real value ;) + // // init state + // //std::cerr << "cannot set unlock condition " << pot << std::endl; + // } else if (calc > param->current()) { + // // pot starts greater than param, so wait for it to go less than + // pots_->locked_[pot] = Pots::K_LT; + // //std::cerr << "set unlock condition lt " << pot << std::endl; + // } else { + // // pot starts less than param, so wait for it to go greater than + // pots_->locked_[pot] = Pots::K_GT; + // //std::cerr << "set unlock condition gt " << pot << std::endl; + // } + // } + // } if (pots_->locked_[pot] == Pots::K_UNLOCKED) { model()->changeParam(Kontrol::CS_LOCAL, parent_.currentRack(), parent_.currentModule(), paramId, calc); From 59a36069e4aad379b8eea8a1dad43ea3f776693e Mon Sep 17 00:00:00 2001 From: Dune Desormeaux Date: Tue, 25 Jul 2023 12:48:03 -0700 Subject: [PATCH 2/4] KontrolRack new method to handle setting --- mec-kontrol/pd/kontrolrack/KontrolRack.cpp | 7 +++++++ mec-kontrol/pd/kontrolrack/KontrolRack.h | 1 + 2 files changed, 8 insertions(+) diff --git a/mec-kontrol/pd/kontrolrack/KontrolRack.cpp b/mec-kontrol/pd/kontrolrack/KontrolRack.cpp index efcdcec..e97ce65 100644 --- a/mec-kontrol/pd/kontrolrack/KontrolRack.cpp +++ b/mec-kontrol/pd/kontrolrack/KontrolRack.cpp @@ -375,6 +375,10 @@ EXTERN void KontrolRack_setup(void) { (t_method) KontrolRack_setmoduleorder, gensym("setmoduleorder"), A_GIMME, A_NULL); + class_addmethod(KontrolRack_class, + (t_method) KontrolRack_instantParam, gensym("instantParamBool"), + A_FLOAT, A_NULL); + class_addmethod(KontrolRack_class, (t_method) KontrolRack_test, gensym("test"), A_DEFFLOAT, A_NULL); @@ -1030,6 +1034,9 @@ void KontrolRack_selectmodule(t_KontrolRack* x, t_floatarg module) { if (x->device_) x->device_->selectModule((unsigned) module); } +void KontrolRack_instantParam(t_KontrolRack* x, t_floatarg setting) { + post("instantParam method"); +} //----------------------- void PdCallback::rack(Kontrol::ChangeSource src, const Kontrol::Rack & rack) { diff --git a/mec-kontrol/pd/kontrolrack/KontrolRack.h b/mec-kontrol/pd/kontrolrack/KontrolRack.h index 97b2396..738e38c 100644 --- a/mec-kontrol/pd/kontrolrack/KontrolRack.h +++ b/mec-kontrol/pd/kontrolrack/KontrolRack.h @@ -84,6 +84,7 @@ void KontrolRack_selectmodule(t_KontrolRack* x, t_floatarg value); void KontrolRack_loadresources(t_KontrolRack *x); void KontrolRack_setmoduleorder(t_KontrolRack *x,t_symbol* s, int argc, t_atom *argv); +void KontrolRack_instantParam(t_KontrolRack *x, t_floatarg setting); } From cf13f25c1600aed01406dbce695c210f90c7a9a6 Mon Sep 17 00:00:00 2001 From: Dune Desormeaux Date: Tue, 25 Jul 2023 12:50:32 -0700 Subject: [PATCH 3/4] fix typo --- mec-kontrol/pd/kontrolrack/KontrolRack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mec-kontrol/pd/kontrolrack/KontrolRack.cpp b/mec-kontrol/pd/kontrolrack/KontrolRack.cpp index e97ce65..04af5da 100644 --- a/mec-kontrol/pd/kontrolrack/KontrolRack.cpp +++ b/mec-kontrol/pd/kontrolrack/KontrolRack.cpp @@ -376,7 +376,7 @@ EXTERN void KontrolRack_setup(void) { A_GIMME, A_NULL); class_addmethod(KontrolRack_class, - (t_method) KontrolRack_instantParam, gensym("instantParamBool"), + (t_method) KontrolRack_instantParam, gensym("instantParamsBool"), A_FLOAT, A_NULL); class_addmethod(KontrolRack_class, From 070e63c3f93cd16b7965ef6a445c3863204b7a7e Mon Sep 17 00:00:00 2001 From: Dune Desormeaux Date: Tue, 25 Jul 2023 14:29:50 -0700 Subject: [PATCH 4/4] add setting logic --- mec-kontrol/pd/kontrolrack/KontrolRack.cpp | 2 +- .../pd/kontrolrack/devices/KontrolDevice.cpp | 4 + .../pd/kontrolrack/devices/KontrolDevice.h | 4 + .../pd/kontrolrack/devices/Organelle.cpp | 76 +++++++++---------- 4 files changed, 47 insertions(+), 39 deletions(-) diff --git a/mec-kontrol/pd/kontrolrack/KontrolRack.cpp b/mec-kontrol/pd/kontrolrack/KontrolRack.cpp index 04af5da..d56bf7f 100644 --- a/mec-kontrol/pd/kontrolrack/KontrolRack.cpp +++ b/mec-kontrol/pd/kontrolrack/KontrolRack.cpp @@ -1035,7 +1035,7 @@ void KontrolRack_selectmodule(t_KontrolRack* x, t_floatarg module) { } void KontrolRack_instantParam(t_KontrolRack* x, t_floatarg setting) { - post("instantParam method"); + x->device_->instantParam(setting); } //----------------------- diff --git a/mec-kontrol/pd/kontrolrack/devices/KontrolDevice.cpp b/mec-kontrol/pd/kontrolrack/devices/KontrolDevice.cpp index c58f695..16281fb 100644 --- a/mec-kontrol/pd/kontrolrack/devices/KontrolDevice.cpp +++ b/mec-kontrol/pd/kontrolrack/devices/KontrolDevice.cpp @@ -221,6 +221,10 @@ void KontrolDevice::midiLearn(Kontrol::ChangeSource src, bool b) { midiLearnActive_ = b; } +void KontrolDevice::instantParam(bool b) { + instantParamSetting_ = b; +} + void KontrolDevice::modulationLearn(Kontrol::ChangeSource src, bool b) { modParamId_ = ""; modModuleId_ = ""; diff --git a/mec-kontrol/pd/kontrolrack/devices/KontrolDevice.h b/mec-kontrol/pd/kontrolrack/devices/KontrolDevice.h index d3db09b..04410db 100644 --- a/mec-kontrol/pd/kontrolrack/devices/KontrolDevice.h +++ b/mec-kontrol/pd/kontrolrack/devices/KontrolDevice.h @@ -66,6 +66,7 @@ class KontrolDevice : public Kontrol::KontrolCallback { void midiLearn(bool b); void modulationLearn(bool b); + void instantParam(bool b); virtual void midiCC(unsigned num, unsigned value); virtual void modulate(const std::string& src, unsigned bus, float value); @@ -81,6 +82,8 @@ class KontrolDevice : public Kontrol::KontrolCallback { bool midiLearn() { return midiLearnActive_; } bool modulationLearn() { return modulationLearnActive_; } + bool instantParamSetting() { return instantParamSetting_; } + Kontrol::EntityId currentRack() { return currentRackId_; } @@ -105,6 +108,7 @@ class KontrolDevice : public Kontrol::KontrolCallback { bool midiLearnActive_; bool modulationLearnActive_; bool enableMenu_; + bool instantParamSetting_ = false; std::vector moduleOrder_; Kontrol::EntityId modParamId_; diff --git a/mec-kontrol/pd/kontrolrack/devices/Organelle.cpp b/mec-kontrol/pd/kontrolrack/devices/Organelle.cpp index e3de18c..d9cf7a9 100644 --- a/mec-kontrol/pd/kontrolrack/devices/Organelle.cpp +++ b/mec-kontrol/pd/kontrolrack/devices/Organelle.cpp @@ -313,7 +313,7 @@ void OParamMode::changePot(unsigned pot, float rawvalue) { if (rawvalue != std::numeric_limits::max()) { float value = rawvalue / MAX_POT_VALUE; calc = param->calcFloat(value); - if (rawvalue != pots_->rawValue[pot]) { + if (rawvalue != pots_->rawValue[pot] && parent_.instantParamSetting()) { pots_->locked_[pot] = Pots::K_UNLOCKED; } //std::cerr << "changePot " << pot << " " << value << " cv " << calc.floatValue() << " pv " << param->current().floatValue() << std::endl; @@ -322,43 +322,43 @@ void OParamMode::changePot(unsigned pot, float rawvalue) { pots_->rawValue[pot] = rawvalue; - // if (pots_->locked_[pot] != Pots::K_UNLOCKED) { - // //if pot is locked, determined if we can unlock it - // if (calc == param->current()) { - // pots_->locked_[pot] = Pots::K_UNLOCKED; - // //std::cerr << "unlock condition met == " << pot << std::endl; - // } else if (pots_->locked_[pot] == Pots::K_GT) { - // if (calc > param->current()) { - // pots_->locked_[pot] = Pots::K_UNLOCKED; - // //std::cerr << "unlock condition met gt " << pot << std::endl; - // } - // } else if (pots_->locked_[pot] == Pots::K_LT) { - // if (calc < param->current()) { - // pots_->locked_[pot] = Pots::K_UNLOCKED; - // //std::cerr << "unlock condition met lt " << pot << std::endl; - // } - // } else if (pots_->locked_[pot] == Pots::K_LOCKED) { - // //std::cerr << "pot locked " << pot << " pv " << param->current().floatValue() << " cv " << calc.floatValue() << std::endl; - // // initial locked, determine unlock condition - // if (calc == param->current()) { - // // pot value at current value, unlock it - // pots_->locked_[pot] = Pots::K_UNLOCKED; - // //std::cerr << "set unlock condition == " << pot << std::endl; - // } else if (rawvalue == std::numeric_limits::max()) { - // // stay locked , we need a real value ;) - // // init state - // //std::cerr << "cannot set unlock condition " << pot << std::endl; - // } else if (calc > param->current()) { - // // pot starts greater than param, so wait for it to go less than - // pots_->locked_[pot] = Pots::K_LT; - // //std::cerr << "set unlock condition lt " << pot << std::endl; - // } else { - // // pot starts less than param, so wait for it to go greater than - // pots_->locked_[pot] = Pots::K_GT; - // //std::cerr << "set unlock condition gt " << pot << std::endl; - // } - // } - // } + if (pots_->locked_[pot] != Pots::K_UNLOCKED && parent_.instantParamSetting() == false) { + //if pot is locked, determined if we can unlock it + if (calc == param->current()) { + pots_->locked_[pot] = Pots::K_UNLOCKED; + //std::cerr << "unlock condition met == " << pot << std::endl; + } else if (pots_->locked_[pot] == Pots::K_GT) { + if (calc > param->current()) { + pots_->locked_[pot] = Pots::K_UNLOCKED; + //std::cerr << "unlock condition met gt " << pot << std::endl; + } + } else if (pots_->locked_[pot] == Pots::K_LT) { + if (calc < param->current()) { + pots_->locked_[pot] = Pots::K_UNLOCKED; + //std::cerr << "unlock condition met lt " << pot << std::endl; + } + } else if (pots_->locked_[pot] == Pots::K_LOCKED) { + //std::cerr << "pot locked " << pot << " pv " << param->current().floatValue() << " cv " << calc.floatValue() << std::endl; + // initial locked, determine unlock condition + if (calc == param->current()) { + // pot value at current value, unlock it + pots_->locked_[pot] = Pots::K_UNLOCKED; + //std::cerr << "set unlock condition == " << pot << std::endl; + } else if (rawvalue == std::numeric_limits::max()) { + // stay locked , we need a real value ;) + // init state + //std::cerr << "cannot set unlock condition " << pot << std::endl; + } else if (calc > param->current()) { + // pot starts greater than param, so wait for it to go less than + pots_->locked_[pot] = Pots::K_LT; + //std::cerr << "set unlock condition lt " << pot << std::endl; + } else { + // pot starts less than param, so wait for it to go greater than + pots_->locked_[pot] = Pots::K_GT; + //std::cerr << "set unlock condition gt " << pot << std::endl; + } + } + } if (pots_->locked_[pot] == Pots::K_UNLOCKED) { model()->changeParam(Kontrol::CS_LOCAL, parent_.currentRack(), parent_.currentModule(), paramId, calc);