If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Audio Compression & Limiting - low CPU%
37 posts
• Page 4 of 4 • 1, 2, 3, 4
Re: Audio Compression & Limiting - low CPU%
trogluddite wrote:The only restriction is that the number of loop iterations has to be the same for all SSE channels; other than that you can put whatever code you like as the loop body, and there's no restriction on what variables and registers you use there (so long as you keep the matching eax push/pops). The first example, with the fixed loop iterations, is exactly the same assembly that gets produced by the DSP loop(x){...} instruction.
What I mean is having each loop get a different variable,so on each iteration it gets a different value from an array or something like in ruby. Is that what you explain? Maybe I didnt understand it correctly
- adamszabo
- Posts: 667
- Joined: Sun Jul 11, 2010 7:21 am
Re: Audio Compression & Limiting - low CPU%
Ah, sorry, I think I did misinterpret your question. Yes, that would be possible - in fact, actually quite easy in many cases, because the 'eax' register holds the loop count, and 'eax' is nearly always needed in array index calculations anyway. The only hassle is that it's tricky to get 'eax' to count forwards for variable loop lengths, as the opcodes for subtracting and comparing 'eax' with a value from memory aren't available (in FS3.0.6, at least).
Here's a quick example which sums the values in a Ruby Frame...
Note that, in this example, I've also type-punned the Frame size, so that the ASM can just read it directly as an integer rather than converting it within the ASM - though, you might not want to do that if the value were needed as part of the calculations (if the example were calculating the average, say).
Here's a quick example which sums the values in a Ruby Frame...
Note that, in this example, I've also type-punned the Frame size, so that the ASM can just read it directly as an integer rather than converting it within the ASM - though, you might not want to do that if the value were needed as part of the calculations (if the example were calculating the average, say).
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Audio Compression & Limiting - low CPU%
Thank you, Trog, for this clear example!
Regarding forward looping and comparison of eax against variable index range, I know two methods which work in FS 3.0.8.1:
Regarding forward looping and comparison of eax against variable index range, I know two methods which work in FS 3.0.8.1:
- Code: Select all
int N=9;
mov eax,0; sub eax,N[0];
loopStart:
add eax,N[0];
<use eax as index>
add eax,1; sub eax,N[0];
cmp eax,0; jl loopStart;
- Code: Select all
int N=9;
push ebx; mov ebx,N[0];
mov eax,0;
loopStart:
<use eax as index>
add eax,1;
cmp eax,ebx; jl loopStart;
pop ebx;
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Audio Compression & Limiting - low CPU%
trogluddite wrote:Here are templates for assembly loops with either a fixed loop count or the count set by a stream input.
So I tried to do a looping addition with different stream values, I would like to loop and add the inputs in1, in2, in3, but It didnt work, what am I missing here?
- Code: Select all
// Number of loop iterations
streamin LoopCount;
streamin in1;
streamin in2;
streamin in3;
streamout out;
// For count conditioning.
int IntCount = 0;
float F1p0 = 1.0;
float F0 = 0;
float F1 = 1;
float values[4]; //values 3 + 1
// write sources to buffer
mov eax,16; movaps xmm0,in1; movaps values[eax],xmm0;
add eax,16; movaps xmm0,in2; movaps values[eax],xmm0;
add eax,16; movaps xmm0,in3; movaps values[eax],xmm0;
// Ensure count is positive and convert to integer.
movaps xmm0, LoopCount;
maxps xmm0, F1p0;
cvtps2dq xmm0, xmm0;
movaps IntCount, xmm0;
// Initialize loop.
push eax;
movaps xmm1, F0; // Init sum to zero.
mov eax, IntCount[0];
LoopStart:
push eax;
//Code
movaps xmm2,values[eax];
addps xmm1,xmm2;
pop eax;
// Test loop count and iterate.
add eax, -1;
jnz LoopStart;
movaps out, xmm1;
pop eax;
- adamszabo
- Posts: 667
- Joined: Sun Jul 11, 2010 7:21 am
Re: Audio Compression & Limiting - low CPU%
Your values[eax] isn't stepping 16 bytes per index when you de-reference it in the loop, so it's an unaligned read stepping in single bytes. You need shl eax, 4 before the de-reference to align it.
BTW - you just taught me something new. I had no idea that movaps with an [eax] offset was allowed! Thanks!
BTW - you just taught me something new. I had no idea that movaps with an [eax] offset was allowed! Thanks!
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
Re: Audio Compression & Limiting - low CPU%
Awesome it works now thanks! I learned something new and you learned as well
As far as I know movaps uses less cpu then fstp, I hope someone can confirm, thats why I used it instead of that.
As far as I know movaps uses less cpu then fstp, I hope someone can confirm, thats why I used it instead of that.
- adamszabo
- Posts: 667
- Joined: Sun Jul 11, 2010 7:21 am
Re: Audio Compression & Limiting - low CPU%
Yes, I imagine it would be a lot quicker. The main reason for using the FPU instructions is that, very often, the four SSE channels are not looking up the same array index, especially in poly code - so you have to laboriously do everything one channel at a time. But if the SSE channels will always point to the same index, that's a rather wasteful way of doing things.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
Don't stagnate, mutate to create!
-
trogluddite - Posts: 1730
- Joined: Fri Oct 22, 2010 12:46 am
- Location: Yorkshire, UK
37 posts
• Page 4 of 4 • 1, 2, 3, 4
Who is online
Users browsing this forum: Majestic-12 [Bot] and 65 guests