Just remembered to follow up and share what I got working here, hope this helps a fellow newbie. This code works solid for me to record to the app's documents folder, which can then be shared through iTunes file sharing. *You need to enable file sharing in iTunes in your app's info.plist file in order to retrieve the recorded files when your device is connected to iTunes.
-(void)recordToFile:(int)n { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [paths objectAtIndex:0]; NSString *samplePath = [path stringByAppendingPathComponent:@"sample.aiff"]; NSArray *readWriteArgs = [NSArray arrayWithObjects:samplePath,nil]; //write to aiff in documents folder [PdBase sendMessage:@"open" withArguments:readWriteArgs toReceiver:@"setuprecord"]; [PdBase sendBangToReceiver:@"startrec"]; }
then use an IBAction:
-(IBAction)startRecording:(id)sender { NSLog(@"Recording To File"); [self recordToFile:1]; }
This part of the code sends the "open" message to a receiver named "setuprecording" which feeds to a writesf~ object in the pd patch. [PdBase sendMessage:@"open" withArguments:readWriteArgs toReceiver:@"setuprecording"];
This part of the code to a receiver named "startrecording" which bangs a start message to the writesf~ object to start the recording. [PdBase sendBangToReceiver:@"startrec"];
This code is used to playback the file you recorded within your app.
-(void)playbackFile:(int)n { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [paths objectAtIndex:0]; NSString *samplePath = [path stringByAppendingPathComponent:@"sample.aiff"]; NSArray *readWriteArgs = [NSArray arrayWithObjects:samplePath,nil]; //playback aiff from documents folder [PdBase sendMessage:@"open" withArguments:readWriteArgs toReceiver:@"setupplayback"]; [PdBase sendBangToReceiver:@"startplayback"];
To understand what's going there:
This part of the code sends the "open" message to a receiver named "setupplayback" which feeds to a readsf~ object in the pd patch. [PdBase sendMessage:@"open" withArguments:readWriteArgs toReceiver:@"setupplayback"];
This part of the code to a receiver named "startplayback" which bangs a start message to the readsf~ object to start the recording. [PdBase sendBangToReceiver:@"startplayback"];
I'll post a simple example patch soon.
Here's the example pd patch to go with the comment above.
-1 1 1;
-262144 -1 -1 1600 1;
It looks like you're new here. If you want to get involved, click one of these buttons!