Open elanhickler opened 7 years ago
ok now i get it! I chose 5, I think I'll go with that.
as said, i would adjust b in a way such that the graph passes though x = 0.5, y = "some middle value", perhaps 1kHz if we are dealing with audible frequencies up to 20000
...maybe i could come up with an equation to automatically calculate b from such a requirement....but i think, it involves solving an implicit equation
...could certainly be done by newton iteration, though
The mapper stuff is awesome! Now for the final coup-de-grace.
I need a bipolar log, so the opposite curvature of sinh.. oh jeez, I probably don't have the math knowledge to build a map and unmap function for that, might have to ask you to do it.
what about tanh?
for what kind of parameter is this?
triangle sharpness. As you get toward -1 or +1 sharpness (essentially sawtooth shape) the harmonics increase exponentially, so we need to undo that exponenialness by doing a log curve.
Edit: Oh, it's exactly like the xoxos oscillator how some parameters make the shape sharper., I think you mentioned the C parameter?
Edit: Actually C is the opposite, you need bipolar expo, but A parameter could use bipolar log. see: https://www.desmos.com/calculator/7h9mknbv3q
and yes, tanh would work im sure!
what was your rational shape formula - do you know this off the cuff? ...the one with a and x or x^2 in numerator and denominator. this came up before several times but i can't memorize the whereabouts. couldn't that be suitable mapping too?
yes i was just thinking about that, i think we are on the same wavelength of thinking right now.... going to make a desmos for it, one sec.
edit: here's the code for now
double curve(double value, double tension)
{
double t = tension;
double v = value;
return (t*v-v)/(2*t*v-t-1);
}
double s_curve(double value, double tension)
{
double t = tension;
double v = value;
if (v < 0.5)
return (t*v-v) / (4*t*v-t-1);
v += -0.5;
t *= -0.5;
return (t*v-v*0.5) / (4*t*v-t-0.5) + 0.5;
}
yes. i guess, it makes sense to provide a mapper using these curves, too. maybe in two versions: unipolar and bipolar
Edit: Actually C is the opposite, you need bipolar expo, but A parameter could use bipolar log. see: https://www.desmos.com/calculator/7h9mknbv3q
c bipolar exp is what i was saying, iirc. a being sigmoid (it's not a log)...don't know. set b to 1.57 and the linear scaling for a feels just right, imho. it becomes more complex when parameter interact
set b to 1.57 and the linear scaling for a feels just right
setting b to 1.57 doesn't change the fact that you're still going from no sharpness to infinite sharpness, you should approach that infinity slower.
see gif: https://puu.sh/y321n/e883d67973.gif
near 1 sharpness, you're not able to fine control the harmonic content, while near 0 you have a lot more control than needed. You'll experience the same phenomenon with xoxos A parameter.
aha! good to know. so it needs some fine tuning of the parameter mapping to make it feel more "musical"
Hey robin, if you could implement a bipolar-log style mapper today that would be nice because I don't have to break presets for adding it later. You can charge me time for this. I am just about ready to start making presets and audio demos. Edit: Oh it's saturday, you don't work saturday/sunday, haha, ok.
ok - i made a tanh based sigmoid mapper. that was actually so easy, i did it in 5 minutes (not really worth to account work time for this). it was just a matter of copy/paste the code of the sinh mapper and replace sinh/asinh by tanh/atanh:
https://www.desmos.com/calculator/ppx5yhza2r
but i didn't test it yet - but i can't imagine anything going wrong
...but now i wonder, if i could somehow factor out the common code. code duplication sucks (violates the DRY principle)
i still think, your rational function should perhaps be available too ...i think, the exact behavior/trade-off/precision-curve will be very different from tanh, even though looks sort of similar (both functions are sigmoid) ...or well, the rational can actually continuously sweep between sigmoid, linear and ....äääähhh.....dunno, how this is called
I'm starting to create some "controller profiles" so we can set all this crap all at once,
string conversion function, step size, modulation ranges, modulation limits, slider scalings, etc. just do away with all the confusing and verbose "per slider settings" and just describe what the intention is.
Edit: Doing away with my range enum as well, just going to do lots of profiles, make a new one for every control if needed, that way everything is set in one place. I can customize specific details after choosing a profile as well, before instantiating the parameter.
Oh I just realized before we even started working together I was using rational function scaling for filter frequencies, so I could go from 0 to 20,000hz instead of 1.e-6 to 20,000, I found that scheme to be very nice for my chaos generator. I might try to implement the unipolar rational function myself, unless you get to it first.
ok, do it. you'll probably be faster. i'm in weekend mode now. soon off to a goa party. i think, for frequencies, the exponential scaling is just right. it translates equal distances on the slider to equal multiplication factors in value. i.e. the slider distance between 100 and 200 Hz is the same as between 1000 and 2000 or 10000 and 20000. this is parallels how humans perceive frequency (and a lot of other things):
https://en.wikipedia.org/wiki/Weber%E2%80%93Fechner_law
however, we could perhaps be even more fancy and do some scaling based on that:
slider/parameter profiles sounds like a good idea. ...like just calling:
setParameterProfile(myParameter, FILTER_FREQ)
or something ...which then sets min/max default values, etc. gets rid of a lot of duplicated code. i think, i want that in my framework, too
you are applying the DRY principle! :-D
before: https://puu.sh/y321n/e883d67973.gif after: https://puu.sh/y3V1F/75679b3b09.gif
SO MUCH BETTER.
ok, I tried to implement rational function, but I don't understand what value ranges are being sent to map/unmap function and I can't get a breakpoint on it.
edit: nevermind, figured it out.
What was confusing at first is that setRange isn't called... or at least it wasn't working until I had setRange in the constructor of the custom mapper.
Edit: Will make a pull request soon. Also, I made my "skip zero" mapper.
For sliders, could you provide an option per slider to allow user to type in and accept a value that is outside the range of the slider?