Permalink
Browse files

allow deactivating softWithin (snap-to) if midi mode is 0 (return val…

…ues between 0 and 127)

This may especially be useful if a widget is connected to an on/off
button. If there was a snap-to threshold set the widget wouldn't respond
because 0 and 127 are simply to far apart (a threshold of 0.1 would only
make the widget respond if the new value is within a distance of +/-
0.05 to the old value).

Signed-off-by: Stefan Nussbaumer <st9fan@gmail.com>
  • Loading branch information...
nuss committed Apr 22, 2017
1 parent fff2387 commit 58c8b5013e52d9bc15e4207f855bda60277937b3
@@ -336,7 +336,7 @@ CVCenterPreferences {
if(GUI.id !== \cocoa, {
saveSoftWithin.toolTip_(
- "Set an arbitrary floating point value. Recomended: 0.1.\nApplies only if midiMode is set to 0."
+ "Set an arbitrary floating point value. Recomended: 0.1.\nApplies only if midiMode is set to 0.\nA value =< 0 will prevent snap-to."
)
});
View
@@ -496,10 +496,6 @@ CVWidget {
var thisSlot, thisThresh, wcm;
thisThresh = threshold.asFloat;
- if(thisThresh > 0.5 or:{ thisThresh < 0.01 }, {
- Error("threshold must be between 0.01 and 0.5").throw;
- });
-
switch(this.class,
CVWidget2D, {
thisSlot = slot.asSymbol;
@@ -1793,6 +1789,7 @@ CVWidget {
if(theChanger.value.isKindOf(Event), {
ccResponderAction = { |src, chan, num, val|
+ [src, chan, num, val].postln;
ctrlString ? ctrlString = num+1;
if(this.getCtrlButtonBank(slot).notNil, {
if(ctrlString % this.getCtrlButtonBank(slot) == 0, {
@@ -1809,19 +1806,25 @@ CVWidget {
0, {
switch(this.class,
CVWidgetMS, {
- if(val/127 < (argWidgetCV.input[slot]+(this.getSoftWithin(slot)/2)) and:{
- val/127 > (argWidgetCV.input[slot]-(this.getSoftWithin(slot)/2));
- }, {
+ // softWithin disabled if getSoftWithin <= 0
+ if((this.getSoftWithin(slot) <= 0).or(
+ val/127 < (argWidgetCV.input[slot]+(this.getSoftWithin(slot)/2)) and:{
+ val/127 > (argWidgetCV.input[slot]-(this.getSoftWithin(slot)/2));
+ }
+ ), {
argWidgetCV.input_(argWidgetCV.input.collect({ |it, i|
if(i == slot, { val/127 }, { it })
}))
})
},
{
- if(val/127 < (argWidgetCV.input+(this.getSoftWithin(slot)/2)) and:{
- val/127 > (argWidgetCV.input-(this.getSoftWithin(slot)/2));
- }, {
- argWidgetCV.input_(val/127)
+ // softWithin disabled if getSoftWithin <= 0
+ if((this.getSoftWithin(slot) <= 0).or(
+ val/127 < (argWidgetCV.input+(this.getSoftWithin(slot)/2)) and:{
+ val/127 > (argWidgetCV.input-(this.getSoftWithin(slot)/2));
+ }
+ ), {
+ argWidgetCV.input_(val/127);
})
}
)
@@ -354,12 +354,11 @@ CVWidgetEditor : AbstractCVWidgetEditor {
widget.setSoftWithin(mb.value, slot);
})
.step_(0.005)
- .clipLo_(0.01)
.clipHi_(0.5)
;
if(GUI.id !== \cocoa, {
- softWithinNB.toolTip_("If your device outputs absolute values\nyou can set here a threshold to the\ncurrent CV-value within which a slider\nwill react and set a new value. This avoids\njumps if a new value set by a slider\nis far away from the previous value")
+ softWithinNB.toolTip_("If your device outputs absolute values\nyou can set here a threshold to the\ncurrent CV-value within which a slider\nwill react and set a new value. This avoids\njumps if a new value set by a slider\nis far away from the previous value.\nA value =< 0 will deactivate the snap-to setting.")
});
StaticText(tabView1, Point(flow1.bounds.width/2+60, 15))
@@ -446,7 +446,7 @@ CVWidgetMSEditor : AbstractCVWidgetEditor {
;
if(GUI.id !== \cocoa, {
- softWithinNB.toolTip_("If your device outputs absolute values\nyou can set here a threshold to the\ncurrent CV-value within which a slider\nwill react and set a new value. This avoids\njumps if a new value set by a slider\nis far away from the previous value")
+ softWithinNB.toolTip_("If your device outputs absolute values\nyou can set here a threshold to the\ncurrent CV-value within which a slider\nwill react and set a new value. This avoids\njumps if a new value set by a slider\nis far away from the previous value.\nA value =< 0 deactivates snap-to.")
});
if(thisSoftWithin.select(_.isNumber).size == widget.msSize and:{
@@ -4,7 +4,7 @@ categories:: GUI, Conductor, External Control>MIDI, External Control>OSC
related:: Classes/CVCenter, Classes/CVWidget
DESCRIPTION::
-CVCenterPreferences implements persistant preferences for link::Classes/CVCenter:: and parts of link::Classes/CVWidget:: (resp. its subclassses link::Classes/CVWidgetKnob:: and link::Classes/CVWidget2D::). Preferences may either be set via GUI or programmatically. They are stored in a file named strong::CVCenterPreferences:: in the same directory as the classfile.
+CVCenterPreferences implements persistant preferences for link::Classes/CVCenter:: and parts of link::Classes/CVWidget:: (respectively its subclassses link::Classes/CVWidgetKnob::, link::Classes/CVWidget2D:: and link::Classes/CVWidgetMS::). Preferences may either be set via GUI or programmatically. They are stored in a file named strong::CVCenterPreferences:: in the same directory as the classfile.
CLASSMETHODS::
@@ -34,7 +34,7 @@ argument:: guiProperties
a link::Classes/Rect:: an link::Classes/Array:: providing code::left::, code::top::, code::width::, code::height:: - will be ignored if 'saveProperties is set to code::0:: or code::1::
argument:: saveClassVars
-a link::Classes/Boolean:: or an link::Classes/Integer:: ( code::0:: or code::1::), indicating whether CVCenter's classvars link::Classes/CVCenter#*midiMode#midiMode::, link::Classes/CVCenter#*midiResolution#midiResolution::, link::Classes/CVCenter#*midiMean#midiMean::, link::Classes/CVCenter#*softWithin#softWithin::, link::Classes/CVCenter#*ctrlButtonBank#ctrlButtonBank::. All these classvars have equivalent instancevars in CVWidget that will overwrite CVCenter's classvars if set. Thus the user may set global values here and tweak them within each CVWidget created in CVCenter.
+a link::Classes/Boolean:: or an link::Classes/Integer:: ( code::0:: or code::1::), indicating whether CVCenter's classvars link::Classes/CVCenter#*midiMode#midiMode::, link::Classes/CVCenter#*midiResolution#midiResolution::, link::Classes/CVCenter#*midiMean#midiMean::, link::Classes/CVCenter#*softWithin#softWithin::, link::Classes/CVCenter#*ctrlButtonBank#ctrlButtonBank::. All these classvars have equivalent instancevars in CVWidget that will override CVCenter's classvars if set. Thus the user may set global values here and tweak them within each CVWidget created in CVCenter.
If set to code::0:: the arguments code::midiMode::, code::midiResolution::, code::midiMean::, code::softWithin:: and code::ctrlButtonBank:: will be ignored.
argument:: midiMode
@@ -50,7 +50,7 @@ argument:: midiMean
an link::Classes/Integer:: - only applies when midiMode is set to code::1:: - default: code::64::. The value stands for the value a MIDI-slider will output in neutral position.
argument:: softWithin
-a link::Classes/Float:: - only applies when midiMode is set to code::0:: - default: code::0.1::. A threshold for a MIDI-slider to react. Only if the slider comes close to the link::Classes/CV::'s actual value +/- softWithin a new value will be set. This avoids sudden jumps if a slider gets moved but the actual value of the CV differs much.
+a link::Classes/Float:: - only applies when midiMode is set to code::0:: - default: code::0.1::. A threshold for a MIDI-slider to react. Only if the slider comes close to the link::Classes/CV::'s actual value +/- softWithin a new value will be set. This avoids sudden jumps if a slider gets moved but the actual value of the CV differs much. A value code::=< 0:: will prevent the snap-to.
argument:: ctrlButtonBank
CVCenter was written with a Doepfer Pocket Dial in mind which provides 16 fader-knobs and 4 different banks which sums up to 64 different slider-slots. However, it is not obvious which slider has to be moved to trigger a CCResponder initialised for controller nr. 37. Setting this argument to 16 (the number of knobs) will display controller nr. 37 as 3:5 (knob number 5 in bank 3).
@@ -73,14 +73,14 @@ Currently shortcuts can be edited for link::Classes/CVCenter::, link::Classes/CV
More information about editing shortcuts with the editor: link::Classes/CVCenterShortcutsEditor::.
argument:: globalShortcuts
-global shortcuts work from whereever you call them - whether IDE, the SClang or any other application is currently the frontmost one does not matter. When global shortcuts are enabled a synth that listens to the users keystrokes will be created at server-boot (every key with an action mapped to it takes one link::Classes/UGen::).
+global shortcuts work from whereever you call them - whether IDE, the SClang or any other application is currently the frontmost one does not matter. When global shortcuts are enabled a synth that listens to the users keystrokes will be created at server-boot (every key with an action mapped to it takes one link::Classes/UGen::).
By default the shortcut (fn)+F1 will front all SClang windows and open CVCenter - can be deactivated at any time.
argument:: keyCodesAndMods
-key-mappings differ from platform to platform and may not be consitant accross all keyboards. As a consequence keycode- and modifier-mappings are made editable. At least on Linux and MacOSX things should work instantly. Windows-users may have to adjust the mappings in the editor (ideally edit and send me a copy so I can update them in the distribution).
+key-mappings differ from platform to platform and may not be consitant accross all keyboards. As a consequence keycode- and modifier-mappings are made editable. At least on Linux and MacOSX things should work instantly. Windows-users may have to adjust the mappings in the editor (ideally edit and send me a copy so I can update them in the distribution).
argument:: informString
-a link::Classes/String::, used as alternative inform-message (optional)
+a link::Classes/String::, used as alternative inform-message (optional)
returns:: this (code::CVCenterPreferences::)
@@ -97,7 +97,7 @@ only needed if the widget is a link::Classes/CVWidget2D:: or a link::Classes/CVW
returns:: an link::Classes/Integer::
METHOD:: setSoftWithin
-If code::midiMode:: has been set to code::0:: moving a widget-slider will set the CV to a new value. However, if a MIDI-slider is connected to that widget, moving the MIDI-slider will set the CV's value immediatly to the value that is stored in the MIDI-slider i.e. a "jump" will happen. code::softWithin:: will ease this behavior by setting the CV's value only if the slider gets within code::softWithin/2::. Applies only if midiMode is set to code::0::.
+If code::midiMode:: has been set to code::0:: moving a widget-slider will set the CV to a new value. However, if a MIDI-slider is connected to that widget, moving the MIDI-slider will set the CV's value immediatly to the value that is stored in the MIDI-slider i.e. a "jump" will happen. code::softWithin:: will ease this behavior by setting the CV's value only if the slider gets within code::softWithin/2::. A threshold code::=< 0:: will deactivate snap-to. Applies only if midiMode is set to code::0::.
argument:: threshold
a link::Classes/Float:: - default: code::0.1::.
@@ -108,7 +108,7 @@ only needed if the widget is a link::Classes/CVWidget2D:: or a link::Classes/CVW
returns:: the receiver
METHOD:: getSoftWithin
-Get the current softWithin value.
+Get the current softWithin threshold.
argument:: slot
only needed if the widget is a link::Classes/CVWidget2D:: or a link::Classes/CVWidgetMS:: - either code::\lo:: or code::\hi:: (CVWidget2D) or an integer index (CVWidgetMS)
@@ -649,7 +649,7 @@ returns:: the receiver
METHOD:: editor
Every widget has one or more editors that will open in a new window ( link::Classes/CVWidgetKnob:: 1 editor, link::Classes/CVWidget2D:: 2 editors - code::\lo:: and code::\hi::). This method returns a reference to them.
-returns:: a link::Classes/CVWidgetEditor:: or an link::Classes/Event::, containing a reference two 2 or more link::Classes/CVWidgetEditor::s
+returns:: a link::Classes/CVWidgetEditor:: or an link::Classes/Event::, containing a reference to 2 or more link::Classes/CVWidgetEditor::s
METHOD:: name
Get the name of a widget. This corresponds with the key under which the widget's CV(s) is/are stored in link::Classes/CVCenter#*all::.

0 comments on commit 58c8b50

Please sign in to comment.