SynthMaker

Fsqrt in the Asm module?

Archive · 2009 8 old posts

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

Zyxoas ·

Hey peeps.

I've been working on a little ACG schematic for normalising vocals in real time (though it may also be used as a special effect). As part of the analysis stage, I chain an RMS detector, a Hilbert transform-based envelope follower, and a normal adjustable envelope follower. Both the RMS and Hilbert detectors need to find the square root of a mono signal as part of their processing.

Initially, I used the stream power module that came with Synthmaker. Then I realised that I could speed it up by only processing the [0] data in the assembler component (the included module processes the parameters 4 times, because of SSE packing, but my analysis signal is a simple mono value).

Now, it had been a while since I learnt Assembly Language, so it took me a little time to realise that, instead of using a stream power with the exponent input permanently set to 0.5, I could actually directly calculate the square root itself.

Now, here comes the problem. Although it is a valid floating point instruction, the asm module DOES NOT RECOGNISE THE FSQRT INSTRUCTION. Using it shows a syntax error, and the module produces a bunch of NANs as output, corrupting every component downstream (by the way, the use of a loop in the level meter module, inside the smoothing module, means that you have to actually get inside the schematic and manually reset the looped float every time it gets strange values like NANs).

Why doesn't fsqrt work in the asm module, and can anyone possibly provide me with very fast square root code I can use in the asm module?

TomC ·

Zyxoas wrote: Then I realised that I could speed it up by only processing the [0] data in the assembler component (the included module processes the parameters 4 times, because of SSE packing, but my analysis signal is a simple mono value).

A good assumption would be that the standard stream power primitive uses SSE coding, so it doesn't matter (much) if the signal is mono.

Zyxoas wrote: ...and can anyone possibly provide me with very fast square root code I can use in the asm module?

Never tested if it's actually faster than the primitive, but since I had it laying around anyway I've uploaded my sqrt(x) approximation to the Wiki.

Tom

TomC ·

Umh, nevermind, there's already a mono/poly version from Shif et. al. around here which uses the sqrtps command and which is WAY faster than my approximation.

Just do a search.

Tom

Zyxoas ·

Thanks a lot, Tom! I used the single SSE instruction method, simply because downloading files is a pain for me due to technical issues. If you'd like to copy your code here then I'll try it out.

However, none of this answers the question of why fsqrt does not work in Synthmaker. Developers?

TomC ·

Zyxoas wrote: Thanks a lot, Tom! I used the single SSE instruction method, simply because downloading files is a pain for me due to technical issues. If you'd like to copy your code here then I'll try it out.

Just use this one, it's faster:

monoin in; monoout out;

movaps xmm0,in; sqrtps xmm1,xmm0; movaps out,xmm1;

Zyxoas wrote: However, none of this answers the question of why fsqrt does not work in Synthmaker. Developers?

There are a LOT of ASM/SSE commands not available in SM. And yes, we've already made requests to add them.

Tom

infuzion ·

TomC wrote: Zyxoas wrote: However, none of this answers the question of why fsqrt does not work in Synthmaker. Developers?

There are a LOT of ASM/SSE commands not available in SM. And yes, we've already made requests to add them.

Indeed: + SSE2=64bit audio, SSE3=faster FFT... please

theun ·

Actually, there is only a very limited subset of ASM instructions available, here is the menue from which you can choose:

[old link]

Zyxoas ·

Okay, thanks a lot guys.

I guess that, since Synthmaker is not a dedicated assembler, the developers might find it time-consuming/challenging to implement full assembly support.

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.