I’m utilizing EZOutput from EZAudio to output sound I obtain from a stream of audio (self.myAudioBufferList). Assume LiveListen. I even have the audio fundamental description (self.asbd!). Nonetheless after I set the shouldFill technique of the EZOutput datasource, I get a robotic model of the sound that’s chopped with a few of it lacking.
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's nil, and that's the reason it's making low noise")
audioBufferList.pointee.mBuffers.mData = nil
}
return noErr;
}
Additionally when is about the audioBufferList mDataByteSize, the standard will get worse. In it is present configuration the dataByteSize is 4096 the place as myAudioBufferList will not be fixed and fluctuates, by no means going over 512.
audioBufferList.pointee.mBuffers.mDataByteSize = self.myAudioBufferList!.mBuffers.mDataByteSize
The frames worth that the datasource technique provides has a worth of 1024.
Notice: I’ve additionally tried offering the inputFormat when creating an occasion of EZOutput, nevertheless this does nothing to enhance the sound
// Assign a delegate and datasource to the shared occasion of the output to offer the output audio knowledge
self.ezOutput = EZOutput.init(dataSource: self, inputFormat: asbd)
self.ezOutput?.delegate = self