I am trying to do a certain action based on whether or not the user makes a loud sound. I'm not trying to do any voice recognition or anything. Just simply do an action based on whether the iPhone picks up a loud sound.
Any suggestions, tutorials, I can't find anything on the apple developer site. I'm assuming i'm not looking or searching right.
Apple has examples such as Speak Here which looks to have code relating to decibels. I would check some of the meter classes for examples. I have no audio programming experience but hopefully that will get you started while someone provides you with a better answer.
The easiest thing for you do is to use the AudioQueue services. Here's the manual: Apple AQ manual
Basically, look for any example code that initialized things with AudioQueueNewInput(). Something like this:
Once you have that going, you can enable sound level metering with something like this:
You will have a callback routine that is invoked for each chunk of audio data. In it, you can check the current meter levels with something like this:
Or, in your case, instead of silence you can detect if the decibel level is over a certain value for long enough. Note that the decibel values you will see will range from about -70.0 for dead silence, up to 0.0db for very loud things. On an exponential scale. You'll have to play with it to see what values work for your particular application.