hi all, today I start learning FFT, and after seeing the (hann) windowing function, I realized this (attached) filter with custom frequency response, but I suspect something is wrong here
why it sucks (given that it does)? also I get a fixed frequency around 60Hz, why?
#N canvas 1432 158 925 726 10; #N canvas 1924 103 553 420 fft 0; #X obj 41 42 inlet~; #X obj 146 39 block~ 512; #X obj 42 131 *~; #X obj 68 100 tabreceive~ $0-hann-window; #X obj 42 179 rfft~; #X obj 42 247 *~; #X obj 92 247 *~; #X obj 115 185 tabreceive~ $0-filter-shape; #X obj 43 297 rifft~; #X obj 44 331 /~ 512; #X obj 45 369 outlet~; #X connect 0 0 2 0; #X connect 2 0 4 0; #X connect 3 0 2 1; #X connect 4 0 5 0; #X connect 4 1 6 0; #X connect 5 0 8 0; #X connect 6 0 8 1; #X connect 7 0 5 1; #X connect 7 0 6 1; #X connect 8 0 9 0; #X connect 9 0 10 0; #X restore 59 220 pd fft; #N canvas 0 0 450 300 (subpatch) 0; #X array $0-hann-window 512 float 3; #A 0 0 3.76403e-05 0.000150591 0.000338823 0.000602275 0.000940949 0.00135478 0.00184369 0.00240764 0.00304651 0.00376022 0.00454867 0.00541174 0.0063493 0.00736117 0.00844726 0.00960737 0.0108413 0.0121489 0.01353 0.0149844 0.0165118 0.018112 0.0197847 0.0215298 0.023347 0.0252359 0.0271963 0.029228 0.0313305 0.0335036 0.035747 0.0380602 0.0404431 0.0428951 0.045416 0.0480053 0.0506628 0.0533879 0.0561802 0.0590394 0.061965 0.0649565 0.0680136 0.0711357 0.0743224 0.0775732 0.0808876 0.0842652 0.0877054 0.0912076 0.0947714 0.0983962 0.102082 0.105827 0.109631 0.113495 0.117416 0.121396 0.125432 0.129524 0.133673 0.137876 0.142135 0.146447 0.150812 0.15523 0.159699 0.164221 0.168792 0.173414 0.178084 0.182803 0.18757 0.192384 0.197244 0.20215 0.207101 0.212096 0.217134 0.222215 0.227338 0.232501 0.237705 0.242949 0.248231 0.253551 0.258908 0.264302 0.269731 0.275194 0.280692 0.286222 0.291785 0.297379 0.303004 0.308658 0.314341 0.320053 0.325791 0.331555 0.337345 0.343159 0.348997 0.354858 0.36074 0.366644 0.372567 0.37851 0.384471 0.390449 0.396444 0.402455 0.40848 0.414519 0.420571 0.426635 0.43271 0.438795 0.444889 0.450991 0.457101 0.463218 0.46934 0.475466 0.481596 0.487729 0.493864 0.5 0.506136 0.512271 0.518404 0.524534 0.53066 0.536782 0.542899 0.549009 0.555111 0.561205 0.56729 0.573365 0.579429 0.585481 0.59152 0.597545 0.603556 0.609551 0.615529 0.62149 0.627433 0.633356 0.63926 0.645142 0.651003 0.656841 0.662655 0.668445 0.674209 0.679947 0.685659 0.691342 0.696996 0.702621 0.708215 0.713778 0.719308 0.724806 0.730269 0.735698 0.741092 0.746449 0.751769 0.757051 0.762295 0.767499 0.772663 0.777785 0.782866 0.787904 0.792899 0.79785 0.802756 0.807616 0.81243 0.817197 0.821916 0.826586 0.831208 0.83578 0.840301 0.84477 0.849188 0.853553 0.857865 0.862124 0.866327 0.870476 0.874568 0.878604 0.882584 0.886505 0.890369 0.894173 0.897918 0.901604 0.905229 0.908792 0.912295 0.915735 0.919112 0.922427 0.925678 0.928864 0.931986 0.935044 0.938035 0.940961 0.94382 0.946612 0.949337 0.951995 0.954584 0.957105 0.959557 0.96194 0.964253 0.966496 0.96867 0.970772 0.972804 0.974764 0.976653 0.97847 0.980215 0.981888 0.983488 0.985016 0.98647 0.987851 0.989159 0.990393 0.991553 0.992639 0.993651 0.994588 0.995451 0.99624 0.996953 0.997592 0.998156 0.998645 0.999059 0.999398 0.999661 0.999849 0.999962 1 0.999962 0.999849 0.999661 0.999398 0.999059 0.998645 0.998156 0.997592 0.996953 0.99624 0.995451 0.994588 0.993651 0.992639 0.991553 0.990393 0.989159 0.987851 0.98647 0.985016 0.983488 0.981888 0.980215 0.97847 0.976653 0.974764 0.972804 0.970772 0.968669 0.966496 0.964253 0.96194 0.959557 0.957105 0.954584 0.951995 0.949337 0.946612 0.94382 0.940961 0.938035 0.935043 0.931986 0.928864 0.925678 0.922427 0.919112 0.915735 0.912295 0.908792 0.905229 0.901604 0.897918 0.894173 0.890369 0.886505 0.882584 0.878604 0.874568 0.870476 0.866327 0.862123 0.857865 0.853553 0.849188 0.84477 0.840301 0.835779 0.831208 0.826586 0.821916 0.817197 0.81243 0.807616 0.802755 0.79785 0.792899 0.787904 0.782866 0.777785 0.772662 0.767499 0.762295 0.757051 0.751769 0.746449 0.741092 0.735698 0.730269 0.724806 0.719308 0.713777 0.708215 0.702621 0.696996 0.691342 0.685659 0.679948 0.674209 0.668445 0.662655 0.656841 0.651003 0.645142 0.63926 0.633356 0.627433 0.62149 0.615529 0.60955 0.603556 0.597545 0.59152 0.585481 0.579429 0.573365 0.56729 0.561205 0.555111 0.549008 0.542899 0.536782 0.53066 0.524534 0.518404 0.512271 0.506136 0.5 0.493864 0.487729 0.481596 0.475466 0.46934 0.463218 0.457101 0.450991 0.444889 0.438794 0.43271 0.426635 0.420571 0.414519 0.40848 0.402455 0.396444 0.390449 0.384471 0.37851 0.372567 0.366643 0.36074 0.354858 0.348997 0.343159 0.337345 0.331555 0.325791 0.320052 0.314341 0.308658 0.303004 0.297379 0.291785 0.286222 0.280692 0.275194 0.269731 0.264302 0.258908 0.253551 0.248231 0.242949 0.237705 0.232501 0.227337 0.222215 0.217134 0.212096 0.207101 0.20215 0.197244 0.192384 0.18757 0.182803 0.178084 0.173414 0.168792 0.16422 0.159699 0.15523 0.150812 0.146446 0.142134 0.137876 0.133673 0.129524 0.125432 0.121396 0.117416 0.113495 0.109631 0.105827 0.102081 0.0983962 0.0947713 0.0912075 0.0877053 0.0842652 0.0808876 0.0775732 0.0743224 0.0711357 0.0680135 0.0649565 0.0619649 0.0590393 0.0561801 0.0533878 0.0506627 0.0480053 0.0454159 0.0428951 0.0404431 0.0380602 0.035747 0.0335036 0.0313305 0.0292279 0.0271963 0.0252359 0.0233469 0.0215298 0.0197847 0.0181119 0.0165117 0.0149844 0.01353 0.0121489 0.0108413 0.00960734 0.00844723 0.00736117 0.00634927 0.00541171 0.00454867 0.00376022 0.00304648 0.00240761 0.00184369 0.00135478 0.000940949 0.000602275 0.000338793 0.000150591 3.76403e-05; #X coords 0 1 511 0 200 140 1; #X restore 234 37 graph; #N canvas 0 0 450 300 (subpatch) 0; #X array $0-filter-shape 512 float 3; #A 0 0.960496 0.960496 0.960496 0.960496 0.960496 0.960496 0.960496 0.956924 0.924781 0.924781 0.924781 0.881923 0.878351 0.839065 0.836684 0.834302 0.78192 0.78192 0.753348 0.750967 0.748586 0.717633 0.714062 0.667632 0.667632 0.667632 0.653346 0.653346 0.653346 0.631917 0.631917 0.617631 0.61525 0.612869 0.596202 0.596202 0.589059 0.586678 0.584297 0.574773 0.574773 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.56763 0.574773 0.574773 0.581916 0.581916 0.581916 0.596202 0.624774 0.63906 0.660489 0.660489 0.660489 0.708109 0.712871 0.717633 0.749777 0.753348 0.803349 0.803349 0.803349 0.811921 0.820493 0.829064 0.837636 0.846207 0.860494 0.867637 0.884304 0.886685 0.889066 0.889066 0.889066 0.89859 0.900971 0.903352 0.907637 0.911923 0.916209 0.920495 0.924781 0.931924 0.931924 0.931924 0.935495 0.939067 0.941448 0.943829 0.94621 0.946924 0.947638 0.948353 0.949067 0.949781 0.950496 0.95121 0.951924 0.952639 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.953353 0.94621 0.94621 0.94621 0.94621 0.94621 0.939067 0.939067 0.939067 0.935495 0.931924 0.930138 0.928352 0.926566 0.924781 0.922995 0.921209 0.919423 0.917638 0.915852 0.914066 0.91228 0.910495 0.908709 0.906923 0.905137 0.903352 0.901923 0.900494 0.899066 0.897637 0.896209 0.896209 0.896209 0.893351 0.890494 0.887637 0.88478 0.881923 0.872399 0.870018 0.867637 0.860494 0.860494 0.850969 0.848588 0.846207 0.827159 0.822397 0.817635 0.803349 0.796206 0.405721 0.400959 0.396197 0.37834 0.374768 0.374768 0.374768 0.374768 0.371197 0.367625 0.367625 0.367625 0.367625 0.367625 0.367625 0.365839 0.364054 0.362268 0.360482 0.358696 0.356911 0.355125 0.353339 0.352149 0.350958 0.349768 0.348577 0.347387 0.346196 0.345005 0.343815 0.342624 0.341434 0.340243 0.339053 0.337862 0.336672 0.335481 0.334291 0.3331 0.33191 0.330719 0.329529 0.328338 0.327148 0.325957 0.324767 0.323576 0.322386 0.321195 0.320005 0.318814 0.317624 0.316433 0.315243 0.314052 0.312862 0.311671 0.310481 0.310481 0.310481 0.310481 0.310481 0.310481 0.307624 0.304767 0.301909 0.299052 0.296195 0.293338 0.29048 0.287623 0.284766 0.281909 0.280718 0.279528 0.278337 0.277147 0.275956 0.274766 0.273575 0.272385 0.271194 0.270004 0.268813 0.267623 0.266432 0.265242 0.264051 0.262861 0.26167 0.26048 0.26048 0.26048 0.26048 0.26048 0.26048 0.260004 0.259527 0.259051 0.258575 0.258099 0.257623 0.257146 0.25667 0.256194 0.255718 0.255241 0.254765 0.254289 0.253813 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.253337 0.255242 0.257146 0.259051 0.260956 0.262861 0.264766 0.26667 0.268575 0.27048 0.272385 0.27429 0.276195 0.278099 0.280004 0.281909 0.282802 0.283695 0.284588 0.28548 0.286373 0.287266 0.288159 0.289052 0.289052 0.289052 0.290072 0.291093 0.292113 0.293134 0.294154 0.295174 0.296195 0.297215 0.298236 0.299256 0.300277 0.301297 0.302318 0.303338 0.304358 0.305379 0.306399 0.30742 0.30844 0.309461 0.310481 0.310481 0.310481 0.317624 0.317624 0.317624 0.317624 0.317624 0.317624 0.317624 0.317624 0.319608 0.321592 0.323577 0.325561 0.327545 0.329529 0.331513 0.333497 0.335482 0.337466 0.33945 0.341434 0.343418 0.345402 0.347387 0.349371 0.351355 0.353339 0.356911 0.360482 0.363161 0.365839 0.368518 0.371197 0.373875 0.376554 0.379233 0.381911 0.386673 0.391435 0.396197 0.399769 0.40334 0.405721 0.408102 0.410483 0.411912 0.41334 0.414769 0.416198 0.417626 0.431912 0.439055 0.441436 0.443817 0.446198 0.45096 0.455722 0.460484 0.464056 0.467627 0.472628 0.477628 0.482628 0.487628 0.492628 0.497628 0.502628 0.507628 0.512628 0.517629 0.517629 0.517629 0.517629 0.521914 0.5262 0.530486 0.534772 0.539058 0.547629 0.556201 0.564772 0.573344 0.581916 0.584773 0.58763 0.590487 0.593345 0.596202 0.599059 0.601916 0.604773 0.607631 0.610488 0.613345 0.616202 0.619059 0.621917 0.624774 0.628345 0.631917 0.635488 0.63906 0.642631 0.646203 0.649774 0.653346 0.656917 0.660489 0.66406 0.667632 0.671203 0.674775 0.678347 0.681918 0.68549 0.689061 0.693823 0.698585 0.703347 0.717633 0.731919; #X coords 0 1 511 0 200 140 1; #X restore 234 207 graph; #X obj 62 176 phasor~; #X floatatom 70 66 5 0 0 0 - - -; #X obj 56 301 dac~; #N canvas 656 272 450 375 make-hann-window 1; #X obj 54 261 tabwrite $0-hann-window; #X obj 51 167 t f f; #X obj 50 141 f; #X obj 85 141 + 1; #X obj 49 113 until; #X msg 51 14 512; #X obj 51 39 t f f b; #X msg 93 65 0; #X obj 56 191 /; #X obj 55 212 expr 0.5*(1-cos($f1*atan(1)*8)); #X connect 1 0 8 0; #X connect 1 1 0 1; #X connect 2 0 3 0; #X connect 2 0 1 0; #X connect 3 0 2 1; #X connect 4 0 2 0; #X connect 5 0 6 0; #X connect 6 0 4 0; #X connect 6 1 8 1; #X connect 6 2 7 0; #X connect 7 0 2 1; #X connect 8 0 9 0; #X connect 9 0 0 0; #X restore 33 404 pd make-hann-window; #X obj 70 90 mtof; #X msg 71 112 $1 100; #X obj 69 138 line~; #X obj 60 265 *~ 0; #X obj 120 203 vsl 15 128 0.01 1 1 0 empty empty empty 0 -9 0 10 -262144 -1 -1 0 1; #X connect 0 0 10 0; #X connect 3 0 0 0; #X connect 4 0 7 0; #X connect 7 0 8 0; #X connect 8 0 9 0; #X connect 9 0 3 0; #X connect 10 0 5 0; #X connect 10 0 5 1; #X connect 11 0 10 1;
hi all, today I start learning FFT, and after seeing the (hann) windowing function, I realized this (attached) filter with custom frequency response, but I suspect something is wrong here
why it sucks (given that it does)? also I get a fixed frequency around 60Hz, why?
[phasor~] takes a range of 0 to 1. To fully drive your speakers, you may want to insert a [-~ 0.5] after [phasor~] so that you get a range of -0.5 to 0.5, centered at zero. You can then multiply the amplitude by 2 (instead of 1 which you currently have your slider range set to)
This should also removed the 60Hz tone you were hearing.
Actually, the tone you were hearing was probably 86Hz if you are processing audio at a sample rate of 44,100Hz.
By multiplying the source with a hanning window, you are actually applying a kind of an amplitude modulation. Artifacts caused by this procedure may become a little more apparent when you use live sounds for input.
-- David Shimamoto
PSPunch wrote:
[phasor~] takes a range of 0 to 1. To fully drive your speakers, you may want to insert a [-~ 0.5] after [phasor~] so that you get a range of -0.5 to 0.5, centered at zero. You can then multiply the amplitude by 2 (instead of 1 which you currently have your slider range set to)
oh, right! after some time not playing with pd I forgot about this and thought a phasor as a nornmal oscillator (in the range -1...1)
By multiplying the source with a hanning window, you are actually applying a kind of an amplitude modulation. Artifacts caused by this procedure may become a little more apparent when you use live sounds for input.
uhm... actually, *not* using the hanning window, makes the processed sound suck even more. so what's the best solution?
there is a better window function? perhaps the gaussian function? isn't the window function also related on how much samples overlap between a block and the next one? shouldn't fft~ be aware of this?
ciao
if you use overlapped blocks, it makes the hanning window less intrusive.
so instead of [block~ 512], use [block~ 512 2 1] or even [block~ 512 4 1]
uhm... actually, *not* using the hanning window, makes the processed sound suck even more. so what's the best solution?
there is a better window function? perhaps the gaussian function? isn't the window function also related on how much samples overlap between a block and the next one? shouldn't fft~ be aware of this?
Why you want to apply a window function, and the pros & cons of each window is well described in this document introduced in one of the previous posts on this list. http://www.dspguide.com/
By multiplying each block with a window function, you are applying sort of an amplitude modulation which causes audible rumbles.
The easiest way to avoid this that I know of is to "clone" your entire FFT routine (call them 'original' and 'clone' for now), apply a delay before the original signal and the same delay time after iFFT on cloned signal. The delay time should be half the size of the window size (=block size). What you are doing here is preparing an identical signal to compensate for the gaps of amplitude caused by applying a window function to the original signal.
This will introduce a slightly longer delay in the overall sound, but I found its quality acceptable for certain applications.
I've attached a modified version of your original post.
There may be better ways of looking at all this which I am up to learning as well.
-- David Shimamoto
Hallo, PSPunch hat gesagt: // PSPunch wrote:
The easiest way to avoid this that I know of is to "clone" your entire FFT routine (call them 'original' and 'clone' for now), apply a delay before the original signal and the same delay time after iFFT on cloned signal. The delay time should be half the size of the window size (=block size). What you are doing here is preparing an identical signal to compensate for the gaps of amplitude caused by applying a window function to the original signal.
[block~ SIZE 2] does practically the same: See attached comparison and my other reply in this thread.
Frank Barknecht _ ______footils.org__
Hallo, mescalinum@gmail.com hat gesagt: // mescalinum@gmail.com wrote:
today I start learning FFT, and after seeing the (hann) windowing function, I realized this (attached) filter with custom frequency response, but I suspect something is wrong here
why it sucks (given that it does)?
First as others wrote you should use block overlaps.
The delay strategy, David (pspunch) suggested isn't necessary with overlap using [block~ 512 4] as the block~ object does an internal delay automatically (four times in this case)
Then it's important for windowing that you also *window the outgoing signal* after the inverse FFT, otherwise you get these bad artifacts.
Check the I03.resynthesis.pd example in the docs for a complete example, the corresponding chapter in Miller's book and maybe my "FFT for dummies" guide here: http://footils.org/cms/show/60 (though this doesn't explain overlap)
Frank Barknecht _ ______footils.org__
Frank,
I wasn't quite sure till now what the overlap argument was for. Thanks for clarifying it.
-- David Shimamoto
Hallo, mescalinum@gmail.com hat gesagt: // mescalinum@gmail.com wrote:
today I start learning FFT, and after seeing the (hann) windowing function, I realized this (attached) filter with custom frequency response, but I suspect something is wrong here
why it sucks (given that it does)?
First as others wrote you should use block overlaps.
The delay strategy, David (pspunch) suggested isn't necessary with overlap using [block~ 512 4] as the block~ object does an internal delay automatically (four times in this case)
Then it's important for windowing that you also *window the outgoing signal* after the inverse FFT, otherwise you get these bad artifacts.
Check the I03.resynthesis.pd example in the docs for a complete example, the corresponding chapter in Miller's book and maybe my "FFT for dummies" guide here: http://footils.org/cms/show/60 (though this doesn't explain overlap)
Ciao