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
time-domain FIR filter (Convolver)
11 posts
• Page 1 of 2 • 1, 2
time-domain FIR filter (Convolver)
REPOSTED FROM SYNTHMAKER FORUM
Very simply a time-domain FIR filter. It circularly loads the coefficients and calculates output as (pseudocode):
However, this can be managed in many different ways in assembly.
The "medium optimized" FIR filter uses following code to load 4packed values from memory:
That requires cvtps2dq (which is packed single precision float to doublequadword integer conversion) which is quite cpu hungry instruction and also the st() registers to call individual values of 4packed data. If you put this in a loop (like the FIR filter requires to calculate it a several hundred times) the polar-bear isn't very happy with you buying quadcore instead of dualcore.
To save CPU you can calculate the indexes as integers (using eax register and add,sub,cmp instructions and conditional jumps) and leave out the conversion. Also in this case the index is always the same for all 4 channels so you don't save CPU by using SSE instructions (actually you waste CPU by using them).
Because index is the same in all 4 channels instead of calling individual values from the memory using st() registers, you can simply use this:
on my computer the filter runs at 1/6 CPU % compared to the medium optimized version. Only it has fixed impulse size of 256. However it can easily be changed within the schematic, possibly even be made variable.
the schematic is .osm ,hope there will not be problems with compatibility.
http://www.mediafire.com/?xdwa7ivycqaywtk
Very simply a time-domain FIR filter. It circularly loads the coefficients and calculates output as (pseudocode):
- Code: Select all
out=0;
for i:=0 to 255 do
out=out+coeficientMemory[i]*inputMemory[i];
However, this can be managed in many different ways in assembly.
The "medium optimized" FIR filter uses following code to load 4packed values from memory:
- Code: Select all
cvtps2dq xmm1,Index;
movaps smIntVarArrayIndex,xmm1;
push eax;
mov eax,smIntVarArrayIndex[0];
shl eax,4;
fld memory[eax];
fstp smIntVarTemp[0];
mov eax,smIntVarArrayIndex[1];
shl eax,4;
add eax,4;
fld memory[eax];
fstp smIntVarTemp[1];
mov eax,smIntVarArrayIndex[2];
shl eax,4;
add eax,8;
fld memory[eax];
fstp smIntVarTemp[2];
mov eax,smIntVarArrayIndex[3];
shl eax,4;
add eax,12;
fld memory[eax];
fstp smIntVarTemp[3];
pop eax;
That requires cvtps2dq (which is packed single precision float to doublequadword integer conversion) which is quite cpu hungry instruction and also the st() registers to call individual values of 4packed data. If you put this in a loop (like the FIR filter requires to calculate it a several hundred times) the polar-bear isn't very happy with you buying quadcore instead of dualcore.
To save CPU you can calculate the indexes as integers (using eax register and add,sub,cmp instructions and conditional jumps) and leave out the conversion. Also in this case the index is always the same for all 4 channels so you don't save CPU by using SSE instructions (actually you waste CPU by using them).
Because index is the same in all 4 channels instead of calling individual values from the memory using st() registers, you can simply use this:
- Code: Select all
mov eax,index[0]; //assuming the index is already integer
shl eax,4;
movaps xmm0,memory[eax]; //loads all four values from memory at that index
on my computer the filter runs at 1/6 CPU % compared to the medium optimized version. Only it has fixed impulse size of 256. However it can easily be changed within the schematic, possibly even be made variable.
the schematic is .osm ,hope there will not be problems with compatibility.
http://www.mediafire.com/?xdwa7ivycqaywtk
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: time-domain FIR filter (Convolver)
Quick question, because recently few schematics produced unexpected adventures. This design can be used without any complications as mono or mono4?
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: time-domain FIR filter (Convolver)
Yes, they should be perfectly usable both in mono and mono4. You can even use different impulses for the 4 channels, however the impulses must be the same size, because the loop is based on conditional jumps.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: time-domain FIR filter (Convolver)
Okay, thanks for info.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: time-domain FIR filter (Convolver)
here... version with non-hard-coded FIR length. It should work for any IR you feed it with (as long as it's not bigger than the size of buffers). However change of length will work only on audio reset (clear audio primitive), because internal variables are calculated at stage(0).
http://www.mediafire.com/?h5fpgr9r7bfcn66
http://www.mediafire.com/?h5fpgr9r7bfcn66
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: time-domain FIR filter (Convolver)
You should search in the forum first, this would save some of your time:
viewtopic.php?f=3&t=1487&p=6393
viewtopic.php?f=3&t=1487&p=6393
-
MyCo - Posts: 718
- Joined: Tue Jul 13, 2010 12:33 pm
- Location: Germany
Re: time-domain FIR filter (Convolver)
MyCo wrote:You should search in the forum first, this would save some of your time:
http://dsprobotics.com/support/viewtopi ... 487&p=6393
I read through that topic some time ago, but I actually do this stuff to kill time... like some people do sudoku, i do programming. It's pretty cool puzzle to try to make stuff like this all alone and create something that is actually usable in the end? I believe that is why many people do this stuff...
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: time-domain FIR filter (Convolver)
@KG_is_back - you are an excellent candidate to help me with this:
viewtopic.php?f=2&t=1714
I'm serious. I do'nt like to mess with external plugins in odrder to add to this - such sort of this. Especially if these external plugins are not very cool to use (plus expensive and not friendly when often moving between machines). Unfortunately there is only one plugin I know, capable of reaching there, where you can hear with headphones. But I suspect - it can be done a lot more, and... better.
viewtopic.php?f=2&t=1714
I'm serious. I do'nt like to mess with external plugins in odrder to add to this - such sort of this. Especially if these external plugins are not very cool to use (plus expensive and not friendly when often moving between machines). Unfortunately there is only one plugin I know, capable of reaching there, where you can hear with headphones. But I suspect - it can be done a lot more, and... better.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: time-domain FIR filter (Convolver)
KG_is_back wrote: like some people do sudoku, i do programming. It's pretty cool puzzle to try to make stuff like this
I'll second that! Though it's surprising how few people understand that when you try and explain it to them!
Nice to see you here KG.
PS) And nice to see you are still with us, MyCo.
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: time-domain FIR filter (Convolver)
trogluddite wrote:I'll second that! Though it's surprising how few people understand that when you try and explain it to them!
I've stopped trying... When you say the word "programmer" regular person automatically imagines a fat guy with thick glasses and no social life (and definitely no girlfriend) sitting on chair in front of a computer 12 hours a day. They somehow cannot understand that programmers play in rock bands, drink every Saturday with friends and actually do programing when their girlfriends aren't looking.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
11 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 48 guests