Sample code from Apple: https://developer.apple.com/library/ios/samplecode/aurioTouch/Introduction/Intro.html