Author Topic: Frequency detection  (Read 7384 times)

Noutie

  • Posts: 10
Frequency detection
« on: 16 May '06 - 09:48 »
Hi everyone,

I have a quite physical question which came out of an investigation in which I'm currently involved and I hope that somebody can provide me some informationon this topic. 

I analyze, by a self written program using BASS, sounds recorded by a microphone. On the received data I apply a Fast Fourier Transformation and I analyse which frequency was played by finding the highest amplitude and it's belonging frequency. I'm capable of correctly reckognizing the tones of a simple song, played by an 'normal' external speaker. Things become quite different when I, for example, want to analyse a mobile phone sound.

When the mobile phone plays an A4 note (440 Hz) things starts well, but after a second or so, not the A4, but the A5 (880 Hz) gets the highest amplitude. Offcourse, a mobile phone speakers is encapsulated, so perhaps this happens due to interference? Or due to the limited frequency response of a mobile phone speaker (300 Hz - 4 kHz)? (Remember: The same soundfile on a 'normal' speaker is recorded like I supposed it would). Clues would be appreciated...
Does anyone has an idea on how to get first harmonic (so the actual tone which is played)? Or ideas on which possibilities are there to apply the highest amplitude to the first harmonic are also more than welcome...

Thanks for reading anyway,
Cheers,
Arnoud

Rah'Dick

  • XMPlay Support
  • Posts: 932
Re: Frequency detection
« Reply #1 on: 16 May '06 - 11:59 »
I think the actual problem is that mobile phone speakers are so crappy and have lots of resonance frequencies that aren't there on bigger speakers. To get the real frequency, you need to analyse all peaks that are over some threshold, in the whole frequency range. Try recording the sound you're analysing and have a look at the spectrum (with Adobe Audition for example, or XMPlay's Spectrograph). Sometimes the resonance frequency is just that - a resonance that is nothing like the original tone.

I hope that helps a bit...

Torkell

  • Posts: 1169
Re: Frequency detection
« Reply #2 on: 16 May '06 - 12:08 »
A thought: you could find the highest amplitude, then search for the smallest power-of-two factor of it (so, e.g. if you find 880Hz you then look for 440Hz, 220Hz and 110Hz) that still has a large enough amplitude.

Noutie

  • Posts: 10
Re: Frequency detection
« Reply #3 on: 16 May '06 - 13:02 »
Tnx to you guys for responding so fast!

A thought: you could find the highest amplitude, then search for the smallest power-of-two factor of it (so, e.g. if you find 880Hz you then look for 440Hz, 220Hz and 110Hz) that still has a large enough amplitude.

Believe it or not, but this option just went also through my head...
The smallest power of two factor is easy to search for but the problem is how do I define the large enough amplitude peak? If I cummulate all the amplitudes of the FFT (I use BASS_DATA_FFT4096) and divide it by 4096 to get the average, would this be a nice way to set the large enough amplitude? The lowest frequency with an amplitude peak, is always the first harmonic? I mean when a MIDI tone of 440 hz is played, there will never ever be 220 hz in the spectrum, or isn't this correct?

... Try recording the sound you're analysing and have a look at the spectrum (with Adobe Audition for example, or XMPlay's Spectrograph).

I have done this, and that's why I know the problem resides not in my program... The spectrograph's shows that in the first period of time the frequency with the highest amplitude is the note which is defined in the MIDI file, later on, this frequency amplitude attenuates a little, and the second harmonic amplitude gains above the frequency supposed to have the highest amplitude.

What I also think is strange, (but a bit offtopic) is the fact that I don't hear the A5 (880 Hz) note when the sound is played. Not cocky or something, but my 'audiosensiblity' is above average, but still I'm not capable of hearing the difference between an A4 played in a pure way (only 880 Hz without harmonics), and an A4 played with an overload of harmonics, on which even the A5 is played louder then the A4. ???
« Last Edit: 16 May '06 - 13:06 by Noutie »

Dotpitch

  • Posts: 2871
Re: Frequency detection
« Reply #4 on: 16 May '06 - 17:44 »
I mean when a MIDI tone of 440 hz is played, there will never ever be 220 hz in the spectrum, or isn't this correct?
If you're have only one source of sound (a speaker), then there can only be harmonics in higher frequencies (since 220 Hz isn't a harmonic of 440 Hz, you can draw out the waves and see that there is no integer number of 220 Hz-waves in one 440 Hz-wave).

It's odd that the first harmonic has a higher amplitude than the ground tone... something is resonating, either in the mobile phone, or in the microphone.

What I also think is strange, (but a bit offtopic) is the fact that I don't hear the A5 (880 Hz) note when the sound is played. Not cocky or something, but my 'audiosensiblity' is above average, but still I'm not capable of hearing the difference between an A4 played in a pure way (only 880 Hz without harmonics), and an A4 played with an overload of harmonics, on which even the A5 is played louder then the A4.
Just try with Audacity ;) (audacity.sourceforge.net). It has a tone generator, and I can clearly hear the difference between 440 Hz, 880 Hz, 440 with 880 Hz and 440 with 880 and 1760 Hz on a normal speaker (though the sound gets annoying :P).

Rah'Dick

  • XMPlay Support
  • Posts: 932
Re: Frequency detection
« Reply #5 on: 16 May '06 - 23:38 »
Another thought:
What if you're FFT'ing both channels? To get one single-channel frequency, you'd have to divide that by 2, right?