Hi all,
I am trying to implement an IEC 1260 compliant third octave band filter with a mid frequency of 125Hz. This is only possible via downsampling. Therefore I made a subpatch with [switch~ 64 1 0.5] which works most of the time, see attached patch (requires iemlib for lp filters).
Sometimes however, I get strong high frequency disturbances. I suspect a bug in switch, but maybe I am missing something?
Thanks for any help, Matthias
#N canvas 532 151 539 446 10; #X obj 134 228 div 2; #X obj 178 228 mod 2; #X obj 104 308 pow 0; #X msg 104 285 10; #X obj 74 257 delay 10; #X floatatom 104 342 5 0 0 0 - - -; #X obj 178 256 select 0 1; #X msg 178 285 1; #X msg 210 285 3; #X obj 139 372 * 1; #X floatatom 139 399 5 0 0 0 - - -; #X floatatom 156 198 5 0 0 0 - - -; #X msg 119 122 1; #X msg 192 122 1; #X obj 119 147 + 1; #X obj 192 147 - 1; #X obj 192 172 * -1; #X msg 156 122 0; #X connect 0 0 2 1; #X connect 0 0 4 0; #X connect 1 0 6 0; #X connect 2 0 5 0; #X connect 3 0 2 0; #X connect 4 0 3 0; #X connect 5 0 9 0; #X connect 6 0 7 0; #X connect 6 1 8 0; #X connect 7 0 9 1; #X connect 8 0 9 1; #X connect 9 0 10 0; #X connect 11 0 14 1; #X connect 11 0 15 1; #X connect 11 0 0 0; #X connect 11 0 1 0; #X connect 12 0 14 0; #X connect 13 0 15 0; #X connect 14 0 11 0; #X connect 15 0 16 0; #X connect 16 0 11 0; #X connect 17 0 11 0;
oh sorry, got the wrong patch attached to the original question. So here it goes...
--Matthias
#N canvas 190 294 450 300 10; #X obj 111 24 noise~; #X obj 111 56 lp6_butt~ 1000; #N canvas 502 326 681 534 thirdoctfilt_125_22050Hz 0; #X obj 440 149 switch~ 64 1 0.5; #X text 2 374 ------------------------------------------------------------ ; #X text 422 374 -------------------------; #X obj 156 403 outlet~; #X obj 156 295 *~ 2; #X obj 156 150 biquad~ 1.99091 -0.992174 1 0 -1; #X obj 156 186 biquad~ 1.99418 -0.995714 1 0 -1; #X obj 156 226 biquad~ 1.99536 -0.996406 1 0 -1; #X obj 156 270 /~ 1.6502e+07; #X text 2 114 ------------------------------------------------------------ ; #X text 422 114 -------------------------; #X obj 155 88 inlet~; #X obj 440 84 inlet; #X connect 4 0 3 0; #X connect 5 0 6 0; #X connect 6 0 7 0; #X connect 7 0 8 0; #X connect 8 0 4 0; #X connect 11 0 5 0; #X connect 12 0 0 0; #X restore 111 94 pd thirdoctfilt_125_22050Hz; #X obj 111 136 lp6_butt~ 1000; #X obj 111 184 dac~; #X obj 295 60 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 ; #X connect 0 0 1 0; #X connect 1 0 2 0; #X connect 2 0 3 0; #X connect 3 0 4 0; #X connect 3 0 4 1; #X connect 5 0 2 1;
Matthias Blau wrote:
Hi all,
Therefore I made a subpatch with [switch~ 64 1 0.5] which works most of
...
Sometimes however, I get strong high frequency disturbances. I suspect a bug in switch, but maybe I am missing something?
you might have problems with aliasing. the up/downsampling does very little (to no) pre-filtering. upsampling: depending on the argument the iolet~s will do linear interpolation between 2 original samples at the best(!!!); this is not very good; the default is zero-padding which is really awful (but is there by intent, as you will very soon notice, that "something" is going on) downsampling: if i remember correctly, it just takes every nth sample (even if you specify "linear" there is no smoothing or whatever)
so make sure that you filter your signal before/after down/upsampling.
mfg.asd.r IOhannes
In my opinion, the whole thing looks like switch~ sometimes does the switching in the upsampled (parent patch) domain although it sits in the subpatch, thereby generating high-frequency components at the interface between parent (upsampled) patch and subpatch. In any case, if switch~ is used without downsampling, and the downsampling is then done in yet another subpatch using block~, then all problems disappear. Thus, it appears that one should not use switch~ together with downsampling. --Matthias
IOhannes m zmoelnig schrieb:
Matthias Blau wrote:
Hi all,
Therefore I made a subpatch with [switch~ 64 1 0.5] which works most of
...
Sometimes however, I get strong high frequency disturbances. I suspect a bug in switch, but maybe I am missing something?
you might have problems with aliasing. the up/downsampling does very little (to no) pre-filtering. upsampling: depending on the argument the iolet~s will do linear interpolation between 2 original samples at the best(!!!); this is not very good; the default is zero-padding which is really awful (but is there by intent, as you will very soon notice, that "something" is going on) downsampling: if i remember correctly, it just takes every nth sample (even if you specify "linear" there is no smoothing or whatever)
so make sure that you filter your signal before/after down/upsampling.
mfg.asd.r IOhannes
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://iem.at/cgi-bin/mailman/listinfo/pd-list