ArrayArrayArrayArray BrainModular BrainModular Users Forum 2024-12-24T11:43:58+02:00 https://brainmodular.com/forums/app.php/feed/topic/7315 2024-12-24T11:43:58+02:00 2024-12-24T11:43:58+02:00 https://brainmodular.com/forums/viewtopic.php?t=7315&p=45639#p45639 <![CDATA[Re: log vs exp question]]> Statistics: Posted by senso — 24 Dec 2024, 10:43


]]>
2024-12-12T09:26:43+02:00 2024-12-12T09:26:43+02:00 https://brainmodular.com/forums/viewtopic.php?t=7315&p=45614#p45614 <![CDATA[Re: log vs exp question]]>

CODE:

///////////////////////////////////////////////////////////// TOUCH FADER// eric moon 2024// Wire this up to a fader to get a feature where you can touch the fader at a // spot, and it will go to that value.// dragging works as usual.// set logIN on, if your fader is set to logarithmic taper// if your fader goes from 0 to 1, you shouldn't have to wire in min and max// slop is how much mouse movement is needed to be considered 'dragging'/////////////////////////////////////////////////////////////// Globally enable/disable logging const DTAG = 'TextButton: ';const DBUG_ON = TRUE;procedure debug(s: string); begin if DBUG_ON then strace(DTAG + s); end;procedure iDebug(s: string; num : integer); begin debug(s + '= ' + intToStr(num)); end;procedure fDebug(s: string; num : single); begin debug(s + '= ' + floatToStr(num)); end;// Always log, whether debug is on or not.procedure Error(s: string); begin strace('ERROR-' + DTAG + s); end;procedure fError(s: string; num : single); begin strace('ERROR-' + DTAG + s + '= ' + floatToStr(num)); end;procedure iError(s: string; num : integer); begin strace('ERROR-' + DTAG + s + '= ' + intToStr(num)); end;const LOG_TAPER = 1;const LINEAR_TAPER = 0;var mouseValIN, mouseDownIN, minIN, maxIN, slopIN, logIN, valueOUT: tParameter;var gMouseVal: float;var doneMousing, mouseDown: boolean;// when we see the mouseDown, we note the mouseValue.  If it is the same (within slop) when the mouse is released// just set the fader to that valueprocedure init;var i : integer;                   begin                               SetModuleColor($804080+600000);     minIN := CreateParam('fader min', ptDatafield, pioInput);     minIN.DefaultValue(0);    maxIN := CreateParam('fader max', ptDatafield, pioInput);     maxIN.DefaultValue(1);     logIN := CreateParam('log taper', ptSwitch, pioInput);        mouseDownIN := CreateParam('mouse down', ptSwitch, pioInput);    mouseValIN := CreateParam('mouse X', ptDatafield, pioInput);    slopIN := CreateParam('slop in', ptDatafield, pioInput);     slopIN.DefaultValue(0.05);    valueOUT := CreateParam('val to fader', ptDatafield, pioOutput);    doneMousing := FALSE;END;//todo: could track mouse movement more continuously.procedure mouse(down: boolean);var current, travel, range, val: float;begin    if down then     begin        mouseDown := TRUE;        gMouseVal := mouseValIN.asFloat;   //store the mouse value        fDebug('mouse val ',gMouseVal);    end    else    begin        mouseDown := FALSE;        current := mouseValIN.asFloat;        travel := abs(gMouseVal - current);                fDebug('travel ', travel);        range := maxIN.asFloat - minIN.asFloat;        //compute mouse movement         if travel < slopIN.asFloat then        // set value of control        begin                   if logIN.asInteger = LOG_TAPER then current := current * current * current * current;            val := minIn.asFloat + (current * range);                        fDebug('val ', val);            valueOUT.asFloat(val);        end;    end;end;procedure callback(n: integer);begin    if n = mouseDownIN then mouse(mouseDownIN.asInteger = 1);end;procedure processIdle();begin    if not mouseDown then     begin        //doneMousing := FALSE;        valueOUT.length(-1);    end;end;

Statistics: Posted by woodslanding — 12 Dec 2024, 08:26


]]>
2024-12-12T07:42:10+02:00 2024-12-12T07:42:10+02:00 https://brainmodular.com/forums/viewtopic.php?t=7315&p=45612#p45612 <![CDATA[Re: log vs exp question]]>
cheers,
-e

Statistics: Posted by woodslanding — 12 Dec 2024, 06:42


]]>
2024-12-12T00:30:00+02:00 2024-12-12T00:30:00+02:00 https://brainmodular.com/forums/viewtopic.php?t=7315&p=45611#p45611 <![CDATA[log vs exp question]]>
It works fine so far, but then I realized that I needed my fader to be log taper. And I can't figure out what math to do on the mouse-position-based VAL (normalized to 0..1) to get log taper out.

VAL := log(VAL) gives negative numbers, and VAL := exp(VAL) gives numbers above 1. Neither is what I expected...

THANKS!
=e

edit: you can ignore the bit about negative and over-values--I was doing my range adjusting before the conversion. But I still don't know what usine's log taper is. Some research on audio taper makes it seem like this is not a universal standard... so I guess I need to know the math behind usine's implementation....

Statistics: Posted by woodslanding — 11 Dec 2024, 23:30


]]>
BrainModular BrainModular Users Forum 2024-12-24T11:43:58+02:00 https://brainmodular.com/forums/app.php/feed/topic/7315 2024-12-24T11:43:58+02:00 2024-12-24T11:43:58+02:00 https://brainmodular.com/forums/viewtopic.php?t=7315&p=45639#p45639 <![CDATA[Re: log vs exp question]]> Statistics: Posted by senso — 24 Dec 2024, 10:43


]]>
2024-12-12T09:26:43+02:00 2024-12-12T09:26:43+02:00 https://brainmodular.com/forums/viewtopic.php?t=7315&p=45614#p45614 <![CDATA[Re: log vs exp question]]>

CODE:

///////////////////////////////////////////////////////////// TOUCH FADER// eric moon 2024// Wire this up to a fader to get a feature where you can touch the fader at a // spot, and it will go to that value.// dragging works as usual.// set logIN on, if your fader is set to logarithmic taper// if your fader goes from 0 to 1, you shouldn't have to wire in min and max// slop is how much mouse movement is needed to be considered 'dragging'/////////////////////////////////////////////////////////////// Globally enable/disable logging const DTAG = 'TextButton: ';const DBUG_ON = TRUE;procedure debug(s: string); begin if DBUG_ON then strace(DTAG + s); end;procedure iDebug(s: string; num : integer); begin debug(s + '= ' + intToStr(num)); end;procedure fDebug(s: string; num : single); begin debug(s + '= ' + floatToStr(num)); end;// Always log, whether debug is on or not.procedure Error(s: string); begin strace('ERROR-' + DTAG + s); end;procedure fError(s: string; num : single); begin strace('ERROR-' + DTAG + s + '= ' + floatToStr(num)); end;procedure iError(s: string; num : integer); begin strace('ERROR-' + DTAG + s + '= ' + intToStr(num)); end;const LOG_TAPER = 1;const LINEAR_TAPER = 0;var mouseValIN, mouseDownIN, minIN, maxIN, slopIN, logIN, valueOUT: tParameter;var gMouseVal: float;var doneMousing, mouseDown: boolean;// when we see the mouseDown, we note the mouseValue.  If it is the same (within slop) when the mouse is released// just set the fader to that valueprocedure init;var i : integer;                   begin                               SetModuleColor($804080+600000);     minIN := CreateParam('fader min', ptDatafield, pioInput);     minIN.DefaultValue(0);    maxIN := CreateParam('fader max', ptDatafield, pioInput);     maxIN.DefaultValue(1);     logIN := CreateParam('log taper', ptSwitch, pioInput);        mouseDownIN := CreateParam('mouse down', ptSwitch, pioInput);    mouseValIN := CreateParam('mouse X', ptDatafield, pioInput);    slopIN := CreateParam('slop in', ptDatafield, pioInput);     slopIN.DefaultValue(0.05);    valueOUT := CreateParam('val to fader', ptDatafield, pioOutput);    doneMousing := FALSE;END;//todo: could track mouse movement more continuously.procedure mouse(down: boolean);var current, travel, range, val: float;begin    if down then     begin        mouseDown := TRUE;        gMouseVal := mouseValIN.asFloat;   //store the mouse value        fDebug('mouse val ',gMouseVal);    end    else    begin        mouseDown := FALSE;        current := mouseValIN.asFloat;        travel := abs(gMouseVal - current);                fDebug('travel ', travel);        range := maxIN.asFloat - minIN.asFloat;        //compute mouse movement         if travel < slopIN.asFloat then        // set value of control        begin                   if logIN.asInteger = LOG_TAPER then current := current * current * current * current;            val := minIn.asFloat + (current * range);                        fDebug('val ', val);            valueOUT.asFloat(val);        end;    end;end;procedure callback(n: integer);begin    if n = mouseDownIN then mouse(mouseDownIN.asInteger = 1);end;procedure processIdle();begin    if not mouseDown then     begin        //doneMousing := FALSE;        valueOUT.length(-1);    end;end;

Statistics: Posted by woodslanding — 12 Dec 2024, 08:26


]]>
2024-12-12T07:42:10+02:00 2024-12-12T07:42:10+02:00 https://brainmodular.com/forums/viewtopic.php?t=7315&p=45612#p45612 <![CDATA[Re: log vs exp question]]>
cheers,
-e

Statistics: Posted by woodslanding — 12 Dec 2024, 06:42


]]>
2024-12-12T00:30:00+02:00 2024-12-12T00:30:00+02:00 https://brainmodular.com/forums/viewtopic.php?t=7315&p=45611#p45611 <![CDATA[log vs exp question]]>
It works fine so far, but then I realized that I needed my fader to be log taper. And I can't figure out what math to do on the mouse-position-based VAL (normalized to 0..1) to get log taper out.

VAL := log(VAL) gives negative numbers, and VAL := exp(VAL) gives numbers above 1. Neither is what I expected...

THANKS!
=e

edit: you can ignore the bit about negative and over-values--I was doing my range adjusting before the conversion. But I still don't know what usine's log taper is. Some research on audio taper makes it seem like this is not a universal standard... so I guess I need to know the math behind usine's implementation....

Statistics: Posted by woodslanding — 11 Dec 2024, 23:30


]]>