SynthMaker

a mad code idea

Archive · 2010 5 old posts

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:

streamin exp; streamin b; streamout out;

float a128; float a64; float a32; float a16; float a8; float a4; float a2; float a1;

float x128; float x64; float x32; float x16; float x8; float x4; float x2;

float m1; float m2;

float z1; float z2; float z4; float z8; float z16; float z32; float z64; float z128;

float h1; float h2; float h3; float h4; float h5; float h6;

hop(128){ //make exponent squares squareval 2 to 128; x2= b*b; x4=x2*x2; x8=x4*x4; x16=x8*x8; x32=x16*x16; x64=x32*x32; x128=x64*x64;

//from 128 to 1, find squares inside exponent. //delete any present squares from remainder //from 128 to 2 and value 1/0 if square is present/absent a128 =(exp>=128) & 1; a64 = (exp-(128*a128))>=64 & 1; a32 = (exp-(64*a64)-(128*a128))>=32 & 1; m1 = (-64*a64)-(128*a128)-(32*a32); a16 = (exp+m1)>=16 & 1; a8 = (exp+(m1)-(a16*16))>=8 & 1; a4 = (exp+(m1)-(a8*8)-(a16*16))>=4 & 1; m2 = ((m1)-(a16*16)-(a8*8)-(a4*4)); a2 = (exp+(m2))>=2 & 1; a1 = (exp+(m2)-(a2*2))>=1 & 1;

//revalue present absent 1/0 to square-val/1 z1 = (a1*(b-1))+1; z2 = (a2*(x2-1))+1; z4 = (a4*(x4-1))+1; z8 = (a8*(x8-1))+1; z16= (a16*(x16-1))+1; z32= (a32*(x32-1))+1; z64= (a64*(x64-1))+1; z128= (a128*(x128-1))+1;

//multiply all square vals present h1 = z1*z2*z4*z8*z16*z32*z64*z128; h2 = h1*b; h3 = exp % 1; h4 = (h1*(1-h3))+(h2*h3);

out = h4 ; }

adamszabo ·

thanx dude

Disco_Steve ·

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].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.