I'm using AVAssetWriter to output wav file in the app temp folder with these settings:
NSDictionary* outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[ NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey,
[ NSNumber numberWithInt: 2 ], AVNumberOfChannelsKey,
[ NSNumber numberWithFloat: 44100.0 ], AVSampleRateKey,
[ NSData data ], AVChannelLayoutKey,
[ NSNumber numberWithInt: 64000 ], AVEncoderBitRateKey,
nil];
It's outputting seemingly normal 45mb .wav file but the app can not read it anyways. I suspect the file header is corrupt because I opened the the .wav in audacity (which accepted it no problem) and re-exported it with again .wav extension. The exported file worked fine in the app.
I also opened the both .wav files with the text editor to see the headers and they were somewhat different.
any clues?
You're using
kAudioFormatMPEG4AAC
forAVFormatIDKey
when you should be usingkAudioFormatLinearPCM
. Wave files are a PCM format and cannot be exported with MPEG-4 packets.