Use FFT to determine strongest freqs?

Official support for: sonicbirth.sourceforge.net
RELATED
PRODUCTS

Post

hi,

i'd like to determine the top 3 of the frequencies with the highest amplitude in an audio signal for a plugin idea i have. i already read that the FFT capabilities are limited in SB, but maybe it's (almost) there.

so is there an example plugin showing how to work with the FFT components? i know that FFT has something to do with decomposing a signal into sinusiods with a certain amplitude and phase, but i cannot figure out myself what the in- and outputs of, say, the Forward FFT component mean, and what i can do with them. the manual isn't very helpful in this respect (at least, not for me).

or does anybody have a suggestion how to accomplish this, or what kind of component is missing (which maybe i can contribute).

grtz

Post

so i found the graphical EQ using FFT, which made some sense to me, but i still don't understand the outputs (real, img) of the FFT.

i think it's about moving from the time domain into the frequency domain, but the outputs suggest to consist of only 1 complex number representing the amplitude and phase of just 1 frequency, but for which frequency?

is there somebody who can shed a light here?
Creator of the InstantSampler @ www.muxer.nl

Post

I don't think you are going to be able to do what you want. The outputs of the FFT module are arrays of numbers, one array giving the amplitudes of all the sin functions and one giving the amplitudes of all the cosine functions, that, when all added together give the waveform that you decomposed.

The frequencies of each component sin or cosine function are whole number multiples the fundamental. They are fixed: so 2f, 3f . . . so forth. Only their amplitudes vary. You don't have access to those numbers in those arrays in SB. For example, if you wanted to increase every component frequency by some amount, or dump the lowest two etc. there isn't a way to do it. Any algebraic operation you do to the outputs of FFT just operates on the whole array. You can't . . say . . . just look at the last three values, or manipulate any of the individual component frequencies.

Converting the outputs from real/imaginary to polar form won't do anything either because that's just a different way of representing the same data.

One thing I haven't investigated too much is using convolution to somehow affect the components of the FFT arrays. The included convolution module (NOT the convolution reverb module) says that it convolves two signals in the complex plane. I tried briefly to convolve special functions like a delta function (spike) with some FFTs and then inversing the FFT to hear the result. It seemed to me that in theory you could "select" a particular frequency from the FFT this way, although I have no idea how you would make it shift relative to the fundamental note. Admittedly, this is a long shot.

Something that you may want to check out if you have some time is this online text http://www.dspguide.com/ which discusses digital signal processing in general and really teaches the concept of convolution well.

Post

thnx dscro for the explanation,

if you say "The frequencies of each component sin or cosine function are whole number multiples the fundamental.", what fundamental do you mean, the lowest frequency in the signal or something like that? and if you would FFT noise (which contains all freqs), are just the multiples of a fundamental (again, which one?) enough to represent this?

shouldn't this fundamental be an output parameter? it seems crucial when interpreting the sine + cosine amplitude arrays.

i can think of a generic component taking FFT and a constant N as input, which outputs the N-th loudest frequency. you can do all sorts of things with that i guess. what i'm thinking about is a dynamic equalizer that does not has a static frequency but 'follows' the (N-th) loudest frequency in the side-chain.

it could be a stupid idea, or brilliant, and/or already done, but i'd like to experiment with this and see if i can give, for instance, a lead synth more priority in a mix over a bass synth in a very dynamic way: only when the lead plays, the bass will have some specific conflicting freqs attenuated.
Creator of the InstantSampler @ www.muxer.nl

Post

.

What was this graphical EQ that you say uses FFT in Sonic Birth?

Post

it's in the Prebuilt_plugins dir of the source distribution:

"Graphical Equalizer.sbc"
Creator of the InstantSampler @ www.muxer.nl

Post

The fundamental is the lowest harmonic in the series, yes. Play A=440 Hz on the piano. The 440 Hz, the note we call A is the fundamental. Most people aren't able to hear the higher harmonics present in a musical signal as discrete notes themselves. Discrete FFT just takes a fixed length of time of a musical signal(a certain number of samples, I don't know what it is) and says, instead of representing them as amplitude vs. time, let's see what mix of all frequencies is necessary to create that particular waveform.

A complication with Discrete FFT is that if the time is long, and harmonic content in the signal changes during the FFT block, then your spectrum will not necessarily be what you would expect. For a simple example: if A=440 continuous sin wave has an 880Hz overtone and another at, say 1760Hz then you would expect to get three amplitude values in your FFT (with the one at 440Hz the biggest). But that's only if the signal was steady state during the time that the DFFT is decomposing the signal. If one of those harmonics decayed quickly then the overall waveform changed during your FFT "sample/block time" and now FFT is going to mix in all sorts of other harmonics with various amplitudes to try to un-build a complicated shaped waveform that is really just the result of a time-decaying third harmonic. The more steady-state the real signal is, the more the FFT will contain just spikes at the constituent harmonics. The more dynamic the signal is, the less the FFT will nail the simple harmonic frequency components of the signal. I believe in quantum physics they call this the uncertainty principal.

By the way, most FFT algorithms represent frequency as fractions of the sample rate.

I have no idea what the frequency spectrum of noise looks like but I'm gonna guess that there's some pattern of decreasing amplitudes for increasing frequencies. Aren't there different "noises" - pink noise, white noise . . with different spectra?

I totally agree with you that the fundamental should be an output that you can steal from the FFT module. But it's just not there in SB.

Post

dscro wrote:a fixed length of time of a musical signal(a certain number of samples, I don't know what it is).
It is variable in SB, the FFT Sync element allows you to assign any power of 2 from 64 to 8192 (samples).
dscro wrote:A complication with Discrete FFT is that if the time is long......FFT algorithms represent frequency as fractions of the sample rate.
And the complication when it is short, is that you have less control over the signal because each bin represents a larger portion of the frequency range. To make it really quick, the shorter the sample (FFT size) the fewer blocks you have because it is divided into equal portions of the frequency range - which typically works against us due to the logarithmic scale of frequency. For a quick (rather unrealistic) illustration, a very small sample (let's say there are 10 bins to use and our spectrum is 0-20000Hz) the bin size would be 20000/10, or 2000 Hz. The bin boundaries in the frequency spectrum would be (in Hz) 0, 2000, 4000, 6000, 8000.... Which gives little control over the low end and midrange since we* only have access to the bins and therefore we would have 1 bin to control everything that happened from 0-2000 Hz.

J

*we = the capability exists, but not exposed in every format/angle in SonicBirth.

Post

ok, got most of it.

well, almost. what is the relation between a bin (which seems to be some range in which only 1 frequency can be determined) and the output (arrays of (co)sine amplitudes with whole numbered multiples of the fundamental)?


but the one thing i particularly do not understand (and that's what i tried to ask with the noise example) is if you decompose a signal only in sines and co-sines with frequencies which are whole multiples of the fundamental, then how can, for example, a signal containing a simple cord (say C3-E3-G3) of three sine waves be represented?

the fundamental would be C3 = 130.81 Hz. then the next sine/co-sine frequency that can be represented is C4 = 261.62 (2 times the fundamental) which is already bigger than E3 or G3. so how do these frequencies get represented in the output?
Creator of the InstantSampler @ www.muxer.nl

Post

muxer wrote:ok, got most of it.

well, almost. what is the relation between a bin (which seems to be some range in which only 1 frequency can be determined) and the output (arrays of (co)sine amplitudes with whole numbered multiples of the fundamental)?


but the one thing i particularly do not understand (and that's what i tried to ask with the noise example) is if you decompose a signal only in sines and co-sines with frequencies which are whole multiples of the fundamental, then how can, for example, a signal containing a simple cord (say C3-E3-G3) of three sine waves be represented?

the fundamental would be C3 = 130.81 Hz. then the next sine/co-sine frequency that can be represented is C4 = 261.62 (2 times the fundamental) which is already bigger than E3 or G3. so how do these frequencies get represented in the output?
A bin is the signal for one division of the spectrum, in the above illustration, it would be 0-2000Hz, 2000-4000Hz, 4000-6000Hz.... In SB, the FFT output is the FFT bin datum. In reality, there are much more than 10 bins to use (the actual value depends on the FFT Size you state). It's not based on the fundamental of the signal, but the range/bin the fundamental falls in. The signal is represented by energy within a bin, so the 3 sinusoids will typically fall into 3 different bins.

J

P.S. I'm not an expert on the subject.

Post

muxer wrote:hi,

i'd like to determine the top 3 of the frequencies with the highest amplitude in an audio signal for a plugin idea i have. i already read that the FFT capabilities are limited in SB, but maybe it's (almost) there.

so is there an example plugin showing how to work with the FFT components? i know that FFT has something to do with decomposing a signal into sinusiods with a certain amplitude and phase, but i cannot figure out myself what the in- and outputs of, say, the Forward FFT component mean, and what i can do with them. the manual isn't very helpful in this respect (at least, not for me).

or does anybody have a suggestion how to accomplish this, or what kind of component is missing (which maybe i can contribute).

grtz
Weird, I was just asking about the same thing on the SE yahoo group.

Post

thnx eigentone, that makes sense.

runagate, what is SE and for what do you want to use this "top-3 frequency selector"?

btw (this starts to get a bit off topic), does anybody know of a dynamic eq created in SB, or maybe wants to help me to make one?
Creator of the InstantSampler @ www.muxer.nl

Post

muxer wrote:thnx eigentone, that makes sense.

runagate, what is SE and for what do you want to use this "top-3 frequency selector"?

btw (this starts to get a bit off topic), does anybody know of a dynamic eq created in SB, or maybe wants to help me to make one?
I think runagate is referring to SynthEdit.

Sorry, I can't help make an EQ right now (it takes a lot of time), I am quite busy (including working the SB source). I would guess the dynamic EQ will be a challenge using the latest version - It depends on how complex/thorough a design you wanted.I don't know of one, but I don't look around for sbcs, so it may be out there. It's possible to make a simple one in the time domain (i.e. no FFT).

J

Post

muxer wrote:thnx eigentone, that makes sense.

runagate, what is SE and for what do you want to use this "top-3 frequency selector"?

btw (this starts to get a bit off topic), does anybody know of a dynamic eq created in SB, or maybe wants to help me to make one?
Yep, synthedit.

I want the top 3 freqs for hz to modulation information,
and to make a 2-stereo in/out vocoder which spectrally morphs 4 bands of each input from one dry signal to the other.

Post

I see reference to dynamic eq now and again, what's the difference between that and multiband compression?

The FFT stuff is over my head, wish I had something to contribute!
Image

Post Reply

Return to “SonicBirth”