EZAudio doesn't work with Bluetooth devices - ios

I am using EZAudio to playback streaming audio data. Here is the graph: AUConverter -> MultiChannelMixer -> Output. The converter is configured such that it converts audio data with a sampling rate of 48000 to device sampling rate (normally 44100). The audio data will be written into a converter node
AURenderCallbackStruct converterCallback;
converterCallback.inputProc = EZOutputConverterInputCallback;
converterCallback.inputProcRefCon = (__bridge void *)(self);
[EZAudioUtilities checkResult:AUGraphSetNodeInputCallback(self.info->graph,
self.info->converterNodeInfo.node,
0,
&converterCallback)
operation:"Failed to set render callback on converter node"];
This graph works well with iphone's speakers. But when I select a bluetooth device, the callback is no longer triggered and no audio is played.
If I remove the converter node, I can play the audio again with a bluetooth device, but the sound quality is terrible. Please help, what am I missing in order to play audio in a bluetooth device.
Thanks.

Related

Resample audio in iOS

I have a wave file recorded in 48000 sample rate. I need to play the recorded audio file in BLE device configured with 44100 sample rate. When the BLE device is disconnected from iPhone, i need to resume the playback in iPhone speaker which is configured by 48000 sample rate. So is it possible to resample the audio data to 44100 while sending data to connected BLE device
Please help
Yes, this is handled automatically for you if you use AVAudioPlayer.

How can GarageBand record from built-in mic while playback on Bluetooth A2DP?

While using a Bluetooth device WITHOUT microphone to playback audio I want to record audio from the built-in microphone.
If the Bluetooth device HAS a microphone, it is not possible according to this Apple Developer Forum thread and this SO question.
However, I justed tried to do it with GarageBand and it allows me to record from the built-in microphone while playing back high quality audio (A2DP?) on the Bluetooth speaker (with no built-in microphone).
How does GarageBand do it?
I activate the my app's AVAudioSession with category AVAudioSessionCategoryPlayAndRecord and parameter AVAudioSessionCategoryOptionAllowBluetooth but I have not found a way to playback audio on the Bluetooth speaker. Only Bluetooth speakers that has a built-in microphone works.

Independently selecting input and output audio paths

I'm willing to make an app for iPad that does the following:
When the headset and a 30 pin connector speaker/mic are plugged in at the same time the user has the ability to choose the both input and output path independently for real time audio streaming.
Example:
User selects via touch events the input device as the headset mic and selects the output device as the internal speakers. The user can then speak into the headset mic and in real time hear their voice on the internal speakers.
Then the user selects the 30-pin mic as the input and the headset speakers as the output. And similarly, speaks into the 30-pin mic and hears the output on the headset speakers.
Calls like the following do not work because it automatically changes the input or output to the same peripheral.
CFStringRef audioInputOverride = kAudioSessionInputRoute_HeadsetMic;
AudioSessionSetProperty (kAudioSessionProperty_InputSource, sizeof(audioInputOverride), &audioInputOverride);
CFStringRef audioOutputOverride = kAudioSessionOutputRoute_USBAudio;
AudioSessionSetProperty (kAudioSessionProperty_OutputDestination, sizeof(audioOutputOverride),&audioOutputOverride);
Can I independently choose input/output in real time audio streaming?

CoreBluetooth and audio stream

Can I transfer audio stream from one iOS device to other iOS device (for example from 4s to new iPad) using CoreBluetooth framework. Maybe BLE is too slow fo media streaming?
Bluetooth Low Energy (BLE) is not intended to stream data !
If you want to a stream you MUST use Bluetooth 2.X+EDR and an appropriate profile. Therefore, if you want to stream audio, you need a headset or A2DP profile.
CoreBluetooth API give only access to BLE devices.
Audio streaming wont work any good, since BLE can stream 20 byte packets at a time, with 37.5ms delay between each transfer on iOS5. So this would be laggy and as good as useless. There is always the possibility of buffering the data, but in the end, this is not a good way to stream audio.
|packet| --- 37.5ms --- |packet| --- 37.5ms --- |packet...

iOS: Route audio-IN thru jack, audio-OUT thru inbuilt speaker

My project involves a magnetic card reader device that plugs into the phono socket (ie only uses microphone)
Can I get my project to output sound through the inbuilt speaker while simultaneously listening for input from the device?
Research suggests this is not possible:
iPhone audio playback: force through internal speaker?
Force iPhone to output through the speaker, while recording from headphone mic
Audio Session Services: kAudioSessionProperty_OverrideAudioRoute with different routes for input & output
The only way round I can see is actually changing the audio session every time I wish to emit a sound.
Is this really the only option? And is it practical to do this? How long would it take for the audio session to reconfigure itself?

Resources