A notable feature on most iOS devices is the ability to record audio. In this recipe, we will use the microphone to record audio and save it to a temporary location on the disk using the AVAudioRecorder
class. We will then play it back with a modified pitch using the CDSoundEngine
class.
Link the CoreAudio
and AVFoundation
frameworks to your project. Now, execute the following code:
#import <AVFoundation/AVFoundation.h> #import <CoreAudio/CoreAudioTypes.h> #import "CocosDenshion.h" @interface Ch6_RecordingAudio : Recipe <AVAudioRecorderDelegate> { /* CODE OMITTED */} @implementation Ch6_RecordingAudio -(CCLayer*) runRecipe { //Set initial pitch and recorded temp file object pitch = 1.0f; recordedTmpFile = nil; //Init audio session [self initAudioSession]; /* CODE OMITTED */ return self; } -(void) initAudioSession { //Our AVAudioSession...