From the original SynthMaker forum (2004–2014), with its members’ names and dates.
datsound ·
I had a zealous idea for a stream X^y module that should be 92 percent faster than the present one and precise mathematically. i was going to go it alone but there are various ways of doing it so i want to ask your advice about which way is best.
there are 2 codes to do this already, but one of them is inaccurate and the other takes 5MB and relies on arrays rather than pure maths. still i may be working at nothing it's more for the challenge than the usefulness, please tell me if yo think it's a waste.
the idea is to make 180 fixed exponent codes, to represent midi pitches 0-180, and to link them all to a selector module, or multiple selectors in a hierarchy chain, and to crossfade in between any 2 for intermediate exponents.
so that
x^127.3 = x^127*.7 + x^128*.3
and ...
x^69.501 = x^69*.499+ x^70*.501
But i dont know if the formula could be factorised into a small efficient code.
if you tried to loop x*Y, 180 times it wold be a simple formula, but it wold take crazy amounts of processing power.
so in code it would look like this:
x^127 = x^64 * x^32 * x^16 * x^8 * x^4 * x^2 * x^1..... add all the numbers together it makes 127.
x^128 = x^64 * x^64
all the numbers would be made of building blocks like this:
x2 = x*x
x4 = (x2)(x2)
x8 = (x4)(x4)
x16 = (x8)*(x8)
...
x128 = (x64)*(x64)
... i was going to code every factor individually from 1-128 but that is abit mad. i was also wondering if it could be simplified into a code routine that adds the blocks together to make the number all in one.
i feel this is abit of a mad idea, i dont know why i am excited by it. am a geek. maybe i will abandon it!
datsound ·
due to an insane train of logic i felt compelled to program this in one chunky lump of code.
it saved about 3 cycles from 4 hours work but i learnt in the process. the hopped p-f module now saves 88 percent instead of 83 percent and is totally accurate. if i had bothered to write 180 chunks of code with a selector insteaf of one chunk, then it would probably have been 99 percent faster but i will leave that to someone else.
for anyone reading this from the exitement of an 18 hour bus journey through the north pole, here is the code:
I think your best bet would be to use a taylor expantion about a point or a series of points. that way you could get away with only a small umber of coefitients in the maths and reduce the number of value you need in the array.
so find closest. find differnece extrapolate using taylor expantion to say 2nd order.
then you can alter the memory or speed requirments by increasing or decreasing the expantion order.
compare look up, expand, output.
should be looking at about 30 cycles.
slower for most integer powers but should be faster for most fractional powers.
unless you add some logic to say, if distance from table =zero output, which would make it basicaly the same speed as calculating it for integer powers.
Steve
datsound ·
Thanks, a real mathematician who who knows about these things. I tried to find exponential approximation functions and it led me down the wrong path, I will check out the Taylor expansions and we'll see if I can write one up for exponentials.
Wrote something here? To have a post removed or your name hidden, write to [email protected].