You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m currently working on a project using AVAudioEngine and need assistance with properly encoding and decoding AVAudioPCMBuffer to and from the Opus format.
Would anyone be able to share a working solution or example, please?
Any help or pointers would be greatly appreciated!
Thank you,
Ondrej
The text was updated successfully, but these errors were encountered:
It's actually fairly simple to do using this package.
// set the opus encoding format
varencodingFormat=AVAudioFormat(
opusPCMFormat:.float32,
sampleRate:.opus48khz,
channels:1)
// Initialize the encoder
guardvar opusEncoder =try?Opus.Encoder(format: encodingFormat)else{print("Failed to create opus encoder")return}
// and now you can use the encoder to encode your AVAudioPCMBuffer. The encoding migh fail if the samplerate does not match, sou you might need to convert the sample rate first
varbuffer:AVAudioPCMBuffer= example_buffer // your buffer
varopusData=Data(count:10000) // not sure why, but setting the data count to something like this fixes weird errors I've encountered
_ =try opusEncoder.encode(buffer, to:&opusData)print(opusData)
Was stuck on this myself for weeks.
Thank you @ydnar for creating this!
Hi everyone,
I’m currently working on a project using AVAudioEngine and need assistance with properly encoding and decoding AVAudioPCMBuffer to and from the Opus format.
Would anyone be able to share a working solution or example, please?
Any help or pointers would be greatly appreciated!
Thank you,
Ondrej
The text was updated successfully, but these errors were encountered: