I have some effects applied on a channel with the Amazing Audio Engine and I want to export it to the photo library. How can I do that ? With an AEAudioFileWriter ? How can I use it ? I don't understand how it works.
Help ?
Here's where I am with my code :
let numberOfSamples = 4096; var list = AEAudioBufferListCreate(appDelegate.audioController.inputAudioDescription, Int32(numberOfSamples)) let fileWriter = AEAudioFileWriter(audioDescription: appDelegate.audioController.inputAudioDescription) fileWriter.beginWritingToFileAtPath(self._audioOutputURL!.path, fileType: AudioFileTypeID(kAudioFileAIFFType), error: nil) AEAudioFileWriterAddAudio(fileWriter, list, UInt32(numberOfSamples)) fileWriter.finishWriting() let audio = AVAsset.assetWithURL(NSURL(string: fileWriter.path)) as! AVAsset for anyObject in audio.tracks { if let track = anyObject as? AVAssetTrack { var error: NSError? let mutableCompositionTrack: AVMutableCompositionTrack mutableCompositionTrack = mutableComposition.addMutableTrackWithMediaType(AVMediaTypeAudio, preferredTrackID: Int32(kCMPersistentTrackID_Invalid)) mutableCompositionTrack.insertTimeRange(CMTimeRange(start: kCMTimeZero, duration: track.timeRange.duration), ofTrack: track, atTime: kCMTimeZero, error: &error) } }
But when I play the file, the audio is not present...
I didn't found a solution to my problem sadly...
Comments
Help ?
Here's where I am with my code :
let numberOfSamples = 4096; var list = AEAudioBufferListCreate(appDelegate.audioController.inputAudioDescription, Int32(numberOfSamples)) let fileWriter = AEAudioFileWriter(audioDescription: appDelegate.audioController.inputAudioDescription) fileWriter.beginWritingToFileAtPath(self._audioOutputURL!.path, fileType: AudioFileTypeID(kAudioFileAIFFType), error: nil) AEAudioFileWriterAddAudio(fileWriter, list, UInt32(numberOfSamples)) fileWriter.finishWriting() let audio = AVAsset.assetWithURL(NSURL(string: fileWriter.path)) as! AVAsset for anyObject in audio.tracks { if let track = anyObject as? AVAssetTrack { var error: NSError? let mutableCompositionTrack: AVMutableCompositionTrack mutableCompositionTrack = mutableComposition.addMutableTrackWithMediaType(AVMediaTypeAudio, preferredTrackID: Int32(kCMPersistentTrackID_Invalid)) mutableCompositionTrack.insertTimeRange(CMTimeRange(start: kCMTimeZero, duration: track.timeRange.duration), ofTrack: track, atTime: kCMTimeZero, error: &error) } }
But when I play the file, the audio is not present...
I didn't found a solution to my problem sadly...