Thanks for the reply. This is actually half the solution (the playback part). I have figured out the create an audio file part on my own. Since I searched the Internet high and low for a *simple* solution and didn't find anything, I will post my solution here as a community service. The simplest solution that I came up with to programmatically create a sound is as follows:
Create a wave file from scratch. Wave files have a pretty simple structure so it's fairly easy to generate the needed header info (see the wave spec here:
https://ccrma.stanford.edu/courses/4...ts/WaveFormat/). Since all of the sound files I am going to be creating are all the same length and sample rate, I created a file with all the header data all ready in place but it would be a simple matter to do it programmatically. I load that data into a NSMutableData object then just append my sound data after that. Example:
Code:
NSString *path = [[NSBundle mainBundle] pathForResource:@"WavHeader" ofType:@"wav"];
NSMutableData *audioData = [[NSMutableData alloc] initWithContentsOfFile:path];
int samples = 22050;
uint8_t dataToRecord[samples];
int x;
for(x = 0; x < samples; x++) {
// populate the "dataToRecord" array with audio data. //
}
[audioData appendBytes:(const void *)dataToRecord length:samples];
// Get path to documents folder and set a file name //
[audioData writeToFile:pathToFile atomically:YES];