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
Oversampling Toolkit (Revisited)
28 posts
• Page 1 of 3 • 1, 2, 3
Oversampling Toolkit (Revisited)
Hi,
I had a go at the "Oversampling Toolkit" from the SynthMaker forum. I completely rebuilt it from scratch. Instead of using dozens of Biquad-Allpasses, I converted them to higher order Allpasses and optimized the code from there. It didn't get any easier to read, though.
For the Polyphase IIR up/downsamping (That is order: 10, hard slope in my version), I get about 1/3 less CPU time. It's still a bit on the high side, but can't see any chance to get it even lower.
I've also include other order versions with hard/soft slopes that use even less and might be better sometimes.
For test purpose I've also included a decimator effect with x2/x4 oversampling.
Have fun!
Updated version, with Martins and TheOm's suggested optimizations
I had a go at the "Oversampling Toolkit" from the SynthMaker forum. I completely rebuilt it from scratch. Instead of using dozens of Biquad-Allpasses, I converted them to higher order Allpasses and optimized the code from there. It didn't get any easier to read, though.
For the Polyphase IIR up/downsamping (That is order: 10, hard slope in my version), I get about 1/3 less CPU time. It's still a bit on the high side, but can't see any chance to get it even lower.
I've also include other order versions with hard/soft slopes that use even less and might be better sometimes.
For test purpose I've also included a decimator effect with x2/x4 oversampling.
Have fun!
Updated version, with Martins and TheOm's suggested optimizations
Last edited by MyCo on Fri Apr 17, 2015 2:59 am, edited 2 times in total.
-
MyCo - Posts: 718
- Joined: Tue Jul 13, 2010 12:33 pm
- Location: Germany
Re: Oversampling Toolkit (Revisited)
Did you also tested their magnitude response and SNR? High order IIR filters generally suffer from much more significant rounding errors and sometimes even go unstable because of that. It might just be that you traded speed for precision.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Oversampling Toolkit (Revisited)
I've tested the halfband filters separately with white noise and FFT, the response looks right, although I couldn't zoom in. I tried to merge the two parallel halfpass filters into a giant lowpass, but this works only for Orders less then 10. At Order 10 you'll get resonance effect due to rounding errors. As the code was also a lot slower I canceled that approach.
-
MyCo - Posts: 718
- Joined: Tue Jul 13, 2010 12:33 pm
- Location: Germany
Re: Oversampling Toolkit (Revisited)
Thanks, MyCo, that looks like a lot of fruitful work. What exactly are hard/soft slopes?MyCo wrote:I've also include other order versions with hard/soft slopes that use even less and might be better sometimes.
On my machine it's even 50% less. You could exploit SSE to squeeze out still more (unless you really need to process all 4 channels in parallel). For example reusing the halfband filters for both interpolation and decimation cuts it by another 50% while you still have stereo capacity.MyCo wrote:[...] I get about 1/3 less CPU time. It's still a bit on the high side, but can't see any chance to get it even lower.
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Oversampling Toolkit (Revisited)
martinvicanek wrote:What exactly are hard/soft slopes?
Hard Slope drops extremely fast at the half band frequency. Soft Slope roles off smoothly a little bit earlier. The soft slope versions in most cases also attenuate more in the stop band.
martinvicanek wrote:On my machine it's even 50% less.
You can only compare "O10 hard" or "Linear", all other versions didn't exist in the original kit. My selector always chooses the "O10 hard" of the original kit as fallback for the non-existent.
martinvicanek wrote:You could exploit SSE to squeeze out still more (unless you really need to process all 4 channels in parallel)
I didn't want to go that way, because I thought about using it for oscillators in a poly section. And in the mono section I would use it stereo anyway. But an optimized stereo version would make sense, I guess.
martinvicanek wrote:For example reusing the halfband filters for both interpolation and decimation cuts it by another 50% while you still have stereo capacity.
Not sure what you mean with "reusing", but any hint to better performance is appreciated because I'll definetely use the decimator effect in the future, it makes nice dirty sounds
BTW: The original kit has "power series" up/downsampling code. I tried that, but it doesn't look right to me. The second channel doesn't get the right amplitude. But I've no clue, where this comes from, so I couldn't fix it. My thought is that it's supposed to be something like quadric/cubic interpolation, no idea...
-
MyCo - Posts: 718
- Joined: Tue Jul 13, 2010 12:33 pm
- Location: Germany
Re: Oversampling Toolkit (Revisited)
Cool stuff! Can you also use this on oscillator sync to remove aliasing occurring from that?
@martinvicanek: can you whip up a small demo of the mono version to show what you mean?
@martinvicanek: can you whip up a small demo of the mono version to show what you mean?
- adamszabo
- Posts: 667
- Joined: Sun Jul 11, 2010 7:21 am
Re: Oversampling Toolkit (Revisited)
adamszabo wrote:Cool stuff! Can you also use this on oscillator sync to remove aliasing occurring from that?
yeah, but it would make your CPU explode. You need as much oscillators as you oversample, so for 4x upsampling you would need 4 identical oscillators running phase shifted in parallel. You wouldn't get rid of aliasing entirely but it would sound better. Maybe you would loose some higher frequencies too...
-
MyCo - Posts: 718
- Joined: Tue Jul 13, 2010 12:33 pm
- Location: Germany
Re: Oversampling Toolkit (Revisited)
Just an example for generating oversampled naive saw.
- Attachments
-
- oversampled saw test (MyCo).fsm
- (122.37 KiB) Downloaded 1528 times
-
MyCo - Posts: 718
- Joined: Tue Jul 13, 2010 12:33 pm
- Location: Germany
Re: Oversampling Toolkit (Revisited)
MyCo wrote:martinvicanek wrote:For example reusing the halfband filters for both interpolation and decimation cuts it by another 50% while you still have stereo capacity.
Not sure what you mean with "reusing", but any hint to better performance is appreciated
Note that the upsampling filter is the same as (edit: <del>one branch of</del>) the downsampling filter, so I thought it would be straightforward to use it in channelized mode. At second thoght, however, I dropped the idea because it is better to keep the two modules separate. (you might not always want to use them both).
MyCo wrote:An optimized stereo version would make sense, I guess.
Yes, a stereo version of both modules can be obtained by processing even and odd samples simultaneously in parallel SSE channels. I have done this for the second order modules. The efficiency gain is not quite a factor 2, but it is there. Might be more for the higher orders.
adamszabo wrote:@martinvicanek: can you whip up a small demo of the mono version to show what you mean?@martinvicanek: can you whip up a small demo of the mono version to show what you mean?
I also did a mono version of the decimator by channelizing filters 1 and 2 for even and odd samples, respectively. It is a bit tricky, but it works if you can split the filters in two similar chunks (like a section of 2n biquads, for example).
Time to hit the sack.
- Attachments
-
- Oversampling Kit 4 (MyCo, MV).fsm
- (123.53 KiB) Downloaded 1695 times
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Oversampling Toolkit (Revisited)
@MyCo, there may be more potential for optimization. Observe that the a and b coefficients are equal but in reverse order (as it must be for allpass fiters): a_0 = b_n, a_1 = b_n-1, etc. This is true for both the upsampling and the downsampling filters (the latter have a normalization factor 0.5 which can be applied at the input or output). So instead of calculating
out = b_0*in + b_1*in_1 + ... + b_n*in_n
out = out - a_1*out_1 - ... - a_n*out_n
you could simplify as
out = b_0*(in - out_n) + b1*(in_1 - out_n-1) + ... + b_n-1*(in_n-1 - out_1) + in_n
which reduces the number of multiplications and coefficient loads by 50%. Applying this scheme, I have been able to squeeze out a cycle or two for the 2nd orde filters, but would leave it up to you if you think it worthwhile to try for the higher orders. (You are better at optimizing tha I am. )
out = b_0*in + b_1*in_1 + ... + b_n*in_n
out = out - a_1*out_1 - ... - a_n*out_n
you could simplify as
out = b_0*(in - out_n) + b1*(in_1 - out_n-1) + ... + b_n-1*(in_n-1 - out_1) + in_n
which reduces the number of multiplications and coefficient loads by 50%. Applying this scheme, I have been able to squeeze out a cycle or two for the 2nd orde filters, but would leave it up to you if you think it worthwhile to try for the higher orders. (You are better at optimizing tha I am. )
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
28 posts
• Page 1 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 41 guests