ios - Headphone volume issue when using AvAudioEngine output -
i using avaudioengine capture user's voice while applying real-time effects(like reverb or sth) voice.here's code
import uikit import avfoundation class viewcontroller: uiviewcontroller{ var audioengine:avaudioengine! var audioreverb:avaudiounitreverb! var audioinputnode:avaudioinputnode! override func viewdidload() { super.viewdidload() let session = avaudiosession.sharedinstance() session.setcategory(avaudiosessioncategoryplayandrecord, error: nil) session.setactive(true, error: nil) } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func recordwithreverb(sender: anyobject) { audioengine = avaudioengine() audioengine.stop() audioengine.reset() audioinputnode = audioengine.inputnode audioreverb = avaudiounitreverb() audioreverb.loadfactorypreset(.largeroom) audioreverb.wetdrymix = 50 audioengine.attachnode(audioreverb) let inputformat = audioreverb.inputformatforbus(0) audioengine.connect(audioinputnode, to: audioreverb, format: inputformat) audioengine.connect(audioreverb, to: audioengine.outputnode, format: inputformat) audioengine.startandreturnerror(nil) } }
when test headphones have mic on it(like earpods), works well.but when use other headphones without mic (so use mic on iphone input source), right speaker of headphone sounds smaller left speaker of headphone.how can fix it?
and there's question i'd ask, when write code
var audioengine:avaudioengine! var audioreverb:avaudiounitreverb! var audioinputnode:avaudioinputnode!
inside function "recordwithreverb",the code cannot work correctly, can't output, why did happen?
seems set wetdrymix value bigger can solve problem.
audioreverb.wetdrymix = 80
Comments
Post a Comment