Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mightyPhone

macrumors newbie
Original poster
Aug 13, 2008
29
0
Hello, I am still learning to program the iPhone. What I am trying to do is using the Audio Queue to play back a raw audio file. I am trying to create a buffer to store data that's read from a raw audio file.

First I get the audio file path:

soundFilePath = [[NSBundle mainBundle] pathForResource: songName ofType: format];
// check to make sure the file exist
if (soundFilePath) { NSLog(@"soundFilePath: %@", soundFilePath); } else { NSLog(@"DARN IT!! NO AUDIO FILE!!"); }

Then I create a NSData for the buffer

audioBuffer = [NSData dataWithContentsOfFile:(NSString *) soundFilePath];
if (audioBuffer) { NSLog(@"audioBuffer: %@", audioBuffer); } else { NSLog(@"DARN IT!! NO DATA"); }

When I check the NSLog in the console, audioBuffer does load the audio data but only partially, then the iPhone simulator will quit with no error whatsoever. It seems like the
buffer cannot contain the entire file, however, the file size is only 436KB. I thought Apple says NSData reads the entire file up to 2G for a 32 bit system. What have I done wrong?
Are there some other preparations I need before I can put the data in the buffer?

Thanks in advance.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.