ios – Getting robotic and chopped audio when using EZOutput


I am using EZOutput from EZAudio to output sound I receive from a stream of audio (self.myAudioBufferList). Think LiveListen. I also have the audio basic description (self.asbd!). However when I set the shouldFill method of the EZOutput datasource, I get a robotic version that is chopped with some of it missing.

func output(_ output: EZOutput!, shouldFill audioBufferList: UnsafeMutablePointer<AudioBufferList>!, withNumberOfFrames frames: UInt32, timestamp: UnsafePointer<AudioTimeStamp>!) -> OSStatus {
    
    if self.asbd != nil {
        output.inputFormat = self.asbd!
    }
    
    if self.audioBufferList != nil {
        audioBufferList.pointee.mNumberBuffers = self.myAudioBufferList!.mNumberBuffers
        audioBufferList.pointee.mBuffers.mNumberChannels = self.myAudioBufferList!.mBuffers.mNumberChannels
        audioBufferList.pointee.mBuffers.mData = self.myAudioBufferList!.mBuffers.mData
    } else {
        print("it is nil, and that is why it is making low noise")
        audioBufferList.pointee.mBuffers.mData = nil
    }
    
    return noErr;
}

Also when is set the audioBufferList mDataByteSize, the quality gets worse. In it’s current configuration the dataByteSize is about 4096 where as myAudioBufferList is not constant and fluctuates, never going over 512.

audioBufferList.pointee.mBuffers.mDataByteSize = self.myAudioBufferList!.mBuffers.mDataByteSize

The frames value that the datasource method gives has a value of 1024.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img