conversion from mono 22050 to stereo 44100
conversion from mono 22050 to stereo 44100
- Subject: conversion from mono 22050 to stereo 44100
- From: Waverly Edwards <email@hidden>
- Date: Mon, 10 Jul 2017 18:09:50 +0000
- Thread-topic: conversion from mono 22050 to stereo 44100
I am using AVFoundation to up convert and play a mono file that has a sample
rate of 22050, through AVAudioengine with the end result being stereo and a
sample rate of 44100.
At this time, I am explicitly using AVAudioConverter to do this and it is
working perfectly well. However, I thought there may be a way to do this with
less overhead and less code.
WWDC15 Session 507, referenced two things, channel mapping being wrapped in
AVAudioChannelLayout and automatic format conversions. I've been unable to
determine how make this implicit conversion occur. Attempt to make this work,
including inserting a mixer between a player and the main mixer, setting the
output format to the desired sample rate and stereo channel output on the
inserted mixer. When I do this, I get an error AVAE, "No Converter".
Unfortunately, I don't know if this means it can't convert the channels or
sample rate.
Previously, I would have something like this (winging it here).
However, I think AVAudioChannelLayout is supposed to provide a higher level
abstraction, so we didn't need to access the audio unit, like I'm trying to do
here.
channelMap[0] = 0 // keep the left channel as the left channel
channelMap[1] = 0 // map left channel to right channel output
let propSize = UInt32(channelMap.count) * UInt32(MemoryLayout<Int32>.size)
let status = AudioUnitSetProperty( _engine.inputNode.audioUnit,
kAudioOutputUnitProperty_ChannelMap, kAudioUnitScope_Global, 1, channelMap,
propSize)
Does anyone have an idea of how to make the channel mapping using
AVAudioChannelLayout?
Also, is there an implicit up-sampling that occurs when you provide an
AVAudioPCMBuffer and the output node is a higher sample rate?
Thank you,
W.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden