question about ifft for a beginner

Jul 6, 2012 at 1:09am

question about ifft for a beginner

i can generate spectrums that have a similar fft to .wavs that i want to broadly emulate [noisy kind of audio] but when i invert them to play they seem to always end up as a couple of loud clicks at start and beginning and some very quiet fuzz in between. boring!

is creating fft in order to invert it a thankless task? i mean limited to things like sine waves?

i hope that makes sense :o if not maybe i cn explain some more…

#39728
Jul 6, 2012 at 6:01am

Not completely sure of what you’re trying to do – maybe you might want to post an example…

Anyway, if you’re aware enough about how Fourier transforms work, have a look at this:

http://www.ircam.fr/equipes/analyse-synthese/listePublications/articlesRodet/AES92/FFT-1AESFull.ps.gz

hth
aa

#140101
Jul 6, 2012 at 9:02pm

e.g. if i do an fft of two sounds and find the average and ifft that it doen’t sound anything like the original soudsn. that’s to be expected right?

#140102
Jul 6, 2012 at 11:03pm

let me try to rephrase that. i’m trying to make a set of sound files with a similar fft to the top left one here. however, whenever i make the desireed data and then apply ifft to it, i always get a signal that starts and ends with a very sharp peak, so that the sound is far too quiet for most of its length – just starting and beginning with a very loud click. this is not what was desired.

am i doing something wrong?

http://img269.imageshack.us/img269/9351/74628219.png

#140103
Jul 7, 2012 at 9:21am

Frankly, I still don’t understand what you’re trying to do… simply cycling on a set of values and computing their ifft will give you an harmonic spectrum, whose fundamental is the fft frame rate. If you want to create more complex sounds, the Xavier Rodet’s paper I posted above explains a technique.

Of course I might be wrong, but are you sure you have a grasp of the maths behind the Fourier transform?

#140104
Jul 7, 2012 at 12:53pm

hi,

no i don’t, exceptthat the idea is to find the sine wave frequencies that combine to make the wave. that’s not the point atm. i thought that ifft reverrted the application of fft – is that right?

the problem is that whenever i make data represtenting a frequency spectrum, and apply ifft to it, i seems to always get a waveform that starts and ends with a click and is very quiet in between. am i doing something wrong to always get that result?

not specific to max/msp :)

#140105
Jul 7, 2012 at 2:38pm

well, that’s exactly the point… fft doesn’t “find the sine wave frequencies that combine to make the wave”. it’s more complex than that… probably there are great online resources explaining how it works, but I got it when I read this book:
no joke, if you don’t have a great training in maths (which is my case) a children’s book is the best you can find! – and I can assure you, it contains everything you want to know.
cheers
aa

#140106
Jul 7, 2012 at 9:12pm

I you’d post a patch we could probably see whats wrong. But out of your description and lack of expertise I would guess that you did not care of the windowing. I never ever used fft~and ifft~, as dealing with the windowing is a pain.
Since the existence of pfft~ there are very rare occasions only for math professors who would still use these objects…

in short: use pfft~ and the world will shine in a nice spectrum again…

Stefan

#140107
Jul 8, 2012 at 6:15pm

ok, i’m gonna try pfft. there’s even a turorial on it 8)

i was not actually using max/msp, i just figured that here would be a cool / useful place to ask about fourier.

honestly i’m not ready to get to grips with the maths… if i can perform ifft so that not every signal that is returned is the same then i might.
what i’m trying to do is find out if spectrum analysis can be used to determine if some sound is “harsh” or discomforting. i am not sure if this might bear and interesting results? maybe spectrums that are low on noise??

#140108
Jul 8, 2012 at 8:12pm

so i was talking with someone, and they say fft isn’t the way to go with this but: spectrograms.

where do i start? i want to devise a way of measuring the harshness of a recording. perhaps this will be certain frequencies [unpleasantness] perhaps the presence of noise. i dunno yet! but can anyone help me get started with spectrograms – i suppose i’d like to be able to export data so that i can run statistical tests on it??

Luke

#140109
Jul 8, 2012 at 10:25pm

is there a spectrum analyzer i can export the results to .txt??

#140110
Jul 8, 2012 at 11:24pm

you should look at the zsa suite of externals for audio analysis– they use the fft in a more sophisticated, perceptually oriented and musically meaningful manner

#140111
Jul 9, 2012 at 2:02am

thanks!

one thing which suggests i’m confusing myself, is that max/msp seems to want amp and *phase* as inputs, rather than amp and freq. if anyone understand why that might confuse me – why is that?

edit oh i can get the time/freq/amp data into a stats program, i’ve just got to figure out what to run on them ha.

#140112
Jul 9, 2012 at 2:57am

that’s because the frequency is implied by the bin number or index out the right outlet of fftin– the actual frequency for a particular bin number can be calculated by dividing the number of bins into the 1/2 sample rate and then multiplying by the current bin index — sounds like you’ll have to massage your stats data so the frequency is represented as bin number. For your purposes the data could be represented as just an ordered list of amplitudes (or amp-phase pairs) with the first element (or pair) corresponding to bin 0.

#140113
Jul 9, 2012 at 3:33am

right, thanks.

just to go on… i decided that what i want to do is run tests on a bunch of noise signals which i have rated for “harshness”. i then want to create the harshest possible noise signal from that data… but i don’t want to use iift to create it. i want to use midi or something as a control voltage for a square wave oscillator.

is it possible to run an fft test to get an idea [ideally not just vaguely] what signal will be harshest, then create that signal using one square wave oscillator?

i’m kinda ahead of myself here – but any advice would be sweet :)

edit no wait i’m not sure i need fft anymore, because of the nature of what i’m rating… i’d just have several datasets of 0s and 1s, each with a harshness value, and then want to extrapolate from that.

#140114
Jul 9, 2012 at 4:05am

if you have a look at the zsa descriptors there’s all sorts of analyses that can asssist in that, ie htere’s one called ‘brightness’ I think and ‘noisiness’ spectral richness, kurtosis etc that may correlate in some way to your idea of ‘harshness’. definitely worth looking at them to get a handle on what you want and how you can systematize a synthesis method or ‘predict’ an outcome according to your chosen criteria

#140115
Jul 9, 2012 at 4:57am

I am not sure if harshness could be found with a spectral distribution alone. You would have to look in the spectrum for inharmonic content, and I think you should also look at the time domain, as the time structure adds to such a description. ZSA would be the best starting point, or set up a neural network and teach it harshness…;-)
This research could be the beginning of a big Ph.D. thesis…

To measure subjective descriptors involves other sciences like psychology on a high level as well…

But you said you want to create harshness with a square wave – you might be in a completely different world… I imagine metal techno kind of sounds… This would not involve any technical analysis, it would involve simply human experience with dinosaur analog synthesizers combined with harsh digital distortion methods…
There is much treatment out there in the world which could be learned how to tweak it to create the harshest sound imaginable – but thats a matter of taste…

Stefan

#140116
Jul 9, 2012 at 5:48am

“metal techno” haha ^_^

here’s some exmaples of square waves – i’m trying to get some people who are into harsh sounds to rate different sections for harshness…

http://soundcloud.com/timestretched_noise/testing-square-waves

cheers!
ps i also timestretch noise ahaha ;)

#140117
Jul 9, 2012 at 7:39am

so i deleted that mp3 because people were taking it seriously as a work of noise rather than a test of harshness… i;m gonna start asking about stats procedures on different forums now. physicsforums looks good… thanks for replies :)

#140118
Jul 11, 2012 at 11:40pm

square waves… can anyone debug my patch / tell me if max/msp can do this?

i have a list of 0s and 1s – these are the square wave pattern. i then used excel to count the number of times a 1 or 0 repeated before the value changed to a 0 or 1 respectively.
so e.g.: 00110100011 becomes 221132

i am now trying to “play” that new data in max. make sense? but all i get is frank digital *noise* – when i know that the original square wave was tonnes richer. am i asking the program to do things it can’t, or have i set up the patch incorrectly?
the txt file that loads is that second data set i have created in excel :)

thanks for any more help.

Attachments:
1. firstmaxattempt.maxpat
#140119
Jul 12, 2012 at 9:03am

I put something together– thought it would be easy (and probably is for someone cleverer than me), but turned out rather complicated– still doesn’t work perfectly but it’s a start. One thing you need to do is press the button twice to get the expected waveform, so something wrong with my message ordering. Basically it works by converting the text sequence of numbers into a list, which is then used to fill a wave table with either -1 or 1. the table is then looped through by a phasor. Make sure you enclose the number sequence in quotes (ie “11122225554347″) or it wont work.

Ideally you’d have an antialiasing filter in there, otherwise it’s rather academic.
anyway hope it helps
T

– Pasted Max Patch, click to expand. –
#140120
Jul 13, 2012 at 6:47pm

hmm, thanks terry, i’ll try that in a bit : . exciting!

atm i’m kinda working on creating the data in max/msp, just because excel only has about a million cells. what’s the longest txt file that max can load or create? anyway, this process is really slow atm – the patch i made is struggling a bit :( .

thanks for the help!

#140121

You must be logged in to reply to this topic.