Is it possible to use AVAudioConverter (in macOS) to encode or decode 
Opus-encoded data?

I have an Opus encoded stream with a sample rate of 24,000 and 2 channels which 
comes in 10 millisecond “chunks” (i.e. will produce 240 frames when decoded). I 
have successfully decoded it using the decoder from lipopus. I see reference to 
Opus in some of the AVFoundation documentation but have yet to find any clear 
information on how to use it.

Here’s a piece of Swift code to create an Opus format:


var outDesc = AudioStreamBasicDescription(mSampleRate: 24_000, mFormatID: 
kAudioFormatOpus, mFormatFlags: 0, mBytesPerPacket: 0, mFramesPerPacket: 0, 
mBytesPerFrame: 0,                  mChannelsPerFrame: 2, mBitsPerChannel: 0, 
mReserved: 0)

_opusFormat = AVAudioFormat(streamDescription: &outDesc)!



and  its use in AVAudioConverter to convert from a Tap on a MainMixerNode:

    _audioConverter = AVAudioConverter(from: tapFormat, to: _opusFormat)



First of all it doesn’t work. I suspect that I need to populate some of the 
fields in the ASBD but I can’t find any information as to what should be 
populated and the appropriate values.

I have a similar need to encode an Opus stream and would like to do that with 
AVAudioConverter if possible.

Thanks for any help you can give.

Doug
[email protected]



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to