|
|||
I'm not sure if I'm doing the polyphase oversampling right..
I use the polyphase filters from the musicdsp.org archive.. here is the code for 4x oversampling as it is atm: inline void process4x(double& sample) { a = halfband[0]->process( sample ); a = halfband[2]->process( a ); a = effect.process ( a * 4.0); a = halfband[3]->process ( a ); a = halfband[2]->process ( null ); a = effect.process ( a * 4.0); a = halfband[3]->process ( a ); a = halfband[1]->process( a ); sample = a; //Decimate a = halfband[0]->process( null ); a = halfband[2]->process( a ); a = effect.process ( a * 4.0); a = halfband[3]->process ( a ); a = halfband[2]->process ( null ); a = effect.process ( a * 4.0); a = halfband[3]->process ( a ); a = halfband[1]->process( a ); } The 4.0 multiplier is for normalizing the gain for the effects input.. Is this a correct way to do it? |
|||
| ^ | Joined: 07 Feb 2010 Member: #225447 | ||
|
|||
To upsample 2x you zero stuff the source sample, place a zero after every sample (so it's twice as long and every other sample is zero) and feed that through a half band filter.
To downsample by 1/2 you filter by the half band filter and throw away every other sample. So to upsample 2x you alternately feed the half band filter a sample, then a zero, a sample, a zero, and so on... To up sample 4x you do that twice. You zero stuff the sample, filter it, then you zero stuff it again, and filter it again. eg... a = halfband1(input); b = halfband1(0); output0 = halfband2(a); output1 = halfband2(0); output2 = halfband2(b); output3 = halfband2(0); (4 output samples from 1 input) To down sample 4 times you half band filter it, throw away every other sample, half band filter it again, and throw away every other sample again. eg... a = halfband1(input0); halfband1(input1); b = halfband1(input2); halfband1(input3); output = halfband2(a); halfband2(b); (1 output from 4 input samples) HTH. |
|||
| ^ | Joined: 09 Dec 2003 Member: #10919 | ||
|
|||
I have an idea i might try in the next few days that involves oversampling.
It's an offline process so performance doesn't matter much. I was thinking of using a much higher quality interpolator when upsampling to avoid the filtering. Is this false DSP? Am i just fooling myself ? Intuitively it feels right but there's a nagging voice in the back of my head that tells me:"That's not how it's done". ---- At school they taught me how to be. So pure in thought and word and deed. They didn't quite succeed. |
|||
| ^ | Joined: 17 Sep 2002 Member: #3863 Location: Gothenburg Sweden | ||
|
|||
nollock:
Thanks, I think I understand it now... (Does that hold for a recursive filter? Since I've heard of routines for memorlyless filters and recursive ones... ) So, if I understand this correct, this is for a recursive filter: //effect.setSamplerate(4.0 * samplerate); a = halfband1(input); b = halfband1(0); output0 = halfband2(a); output1 = halfband2(0); output2 = halfband2(b); output3 = halfband2(0); output0 = effect.process(output0); output1 = effect.process(output1); output2 = effect.process(output2); output4 = effect.process(output3); a = halfband1(output0); halfband1(output1); b = halfband1(output2); halfband1(output3); output = halfband2(a); halfband2(b); Have I understood it? And should I upsample and downsample with the same halfband filter? I don't know where I got the idea that I had to use one halfband filter for each time I upsampled by 2.. and one filter for each decimation.. |
|||
| ^ | Joined: 07 Feb 2010 Member: #225447 | ||
|
|||
jupiter8 wrote: I have an idea i might try in the next few days that involves oversampling.
It's an offline process so performance doesn't matter much. I was thinking of using a much higher quality interpolator when upsampling to avoid the filtering. Is this false DSP? Am i just fooling myself ? Intuitively it feels right but there's a nagging voice in the back of my head that tells me:"That's not how it's done". It's the same thing. An interpolator is a lowpass filter. If for example you take a hermite interpolator. you can rearange the equation so it's in the form... y = f1(x)*in[-1] + f2(x)*in[0] + f3(x)*in[1] + f4(x)*in[2] Where x is subsample position and each of those f(x) parts is just a polynomial in x. So when you specify 'x' in the equation each of the f(x) parts becomes a constant, and you have a plane old FIR. So if you're upsampling 4x then X is only ever [0, 0.25, 0.5, 0.75], so you have a set of 4 FIRS. Which is just a polyphase FIR. Basicaly a polynomial interpolator and FIR are the same thing. The polynomial interpolator is just stored in a continuous form and allows random access. Last edited by nollock on Wed Jun 30, 2010 3:00 pm; edited 2 times in total |
|||
| ^ | Joined: 09 Dec 2003 Member: #10919 | ||
|
|||
//effect.setSamplerate(4.0 * samplerate); a = halfband1(input); b = halfband1(0); output0 = halfband2(a); output1 = halfband2(0); output2 = halfband2(b); output3 = halfband2(0); output0 = effect.process(output0); output1 = effect.process(output1); output2 = effect.process(output2); output4 = effect.process(output3); a = halfband3(output0); halfband3(output1); b = halfband3(output2); halfband3(output3); output = halfband4(a); halfband4(b); You need to use seeperate filters for each step either up or down. Otherwise you should be good to go. |
|||
| ^ | Joined: 09 Dec 2003 Member: #10919 | ||
|
|||
Thank you nollock, you have been very helpful! |
|||
| ^ | Joined: 07 Feb 2010 Member: #225447 |
| KVR Forum Index » DSP and Plug-in Development | All times are GMT - 8 Hours |
|
Printable version |
Disclaimer: All communications made available as part of this forum and any opinions, advice, statements, views or other information expressed in this forum are solely provided by, and the responsibility of, the person posting such communication and not of kvraudio.com (unless kvraudio.com is specifically identified as the author of the communication).
Powered by phpBB © phpBB Group





