SynthMaker

Attention ASM-FU experts... Interpolated Delay?

Archive · 2008 15 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

infuzion ·

stefan wrote: Plus, the only way to get different results is to have an external seed that changes for each "trigger"....

We have green Random already.

TomC ·

Andrew J wrote: Large wrote: Also needed is pure ASM white noise, that sounds different each time you hit the key on the keyboard.

Pseudo random noise routines (such as rand31-Park-Miller-Carta) are usually based on integer operations and we don't have the appropriate ASM instructions available to us in SM. I spent a bit of time on trying to get this work back in March, but it just won't (works fine in C++ though!).

I've implemented my own white noise algorithm (which, by the way, needs half as much cycles as the original SynthMaker generator). Maybe tonight I can figure out a way to make it different for each start.

Tom

stefan ·

infuzion wrote: stefan wrote: Plus, the only way to get different results is to have an external seed that changes for each "trigger"....

We have green Random already.

True 🙂

Andrew J ·

stefan wrote: infuzion wrote: stefan wrote: Plus, the only way to get different results is to have an external seed that changes for each "trigger"....

We have green Random already.

True 🙂

I was about to ask for system time for seeding too, but I see the green Random already has it 🙂

TomC - I'm interested to see what you've got!

TomC ·

Andrew J wrote: I was about to ask for system time for seeding too, but I see the green Random already has it 🙂

TomC - I'm interested to see what you've got!

I've uploaded it to the Wiki. There's some documentation inside if you'd like to seed it with float or stream values.

Tom

Large ·

TomC:

Very nice, it has complete frequencies through the spectrum except in the 12800Hz area. It is louder there.

"The generator is always running, so if you want to trigger it per note you have to add a gate."

Could you add that gate please? I have no idea what you mean. To have it running contstanty = unecessesary CPU usage. Not good.

Also I added a randomizer (unless you can make a better one, please? 🙂 ). If you could convert the randmizer to ASM, the would be beautiful 🙂

ALSO, when compared to the "Other Noise" in the attached OSM, your noise still eats more CPU. Could you reduce the CPU lower than "Other Noise"?

Thanks.

TomC ·

Large wrote: TomC:

Very nice, it has complete frequencies through the spectrum except in the 12800Hz area. It is louder there.

"The generator is always running, so if you want to trigger it per note you have to add a gate."

Could you add that gate please? I have no idea what you mean. To have it running contstanty = unecessesary CPU usage. Not good.

As soon as you connect it to an audio out it produces sound. But that's the same for every code in SynthMaker, so there's no "unnecessary" CPU usage. My statement was more in the direction that if you want to make noise when a MIDI note is played you have to trigger it with the MIDI event, and the provided gate (from the Voice to Poly" primitive) is the best way to do this. I'll probably find some time tomorrow to show you an example.

Large wrote: Also I added a randomizer (unless you can make a better one, please? 🙂 ). If you could convert the randmizer to ASM, the would be beautiful 🙂

Much simpler solution I use: I compute a seed from the Freq, Pitch and Velocity outputs of the Voice to Poly module. Simple, doesn't need much CPU and it's (almost) always different. I'll post a complete example this weekend.

Large wrote: ALSO, when compared to the "Other Noise" in the attached OSM, your noise still eats more CPU. Could you reduce the CPU lower than "Other Noise"?

Thanks.

Huh? On my system (Dualcore Athlon) mine is 39, the other one is 61 cycles. I'll check on my QuadCore box.

What system are you using?

Tom

TomC ·

Here we go: I've added a seed from the Voice to Poly module and the gate.

Andrew J ·

Thanks for sharing your technique Tom, it certainly is a CPU light noise generator. However, on my system it's looking a long way off having a flat spectral density, it's a lot less flat than the SM stock one. My needs are for the flattest white noise I can get, but yours might be useful for synthesis (to add a bit of flavour).

Incidentally, here is a bit of code I got off the forum ages ago that I've attributed to kingston/sambean (not sure who did what now without looking it up):

streamout out; float rand=0.600001;

stage(0) {rand=rand;} stage(1) { rand = rand*3; rand = rand - (rand>2)&1; rand = rand - (rand>1)&1; out = rand*2 - 1;

}

This one runs nearly as fast as yours but could do with some ASM-fu. It's close to white noise, with only a bit of tailing off at higher frequencies and no resonant peak.

aliasant ·

Thats funny Andrew. That is the code I use and I happened to Asm it a while back. It uses 18 cycles. I think I have modded it slightly but not much. If the "float gain" is set to 2 it is normalized. lower values will give lower gain.

streamout out; float rand=0.600001;float F3=3;float F2=2; float F1=1;float F0P5=0.5; float gain=2; // 2 = normalized gain output stage1; movaps xmm0,rand; mulps xmm0,F3; movaps rand,xmm0; cmpps xmm0,F2,6; andps xmm0,F1; movaps xmm1,rand; subps xmm1,xmm0; movaps rand,xmm1; cmpps xmm1,F1,6; andps xmm1,F1; movaps xmm0,rand; subps xmm0,xmm1; movaps rand,xmm0; subps xmm0,F0P5; mulps xmm0,gain; movaps out,xmm0;

Andrew J ·

Well there you go.

IIRC, the code was inside a pink noise generator and I got the white noise bit out just be removing the filter...

TomC ·

Andrew J wrote: Thanks for sharing your technique Tom, it certainly is a CPU light noise generator. However, on my system it's looking a long way off having a flat spectral density, it's a lot less flat than the SM stock one. My needs are for the flattest white noise I can get, but yours might be useful for synthesis (to add a bit of flavour).

Incidentally, here is a bit of code I got off the forum ages ago that I've attributed to kingston/sambean (not sure who did what now without looking it up):

streamout out; float rand=0.600001;

stage(0) {rand=rand;} stage(1) { rand = rand*3; rand = rand - (rand>2)&1; rand = rand - (rand>1)&1; out = rand*2 - 1;

}

This one runs nearly as fast as yours but could do with some ASM-fu. It's close to white noise, with only a bit of tailing off at higher frequencies and no resonant peak.

Here we go:

streamout out; float rand=0.600001; float F3=3; float F2=2; float F1=1;

movaps xmm0,rand; // rand = rand*3 mulps xmm0,F3; // rand in xmm0

movaps rand,xmm0; // rand = (rand>2)&1 cmpps xmm0,F2,6; andps xmm0,F1; movaps xmm1,rand; subps xmm1,xmm0; movaps rand,xmm1; // rand in xmm1

cmpps xmm1,F1,6; // rand = (rand>1)&1 andps xmm1,F1; movaps xmm0,rand; subps xmm0,xmm1; movaps rand,xmm0; // rand in xmm0

mulps xmm0,F2; // rand = rand*2 - 1; subps xmm0,F1; // rand in xmm0

movaps out,xmm0;

My optimized version is about twice as fast as the SM-coding and nulls perfectly, so I must have done something right 🙂

Tom

MyCo ·

streamout out; float rand=0.600001; float F3=3; float F2=2; float F1=1; float FM1=-1; // added

movaps xmm0,rand; mulps xmm0,F3;

// movaps rand,xmm0; // removed cmpps xmm0,F2,6; andps xmm0,FM1; // original: andps xmm0,F1; //movaps xmm1,rand; // removed addps xmm0,rand; // original: subps xmm1,xmm0; //movaps rand,xmm1; // removed

cmpps xmm0,F1,6; // changed register from xmm1 andps xmm0,FM1; // original: andps xmm0,F1; //movaps xmm0,rand; // removed addps xmm0,rand; // original: subps xmm0,xmm1; movaps rand,xmm0;

mulps xmm0,F2; addps xmm0,FM1; // original: subps xmm0,F1;

movaps out,xmm0;

That's just the first step of optimizing... you can cache some variables in registers and try to get more out of it

exonerate ·

Good point myco....but you've changed the algorithm..

This would be correct...

streamout out; float rand=0.600001; float F3=3; float F2=2; float F1=1; float FM1=-1; // added

movaps xmm0,rand; mulps xmm0,F3; movaps xmm7,xmm0; //store current rand value in xmm7

cmpps xmm0,F2,6; andps xmm0,FM1; // original: andps xmm0,F1;

addps xmm0,xmm7; // original: subps xmm1,xmm0; movaps xmm6,xmm0;

cmpps xmm0,F1,6; // changed register from xmm1 andps xmm0,FM1; // original: andps xmm0,F1;

addps xmm0,xmm6; // original: subps xmm0,xmm1; movaps rand,xmm0;

mulps xmm0,F2; addps xmm0,FM1; // original: subps xmm0,F1;

movaps out,xmm0;

TomC ·

MyCo wrote: That's just the first step of optimizing... you can cache some variables in registers and try to get more out of it

Your code optimized:

streamout out; float const=0.2;

movaps xmm0, const; movaps out,xmm0;

...because (at least on my machine) your code produces the constant output of "0.2"

Tom

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.