Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-13-2009, 12:14 PM   #1 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 3
patbouquette is on a distinguished road
Default Audio - Sound frequency

Hi,
I want to know if it's possible to get the frequency of a sound coming in from the iPhone microphone. I'm not talking here about the recording sampling rate, but the frequency of the sound's waveform. I know it's possible to have access to the sound level via the AudioQueueLevelMeterState struct but I haven't find a way to get the frequency.

Any help would be appreciated.
patbouquette is offline   Reply With Quote
Old 01-13-2009, 12:36 PM   #2 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 486
CommanderData is on a distinguished road
Default

This is not an easy task. To get the frequency you'll have to record the audio coming in and use FFTs to analyze it. Google FFT (Fast Fourier Transform) and enjoy.
CommanderData is offline   Reply With Quote
Old 01-13-2009, 02:57 PM   #3 (permalink)
New Member
 
Join Date: Jan 2009
Posts: 3
patbouquette is on a distinguished road
Default

that's what I feared... I was kind of hoping there was some sort of library object from which that sound information would be directly available.

thanks for your reply
patbouquette is offline   Reply With Quote
Old 03-19-2009, 01:58 PM   #4 (permalink)
zot
New Member
 
Join Date: Mar 2009
Posts: 1
zot is on a distinguished road
Default

Have you checked out the aurioTouch app sample? It shows several different types of sound visualizations based on mic input.

I've only been able to get the sample to run correctly on the phones, it seems to crash if it runs through the simulator.
zot is offline   Reply With Quote
Old 03-19-2009, 02:04 PM   #5 (permalink)
Crafty Veteran
 
Magic Hands's Avatar
 
Join Date: Nov 2008
Location: Memphis, TN
Age: 23
Posts: 436
Magic Hands is on a distinguished road
Send a message via Skype™ to Magic Hands
Default

If you do continue with this, here is a good book that I have used in the past that is free.

The Scientist and Engineer's Guide to Digital Signal Processing's Table of Content
__________________
Magic Hands is offline   Reply With Quote
Old 05-06-2009, 09:02 AM   #6 (permalink)
Old NeXTStep guy
 
Join Date: May 2009
Location: Haddonfield, NJ
Posts: 1
rockhopper is on a distinguished road
Default do a search

Quote:
Originally Posted by patbouquette View Post
Hi,
I want to know if it's possible to get the frequency of a sound coming in from the iPhone microphone. I'm not talking here about the recording sampling rate, but the frequency of the sound's waveform. I know it's possible to have access to the sound level via the AudioQueueLevelMeterState struct but I haven't find a way to get the frequency.

Any help would be appreciated.
Your key search terms are: FFT, Wavelet and Autocorrelation.
Read the articles, grok the math and write the code.
rockhopper is offline   Reply With Quote
Old 07-29-2009, 02:33 AM   #7 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 2
Saied is on a distinguished road
Default Getting the frequency out of aurioTouch

Hello,

Sorry for resurrecting this, but I hope someone can shed light on this.

AurioTouch, apple's sample program is rich with routines demonstrating how to use the audio input, how to buffer it, and how to even FFT it to get the signal in the frequency domain. That's all find, and the internals can be viewed as a very good example and model.

However, the FFT results in an array (called: outMagSpectrum[i]) that provides the relative amplitude of different frequencies for 2048 indexes. But when I read this vector out, it does not correspond to the actual frequency that I feed it in. An A(440) gets only 41, other notes get relatively higher and lower numbers, but none accurate corresponds to the "frequency".

Does anyone know what's the trick to converting these numbers to actual frequencies?
Saied is offline   Reply With Quote
Old 07-29-2009, 06:54 AM   #8 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

You need to study up on the relationship between sample rate, sample period, frequency range, and frequency resolution. In the example you cited, I assume that the FFT had 4096 samples at 44100 samples per second, which gives a Nyquist frequency of 22050 Hz, which corresponds with the midpoint of the FFT array (index 2048). With those parameters, 440 Hz would come out very close to index 41. Your frequency resolution would be 10.8 Hz per index. You could use interpolation methods to reduce that resolution by about a factor of 10, but in this case I think your sample period (4096/44100 seconds = 93 msec.) is way too short. There is a tradeoff between sample period and FFT resolution. If you want better resolution, you need to use longer sample periods. For example, a sample size of 32768 would give a 0.74 second sample period and a frequency resolution of 1.34 Hz per index. If you are going to use FFTs to measure frequency, you have to take all these things into consideration.

Robert Scott
Ypsilanti, Michigan
RLScott is offline   Reply With Quote
Old 07-29-2009, 11:56 AM   #9 (permalink)
New Member
 
Join Date: Jul 2009
Posts: 2
Saied is on a distinguished road
Default

Thank you VERY much Robert. Your response has bee very helpful.

I am looking at the innards of the aurio touch and there seems to be no way to change the sample size without revamping the whole program.
Saied is offline   Reply With Quote
Old 06-08-2010, 10:42 AM   #10 (permalink)
Registered Member
 
Join Date: Sep 2008
Location: Agde, France
Posts: 8
boom is on a distinguished road
Default

Quote:
Originally Posted by Saied View Post
Thank you VERY much Robert. Your response has bee very helpful.

I am looking at the innards of the aurio touch and there seems to be no way to change the sample size without revamping the whole program.
Did someone find an easier way to do it??
boom is offline   Reply With Quote
Reply

Bookmarks

Tags
audio, frequency, level, sound

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 403
19 members and 384 guests
13dario13, 7twenty7, buggen, eski, EvilElf, glenn_sayers, HemiMG, jarv, LunarMoon, morterbaher, n00b, pbart, Pudding, QuantumDoja, sacha1996, Sami Gh, UMAD, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,673
Threads: 94,122
Posts: 402,906
Top Poster: BrianSlick (7,990)
Welcome to our newest member, morterbaher
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:22 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0