How to create Fader with changing rate

Leofab86

2014-03-21 06:31:12

Hello,

I am looking for a way to change the rate of a fader. I want it to start out fast then progressively slow down. Anyone have any ideas how to do this?

Would appreciate any help! Thanks :)

DvlsAdvct

2014-03-22 13:26:11

Hi Leofab86

I am consulting with Florian to get the best answer for this question. Calculating the curve can be complex. We'll have an answer for you soon. :)

Thanks
Jared

florian

2014-03-22 13:30:36

Hi Leo,

I'm not sure what you are trying to do. If you move the fader with a "constant rate", how can MT slow it down? Do you want to change the "response curve" of the fader? I.e. instead of linearly going from 0...127, it will go fast from 0..10, then a little less fast from 11..20, and even slower afterward?

Basically, this would be a map like this:

Code: Select all

Original Fader Value -> Mapped Fader Value
0 -> 0
1 -> 10
2 -> 19
3 -> 26
4 -> 32
5 -> 37
...
121 -> 125
122 -> 125
123 -> 125
124 -> 126
125 -> 126
126 -> 126
127 -> 127
Ideally, an exponential function would be used here. But MT's rules only allow basic arithmetic. But you can use multiplication to emulate power 2 (pp squared = pp*pp).

So here is a formula for the variable pp to have a slow start and then it's getting increasingly faster:

Code: Select all

pp = pp * pp * 25 / 3170
Basically, 25 and 3170 are scaling factors. I chose 25 at random, then I calculated the maximum value for that (pp=127), which is 127*127*25 = 403225. Now that maximum value must be scaled back so that it is 127. I found that dividing 403225 by 3170 is 127, so that's it.
The lower you choose 25 (and 3170 must be lowered then, accordingly), the less exponential the effect is.

But you want the inverse effect. So I just reverse pp at the beginning:

Code: Select all

pp=127-pp
Now here is the formula in form of rules (with a fictitious controller CC 1 to translate):

Code: Select all

Translator 0: Exponential Map of Controller CC1
  [x]swallow
Incoming: MIDI B0 01 pp
Rules:
 pp=127-pp
 pp=pp*pp
 pp=pp*25
 pp=pp/3170
Outgoing: MIDI B0 01 pp
Now I hope that's what you meant :)
Florian

Leofab86

2014-03-22 19:40:30

Hi guys,

Thanks so much for the suggestion, I will mess around with this exponential function to see if I can get it to meet my needs and will report back. Just for kicks, let me show you the workaround I came up with yesterday that works passably well:

Code: Select all

pp=pp*3
if pp>60 then skip next rule
exit rules, execute Outgoing Action
pp=pp/3
pp=pp+40
This actually creates a speeding up effect from CC 0-20 and then goes to a normal steady speed. You can also create a "2nd gear" so to say with something like this:

Code: Select all

pp=pp*3
if pp>60 then skip next rule
exit rules, execute Outgoing Action
pp=pp/3
pp=pp*2
pp=pp+20
if pp>100 then skip next rule
exit rules, execute Outgoing Action
pp=pp/2
pp=pp+50

florian

2014-03-23 00:43:54

Hi, yes, such a manual speeding up is possible, too. The "pp squared" thing has the advantage that it is smooth ly slowing down and not in steps.

What are you using this with?
Florian

mschnell

2014-03-23 11:36:25

Mathematically, there are several ways to approximate an exponential curve by basic operations.

You could use a polynomial like (a + bx) or (a + bx + cx²) or even (a + bx + cx² + dx³)

0n top of that you could define multiple ranges each with optimized polynomial parameter.

See http://en.wikipedia.org/wiki/Polynomial_interpolation.

You need to select some decent points as fixed values for the calculation. Theses will be the beginning and the end of each range plus one or two points in between for the quadratic or cubic functions.

Regarding quadratic and cubic polynomials, an "approximation" (using more intermediate points) might be even better (but more complicated to calculate) than a plain interpolation.

Another nice option is spline interpolation. This avoids sudden changes in the speed during the slider move.

-> http://en.wikipedia.org/wiki/Spline_interpolation

Again there are algorithms for spline interpolation and (maybe better here) for spline approximation (using more points that spline snippets).

Regarding that we only have to cover 128 values, maybe the most easy to calculate option is rather good: use a number of (say four or five) ranges and do a simple linear interpolation for each of the range. When the ranges are cleverly chosen (wider where the curve is rather straight; smaller, where the curve is rather round) you will be happy enough.

In fact this seems like a standard task and it would be nice if a future version of the Translator would support this out of the box.

-Michael

florian

2014-03-24 02:07:16

Such generalized interpolation will surely give much better control on the shape of the curve than the pp squared thing. Though implementation in MT is somewhat difficult.
mschnell wrote:In fact this seems like a standard task and it would be nice if a future version of the Translator would support this out of the box.
Yes, this is on the list -- some way of specifying curves.

Thanks,
Florian

mschnell

2014-03-24 09:17:45

Ah Functions !

That would be nice.

In fact for "OEM" programmers it would be great to provide a plug-in interface (e.g. calling a user provided DLL) on top of that. :D

-Michael

mschnell

2014-03-24 09:21:57

Regarding mathematical function, IMHO a rather easy to do, fast handled and most versatile solution would be to have the user in the source code provide a set of X/Y pairs and have the "compiler" calculate a set of linar interpolation functions (between the consecutive points) from that. Now at runtime, the interpreter can easily select the appropriate range and calculate the linear function.

-Michael

mschnell

2014-03-24 09:46:14

Regarding the original question:

There is not the exponential curve that converts a value 0..127 to a new value 0..127. When doing the transformation, you can select how "round" the transformation should be (in fact the base of the exponential function).

I did a Spreadsheet that allows for calculating and showing this and then calculates a four-range linear approximation from the result.

I suppose this would be rather easy to be included in a Translator doing something like this (pseudo-code to be tweaked for Translator):

This example uses base = 128. With same you get an output of 8 for an input of 64 (in the middle of the complete range 0..127). The error imposed in the rage pp=0..pp=128 is -1..+3

Smaller base values might be good as well: base 16 would give 25 for 64 with an error of -1..+3, as well.

if pp >= 112 goto e112
if pp >= 96 goto e96
if pp >= 64 goto e64
p1 = 0.1631460489
p2 = -1
goto e0
e64:
p1 = 0.8487686586
p2 = -44.6057650938
goto e0
e96:
p1 = 2.0184580824
p2 = -156.2740646901
goto e0
e112:
p1 = 3.7018684452
p2 = -344.1372925431
e0:
pp = p1*pp+p2
if (pp<0) pp = 0;
pp = round(pp)

Of course I can provide the generating spreadsheet to anybody who might be interested. With same you easily can calculate the eight p1/p2 parameters for base values different from 128 (which in fact can be reduced to rather simple formulas)

-Michael

Leofab86

2014-03-27 01:23:23

Hi guys, thanks again for the time and effort. Just wanted to update you on my situation:

Florian, the function did work to make a curved fader response, unfortunately I couldn't get it to meet my needs. In my specific case I needed a faster response early on in the curve and I couldn't get what I needed by raising the scaling factors.

Fortunately I was able to tweak my original rules to get it to sound very good. The speeding up affect of the multiplier from 0-20 on the fader actually served my purposes very well and I just needed to slow it down in the right spot and I slowed it down further near the end of the curve by using pp/2.

FYI, what I needed this for is absurdly difficult to explain, but maybe ile try just for fun :) Bear with me if you're interested in some interesting performance rig challenges:

Im working on a 4 deck DJ setup running Traktor in external mixing mode so I can run the 4 tracks independently out to Ableton and then have separate Ableton effects on each track. Then im running 2 output lines from Ableton on my 2 output line Soundcard. 1 line Master, 1 line Preview. I also have an APC 40 controlling it all, Traktor and Ableton. Its a great setup, but it creates some issues.

Traktor has an option to have pre-effect faders, so that I can use Traktor's reverb and fade out a track while the reverb tail persists for example. I like this feature but this forces me to use the Faders inside of Traktor. I cant use the Ableton Faders to fade out a track now because the signal is mixed with the reverb when it hits Ableton.

Now this creates a problem for previewing tracks! Traktor in external mode doesnt have an extra line out for previewing tracks. The only way to preview a track would be to have the fader on that track be up in Traktor. Thats the only way a signal would get to Ableton and then I could route it into the Preview channel. So the challenge was to figure out how to preview a track without having it go to the master channel. 1 option was to temporarily have the APC40 fader control the Ableton faders while the Traktor fader was up to full while previewing that track. But that turned out to be too restrictive and it meant I lost the ability to use the pre-fader effects tricks while previewing a track. I wanted something more natural and I came up with a crazy little solution:

When I click to preview a track, it sets the Traktor fader to a super low fader value of about -60 db. This is not enough to be heard out the master. Then I have separate preview channels in Ableton with + 60 Gain utilities in the channel. When I click the preview button, those channels are activated and send their signal to my headphones. The signal I get is at full volume.

The challenge at this point is what happens when I raise the fader while the track is still previewed. The Traktor fader rises quickly at first and slows down as it approaches 0 db. I have to compensate for the increase in gain by decreasing the gain on the Ableton channel otherwise my ears blow up. This is where the need for a curved fader response comes in. I needed the decrease in gain in Ableton to match up close enough to the increase of gain in Traktor to keep a relatively steady volume. I managed to accomplish this with those rules I mentioned.

Anyone that took the time to read this I commend you! lol. Im definitely developing one crazy rig here. I plan on making a youtube video showing off the bells and whistles when it is done, and I will definitely share it with you guys. It is definitely only made possible by your product, so I very much appreciate you guys!

florian

2014-03-27 10:12:16

Hi Leo, that is a good explanation! And I'm happy that Midi Translator, for once, is an ear-saver :)
And yes, by all means, it will be great to see your rig in action.
Thanks,
Florian