Posts

Post not yet marked as solved
2 Replies
764 Views
I am developing VOIP calling app so now I am in the stage where I need to transfer the voice data to the server. For that I want to get Real time audio voice data from mic with 20 mili Seconds callbacks.I did searched many links but I am unable find solution as i am new to audio frameworks.DetailsWe have our own stack like WebRTC which gives RTP sends data from remote for every 20 mili second and asks data from Mic for 20 mili second , What I am trying to achieve is to get 20 mili second data from mic and pass it the same to the stack. So need to know how to do so. Audio format is pcmFormatInt16 and sample rate is 8000 Hz with 20 mili seconds data.I have searched forAVAudioEngineAUAudioUnitAVCaptureSession Etc.I am Using AVAudioSession and AUAudioUnit but setPreferredIOBufferDuration of audioSession is not setting with exact value what i have set. In result of that i am not getting the exact data size. Can anybody help me on setPreferredIOBufferDuration.let hwSRate = audioSession.sampleRatetry audioSession.setActive(true)print("native Hardware rate : \(hwSRate)")try audioSession.setPreferredIOBufferDuration(preferredIOBufferDuration)try audioSession.setPreferredSampleRate(8000) // at 8000.0 Hzprint("Changed native Hardware rate : \(audioSession.sampleRate) buffer duration \(audioSession.ioBufferDuration)")Log:-Changed native Hardware rate : 8000.0 buffer duration 0.01600000075995922One more issue is auAudioUnit.outputProvider () is giving inputData in UnsafeMutableAudioBufferListPointer. inputData list has two element and I want only one sample. Can anybody help me on that to change it into data format which can be played in AVAudioPlayer.try auAudioUnit = AUAudioUnit(componentDescription: self.audioComponentDescription)auAudioUnit.outputProvider = { // AURenderPullInputBlock (actionFlags, timestamp, frameCount, inputBusNumber, inputData) -> AUAudioUnitStatus in let inputDataPtr = UnsafeMutableAudioBufferListPointer(inputData) let mBuffers : AudioBuffer = inputDataPtr[0]}
Posted Last updated
.