addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscontroller-playcrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1light-bulblinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Hoodlums Message Board › Understanding the Fourier transform

Understanding the Fourier transform

A former member
Post #: 1
Given the discussion at last week's meet up I thought some might find the following rough explanation of the DFT interesting.


Peter M.
Group Organizer
London, GB
Post #: 38
Thanks Tom, I found that very helpful.

The post mentions having to flatten out the wave at the ends so that it loops. Is that something we are going to need to do?
A former member
Post #: 2
Hi Peter,

The way that you flatten the wave at the ends is by applying a windowing function.

We are actually doing that already in a way, because as we consume the incoming audio stream, we'll pass lists of a fixed size into the DFT function - in our example https://gist.github.c...­ this is the [Complex Double] samples. This is equivalent to the rectangular window function, which is defined as being 1 for samples inside the window, and 0 for samples outside.

The problem with the rectangular window is that it will introduce artifacts into our spectrum, because it's likely that a cycle of a wave will be cut off mid way, unless the size of our window is a multiple of the frequency of our signal. In our test code, we are just generating the window and the samples at the same time, so we don't get this problem.

So, in answer to your question:

We could get a rectangular window from our stream of audio very easily, by just doing

take windowSize inputSamples

But to get a more accurate spectrum, we'd have to take the samples as above, and then flatten the start and ends, as that great blog post mentions. I think it's also necessary to have some overlap between the windows. There are tons of different functions for doing this (see links at end)

I don't know whether it will actually be necessary to do this, given that we only need a rough spectrum for visualization, but it shouldn't be too difficult to implement if we do.


Powered by mvnForum

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy