Answer the question
In order to leave comments, you need to log in
How to mix left and right channel in Swift3?
I am writing a mobile application. How to do this in Xcode Swift3?
Track-A(stereo) -> Track-A(mono) -> Left channel of Track-C
Track-B(stereo) -> Track-B(mono) -> Right channel of Track-C
And finally save Track-C as separate mix. There is a code that adds Stereo tracks to the composition, but how can I change it for my case?
let composition = AVMutableComposition()
let composition.addAudioTrack1 = composition.addMutableTrack(withMediaType: AVMediaTypeAudio, preferredTrackID: kCMPersistentTrackID_Invalid)
let avAsset1 = AVURLAsset.init(url: url1, options: nil)
let audioTrack1 = avAsset1.tracks(withMediaType: AVMediaTypeAudio)[0]
do {
try compositionAudioTrack1.insertTimeRange(CMTimeRangeMake(kCMTimeZero, avAsset1.duration), of: audioTrack1, at: kCMTimeZero)
} catch {
}
audioTrack1.preferredVolume = 1
audioTrack1.pan=-1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question