Re: Sample code or resources for audio play through with echo cancellation?
Re: Sample code or resources for audio play through with echo cancellation?
- Subject: Re: Sample code or resources for audio play through with echo cancellation?
- From: Zack Morris <email@hidden>
- Date: Thu, 08 Dec 2011 08:27:46 -0700
On Dec 8, 2011, at 7:51 AM, Peter Sichel wrote:
> Hello,
>
> I'm the developer of Phone Amego which includes a Bluetooth speakerphone.
>
> http://www.sustworks.com/pa_guide/handsfree.html
>
> Phone Amego currently uses a QTKit capture session to route call audio between Bluetooth and the corresponding I/O devices.
> [I originally tried the CAPlayThrough sample code, but found it to be less stable.]
>
> I'm looking for the simplest way to add echo cancellation. In the Bluetooth HFP, echo cancellation and noise reduction are optional. The iPhone's I've tested do not make them available via Bluetooth. The VPIO audio unit in iOS is not provided on Mac OS X. iChat has built-in echo cancellation, but there is no API or echo cancellation library offered to 3rd party developers [AFAIK]. There's an open source implementation of echo cancellation (SPEEX) which has been adopted by some Mac OS X products, but I haven't found an existing plug-in I can incorporate easily.
>
> If anyone has worked on this or has any useful pointers, I'd appreciate it. I'm not currently into audio development, but will consider adapting SPEEX if necessary.
>
> Thanks!
>
> - Peter Sichel
> Sustainable Softworks
I just wanted to chime in, I asked around a bunch of places when I was messing with speex for an online environment I was working on, and echo cancellation has just always been really difficult on the Mac since OS X. There is no way to just get the currently playing audio for instance (even though that's obviously a trivial thing to do. My guess is, maybe the media companies tell Apple not to do that or something). As far as I know, it requires a kernel extension or root access to really do it right. I could have hacked together something to add all the buffers coming from my game, but when you throw in things like OpenAL, you no longer have control of your audio stream so it turns into a disaster. I think it's a bad enough situation that somebody at Apple needs to put their foot down and tell them to start over. All I need as a developer is access to the queue of buffers about to be played by the hardware, and a callback of some kind to tell me when they were just played. And this needs to be at the sample level, don't make me mess around with timing. Just tell me the sample id that just played, maybe as a double precision float so we don't have to worry about wrapping. And that sample needs to be synchronized with the sample coming in on the microphone, as a simple offset that stays constant. At the very least, give me the output stream even if it's only for my own app, for things like iOS. Even with my hands tied, I can hack together something to watch for the correlation between the mic and speaker and guess the offset between their samples. Until Apple does this, I can't take audio on the Mac seriously. It's kind of, well, a big joke.
I really hope I'm wrong about this. If anyone has had luck with something like CAPlayThrough to at least get the audio coming from their app (whether it's from CoreAudio/Quicktime/OpenAL - it shouldn't matter) I'd love to hear about it. Echo cancellation is a very trivial thing to do with the right approach, and if Apple doesn't provide the access we need, then I'm going to take that to mean that they are blocking developers intentionally.
Zack _______________________________________________
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