Post

Replies

Boosts

Views

Activity

Reply to Compressing AVAudioPCMBuffer within AVAudioEngine Tap
Hello @Engineer, I am trying to convert PCM to AAC Format, the sample rate, channel is same to PCM. I use the code modified upon, but when finish, the sound played was very rapid, What's the problem? let bufferLength = buffer.frameLength var offset: UInt32 = 0 var done = false var data = Data() while !done { let aacBuffer = AVAudioCompressedBuffer(format: outputFormat, packetCapacity: 1, maximumPacketSize: converter.maximumOutputPacketSize) converter.convert(to: aacBuffer, error: nil) { packetCount, inputStatus in let count = min(packetCount, buffer.frameLength - offset) if count == 0 { inputStatus.pointee = .noDataNow return nil } let buffer1 = self.getOffsetBuffer(buffer: buffer, offset: offset, count: count) offset += count inputStatus.pointee = .haveData return buffer1 } data.append(Data(bytes: aacBuffer.data, count: Int(aacBuffer.byteLength))) if offset >= bufferLength { done = true } } return data // To add AAC Header
Topic: Media Technologies SubTopic: Audio Tags:
Oct ’24
Reply to Get PDF blank when generate privacy report when use Xcode
Have you solved this problem?
Replies
Boosts
Views
Activity
Apr ’24
Reply to Compressing AVAudioPCMBuffer within AVAudioEngine Tap
Hello @Engineer, I am trying to convert PCM to AAC Format, the sample rate, channel is same to PCM. I use the code modified upon, but when finish, the sound played was very rapid, What's the problem? let bufferLength = buffer.frameLength var offset: UInt32 = 0 var done = false var data = Data() while !done { let aacBuffer = AVAudioCompressedBuffer(format: outputFormat, packetCapacity: 1, maximumPacketSize: converter.maximumOutputPacketSize) converter.convert(to: aacBuffer, error: nil) { packetCount, inputStatus in let count = min(packetCount, buffer.frameLength - offset) if count == 0 { inputStatus.pointee = .noDataNow return nil } let buffer1 = self.getOffsetBuffer(buffer: buffer, offset: offset, count: count) offset += count inputStatus.pointee = .haveData return buffer1 } data.append(Data(bytes: aacBuffer.data, count: Int(aacBuffer.byteLength))) if offset >= bufferLength { done = true } } return data // To add AAC Header
Topic: Media Technologies SubTopic: Audio Tags:
Replies
Boosts
Views
Activity
Oct ’24