Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: FFT, Overlap, Blocks, ... (Read 5060 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

FFT, Overlap, Blocks, ...

Hello,

I hope that you can help me.
I want to build up an FFT Metering.
My FFT is working. I think I know it because I get a clear signal when I do "audio.in -> FFT -> Meter -> iFFT -> audio.out". But to avoid Leakage I want to work with Hann and 50% overlap.

But I am a little bit confused about the overlap function with static Blocks.
I always have a static size of samples to calculate - let us say 4 (for simplicity) - from the whole audio file.


Am I right to do it like this.

- Get the first Samples "1234".
- Save the Samples "34" for the next calculation
- Do for the Samples "1234" : HannWindowing -> FFT -> Meter -> iFFT
- Save the first 2 calculated Audiosamples "ab"
- Return 0 (Silence)

- Get the next Samples "5678".
- Save "78" for the next caluclation
- Calculate "3456" with HannWindowing -> FFT -> Meter -> iFFT
- Save the first 2 calculated Audiosamples "cd".
- Calculate "5678" with HannWindowing -> FFT -> Meter -> iFFT
- Save the first 2 calculated Audiosamples "ef".
- Return "abcd"

- andsoon...


Thank you.

FFT, Overlap, Blocks, ...

Reply #1
There are a lot of people here with more experience than me with this, but a couple things come to mind (I don't have any reference materials here; I assume you've looked online).

First, the result of the iFFT is going to have the windowing still there, so you can't just use it directly. You could apply the inverse of the windowing but you would get a lot of noise at the ends (where the gain approached infinity). Perhaps you could use only the middle half of the result and apply a partial inverse window.

Another idea would be to add the results back together and overlap them to the same degree that you started with. If you used a triangular window this would all go back together perfectly, but that's obviously not the ideal window. You could derive an inverse window function that could be applied to each entire result that would allow you to add them back together with original overlap. I think that's probably the ideal solution.

Hopefully someone who knows what they are talking about will respond soon... 

FFT, Overlap, Blocks, ...

Reply #2
Quote
There are a lot of people here with more experience than me with this, but a couple things come to mind (I don't have any reference materials here; I assume you've looked online).

First, the result of the iFFT is going to have the windowing still there, so you can't just use it directly. You could apply the inverse of the windowing but you would get a lot of noise at the ends (where the gain approached infinity). Perhaps you could use only the middle half of the result and apply a partial inverse window.

Another idea would be to add the results back together and overlap them to the same degree that you started with. If you used a triangular window this would all go back together perfectly, but that's obviously not the ideal window. You could derive an inverse window function that could be applied to each entire result that would allow you to add them back together with original overlap. I think that's probably the ideal solution.

Hopefully someone who knows what they are talking about will respond soon...  
[a href="index.php?act=findpost&pid=337005"][{POST_SNAPBACK}][/a]


Well if you think briefly you realize that you need to use the window both before and after the FFT and IFFT, and that you need to use some overlap.

Then you realize quickly that the overlap of the window squared with itself at the shift length has to be == 1.

Then you can move onward. There are infinitely many windows that can do this. Using a twiddle-like structure to get the n/2 window coef's (hint, the other half are determined from the first half) assures you get the right values already.
-----
J. D. (jj) Johnston

FFT, Overlap, Blocks, ...

Reply #3
Hello, MichaS !

I would like to know what you mean by "metering". What's the purpose of the iFFT in there ? Are you altering the transform coefficients ? If yes, what are you trying to achieve ? If not, why using the iFFT at all ?

I'm just trying to understand what you're after. It's not clear to me.


Sebi

FFT, Overlap, Blocks, ...

Reply #4
Good morning,

Thank you for getting back.

Quote
I would like to know what you mean by "metering". What's the purpose of the iFFT in there ?


Metering : Perhaps it is a wrong word. After I did FFT I look to the Frequencies.

iFFT : I am doing this because I want to have my signal back and see if the calculation (FFT/iFFT) are correct.

To clarify more, I am doing this.
Get Audiosamples -> do HannWindowing -> put samples in FFT -> look at Frequencies -> do iFFT -> do HannWindowing-back to get Audiosamples back.


Thank you.

FFT, Overlap, Blocks, ...

Reply #5
Quote
To clarify more, I am doing this.
Get Audiosamples -> do HannWindowing -> put samples in FFT -> look at Frequencies -> do iFFT -> do HannWindowing-back to get Audiosamples back.
[a href="index.php?act=findpost&pid=337096"][{POST_SNAPBACK}][/a]


If you just want to test your FFT/iFFT code then just put in some samples, apply the FFT and iFFT and post-scaling and see if the outcome is similar (Theoretically it should be the exact input but since we're usually working with limited accuracy there'll be some rounding errors). No need to apply any window functions and stuff.

Sebi

FFT, Overlap, Blocks, ...

Reply #6
Quote
Quote
To clarify more, I am doing this.
Get Audiosamples -> do HannWindowing -> put samples in FFT -> look at Frequencies -> do iFFT -> do HannWindowing-back to get Audiosamples back.
[a href="index.php?act=findpost&pid=337096"][{POST_SNAPBACK}][/a]


If you just want to test your FFT/iFFT code then just put in some samples, apply the FFT and iFFT and post-scaling and see if the outcome is similar (Theoretically it should be the exact input but since we're usually working with limited accuracy there'll be some rounding errors). No need to apply any window functions and stuff.

Sebi
[a href="index.php?act=findpost&pid=337129"][{POST_SNAPBACK}][/a]


Hello Sebi,

Thanx.
Okay, I should have a look into.
'Cause when I try without a window -> I get a clear sound.
I am doing "Hamming" -> I get a clear sound.

I am doing "Hann", "Blackman" or "Bartlett" -> I get noise
(If I do the technique which I described I won't get noise. Hmmhmm, I really should get a pure sound for all window function on a static size of Blocks? I.e. I get 2048 Samples (do FFT/iFFT), then the next 2048 Samples (do FFT/iFFT), and so on...?)


Thanx.

 

FFT, Overlap, Blocks, ...

Reply #7
You DO know that
some data -> FFT -> some action without alteration -> iFFT -> the same data
right ?

Just think about your signal processing chain and blend out everything bewteen FFT and iFFT (inclusive). Does it make sense ? I don't know (I still don't know what you're trying to achieve). Can you apply any window function if you want the output to be the same as the input ? Of course not ! Do you need the iFFT at all if you want the output to be the same as the inoput ? Of course not !

You COULD use the Vorbis window prior FFT and after the iFFT and do overlap/add. But you could also walk out of the door and scream loudly "I'm stacking FFT and iFFT for no reason". What you SHOULD do depends on your goal.

Sebi