i am trying to understand the concepts of digital sound proceesing and i want to implement the FFT of Apple's Accelerate Framework link. In the vDSP API you can find a nice and fast FFT but unfortunately i can not set it up right. I think the documentation is really hard to understand. I am trying to FFT the signal of the iPhone's microphone. Can somebody give me a setup or some sites where i can read about this? Would be really great.
Thanks for all your answers.
Does Aurio Touch use vDSP ? I didn't the last time I looked, but it might now. I think that you are after a power spectrum.
Found this:
Audio File FFT in an OS X environment
Also Apple's example source would collapse down a bit if you deleted all the G4 ppc code...
The audio comes at you as integers: FFTs need floats. Convert with vDSP_vflt32 or similar.
Aurio touch is good cause you can see how all the callbacks work for sound i/o.
Related
I need to record audio from iPhone. During recording I need to know, how many audio waves I have at the current moment and frequency and amplitude of each wave.
It seems to me, that avaudiorecorder can't help me.
I had a look at Apple's SpeakHere sample code, but I can get only amplitude from here (as I understand).
I had a look at Apple's aurioTouch sample code. It seems, that it does, what I need, but sample code is incredibly big and written mostly in C++, so it's difficult for me to understand it.
Can anybody give me examples, how to get Audio frequency and amplitude. It will be better, if you give me code examples.
Apple's aurioTouch sample app appears to be written using some C++ for absolutely no reason. Convert the code to plain C, and maybe you'll understand it better. Near real-time DSP audio analysis doesn't get much easier, so read up on that topic.
I'm making an app on the iphone and I need a way of detecting the tune of the sounds coming in through the microphone. (I.e. A#, G, C♭, etc.)
I assumed I'd use AVAudio but I really don't know and I can't find anything in the documentation..
Any help?
Musical notes are nothing more than specific frequencies of sound. You will need a way to analyze all of the frequencies in your input signal, and then find a way to isolate the individual notes.
Finding frequencies in an audio signal is done using the Fast Fourier Transform (FFT). There is plenty of source code available online to compute the FFT from an audio signal. In particular, oScope offers an open-source solution for the iPhone.
Edit: Pitch detection seems to be the technical name for what you are trying to do. The answers to a similar question here on SO may be of use.
There's nothing built-in to the iOS APIs for musical pitch estimation. You will have to code your own DSP function. The FFTs in the Accelerate framework will give you spectral frequency information from a PCM sampled waveform, but frequency is different from psycho-perceptual pitch.
There are a bunch of good and bad ways to estimate frequency and pitch. I have a long partial list of various estimation methods on my DSP resources web page.
You can look at Apple's aurioTouch sample app for an example of getting iOS device audio input and displaying it's frequency spectrum.
Like #e.James said, you are looking to find the pitch of a note, its called Pitch Detection. There are a ton of resources at CCRMA, Stanford University for what you are looking for. Just google for Pitch Detection and you will see a brilliant collection of algorithms. As far as wanting to find the FFT of blocks of Audio Samples, you could use the built-in FFT function of the Accelerate Framework (see this and this) or use the MoMu toolkit. Using MoMu has the benefit of it's functions decomposing the audio stream into samples for you and easy application of the FFT using it's own functions.
I am working on a program that needs to capture the frequency of sound from a guitar. I have modified the aurioTouch example to output the frequency by using the frequency with the highest magnitude. It works ok for high notes but is very inaccurate on the lower strings. I believe it is due to overtones. I researched ways on how to solve this problem such as Cepstrum Analysis but I am lost on how to implement this within the example code as it is unclear and hard to follow without comments. any help would be greatly appreciated, thanks!
As you have discovered, musical pitch is not the same as peak frequency.
But trying to investigate algorithms while trying to work with real-time audio is not easy.
I suggest you separate the problems. Record some music sounds (guitar plucks, etc.) on your Mac into raw sound files. Try your chosen pitch estimation algorithms on these recorded sample sets. Then, after you get this working, figure out how to integrate your code into the iOS audio and Accelerate (for FFT) frameworks.
I want to analyze MIC audio on an ongoing basis (not just a snipper or prerecorded sample), and display frequency graph and filter out certain aspects of the audio. Is the iPhone powerful enough for that? I suspect the answer is a yes, given the Google and iPhone voice recognition, Shazaam and other music recognition apps, and guitar tuner apps out there. However, I don't know what limitations I'll have to deal with.
Anyone play around with this area?
Apple's sample code aurioTouch has a FFT implementation.
The apps that I've seen do some sort of music/voice recognition need an internet connection, so it's highly likely that these just so some sort of feature calculation on the audio and send these features via http to do the recognition on the server.
In any case, frequency graphs and filtering have been done before on lesser CPUs a dozen years ago. The iPhone should be no problem.
"Fast enough" may be a function of your (or your customer's) expectations on how much frequency resolution you are looking for and your base sample rate.
An N-point FFT is on the order of N*log2(N) computations, so if you don't have enough MIPS, reducing N is a potential area of concession for you.
In many applications, sample rate is a non-negotiable, but if it was, this would be another possibility.
I made an app that calculates the FFT live
http://www.itunes.com/apps/oscope
You can find my code for the FFT on GitHub (although it's a little rough)
http://github.com/alexbw/iPhoneFFT
Apple's new iPhone OS 4.0 SDK allows for built-in computation of the FFT with the "Accelerate" library, so I'd definitely start working with the new OS if it's a central part of your app's functionality.
You cant just port FFT code written in C into your app...there is the thumb compiler option that complicates floating point arithmetic. You need to put it in arm mode
Can someone help me use the AudioQueue services on the iPhone to play a certain frequency (say, 440 Hz)? I've looked at the documentation, but I can't seem to figure out quite how to do it. Apple's sample code also isn't helping me too much.
Thanks!
/Developer/Examples/CoreAudio/SimpleSDK/DefaultOutputUnit has a sample of how to play a tone at a given frequency and sample rate.
I basically copied the code (also using a bit from this blog entry) and it worked with basically no change on the iPhone.
It isn't hard at all to do this. Take a look at the AudioQueue examples. If you look at the code to play back an audio file, you're going to just do that, except without actually reading a file.
You just divide the sampling rate by your frequency, calculate a sine wave, and feed those values into the audioqueue in your playback callback function.
ok, this is kinda lame, but if no one comes up with the real answer, you could just pre-record a sine wave and loop it. If it's cut well, it should play just fine. Of course this response would only work if you had only a few different frequencies to play.