Jake Johnson wrote:What I still don't get is how you determine what numbers to feed into it for the shape. Do you have a general shape in mind that you want to create, and then find the numbers that will create it?
Well - let's try to break it down ...:
1) You should get to know the shapes that some functions will give you, and the useful ranges they work with e.g:
1.a) The straight line: "x", simply a rising straight line.
1.b) The square: "x*x", or "pow(x,2)". its useful range is non-negative numbers. e.g. map input from 0->1.
If you map it to negative numbers as well - e.g. -1 -> 1, you'll get a mirror image of the 0->1, i.e. a "bowl" shape - first falling, then rising. You don't want that for velocity.
1.c) sin(x) - it gives you a wave, a full cycle for x=0 -> x=2*PI. A wave in itself is not useful, because it sometimes rises, but sometimes fall - which you don't want. (In math it mean sin(x) is "not monotonously rising", or simply "not monotone"). But later we'll see how to combine functions and make sin(x) useful to create a "rising wave"
Regarding the range you either map the input from 0 -> 6.28, (== 2*PI)
but I prefer to map the input to the number of half-cycles you want,
e.g.: 0->2 for a full cycle, 0->3 for a cycle and half. You can also play with the phase by mapping 1->3, will give you a full cycle but starting on the "off beat" of the cycle.
and then write in f(x): sin(x*PI)
1.d) The cube: "x*x*x", or "pow(x,3)" -> in the positive range it is similar to x*x, but steeper. However in the negative range it doesn't give you a mirror image, but rather a "rotated" image ,so it is monotone around (-1 -> 1), with a nice S shape.
1.e) The square root: "pow(x,0.5)" - gives a fast rising edge. Can only be used for non-negative inputs - so map your inputs to 0->1
There are more functions, the cos (similar to sin), atan (another interesting s-shape)...
2) but now you can combine them ....
So basically think of if as a "mixing console" - you can combine two (or more) shapes with different "volumes" by adding them together, and multiplying each one by its respective "volume", or coefficient.
So e.g. - if you want a "rising wave" - than you can combine the "sin" function with the straight line "x" like so:
map input to (0 -> 2)
fx: sin(x*PI) + x.
Still not steep enough - let's give "x" some more volume
sin(x*PI) + x*2
not enough ... how about:
sin(x*PI) + x*4
This gives a monotone shape ...
another example: say you want to combine the square-root "pow(x,.5)" with the cube S-shape "pow(x,3)".
The problem here is that square-root can only be used in ranges >0, e.g. 0->1, and the cube you want to use in range -1->1 ...
So what you can so map the input to 0->1, and adjust X inside pow(x,3) to go from range -1->1, like so:
pow(x*2-1, 3).
Combining the to functions together:
pow(x,.5) + pow(x*2-1, 3)
Playing with the coefficients to get interesting results:
30*pow(x,.5) + pow(x*2-1, 3)
Jake Johnson wrote:Separate question: would it be possible to create a randomization thing for this, with some set, unvarying conditions (the scale must slant to the right, the next step can't be lower than the previous steps, etc)? Just a thought.
Enjoying satan.
Well you can use "random()" combined with some other curve, and give random a low coefficient, so that it only rises, like so:
0.1*random(1) + x
or:
0.2*random(1) + pow(x,3) + x
etc ....
Personally I'd rather have my curve precise w/o any randomness...
best,
Eran
Last edited by etalmor (25-03-2010 09:02)
M-Audio Profire 610 / Roland Fp-3 / Reaper / PianoTeq!
www.myspace.com/etalmor