Does anyone have any code snippets that show how to convert an M4a file to WAV? I know there are libraries that convert the other way around.
Thanks.
Does anyone have any code snippets that show how to convert an M4a file to WAV? I know there are libraries that convert the other way around.
Thanks.
AVAssetReader and AVAssetWriter in the AVFoundation framework can be used read AAC files and write that data as WAV/RIFF files on iOS devices. There's sample code on the Apple developer site. It's a bit more than a short snippet.
Just to update for Swift 3:
If anyone else needs some code to do this here it is in Swift
Here is an Objective-C version of MScottWaller's Swift 3 answer. You need to @import AudioToolbox.
Here is an edit to @O2U answere. As above code does not actually convert it to wave file. Please use "kAudioFileWAVEType" instead of "kAudioFileCAFType" in above code at line
//Create destination file ExtAudioFileCreateWithURL(destinationURL, kAudioFileCAFType, &dstFormat, nil, AudioFileFlags.EraseFile.rawValue, &destinationFile)
I simply changed the extension of the file to .wav and removed the .m4a file and it worked.
I even played .wav file and it's working fine.
Are there any drawbacks for converting the file extension from .m4a to .wav like this?