Outputting sound using multiple audio routes at the same time in an iPhone App? - iphone

I'm playing around with audio routes in AVAudioSession at the moment and I'm wondering whether it is possible to output sound to multiple audio routes at the same time i.e. a sound playing from the speaker and a different sound playing in the headphones? Ideally I'd like to be able to play separate sounds via a dock connector (using a 3.5mm jack adapter) and the headphone jack at the same time so if someone could tell me whether or not this is actually possible that would be a great help.
Thanks

I don't think it was possible three years ago when you wrote this, but it is possible now to play one sound through the headphone jack and another through a USB audio interface connected to the dock connector. This WWDC presentation walks you through it and provides sample code.
I don't think it's possible to play separate sounds through the headphone jack and the speaker because the AVAudioSessionRouteDescription only shows one of these built-in output ports at a time. You'd have to add a second audio interface via USB, which adds a second output port to the AVAudioSessionRouteDescription. I'm testing with a Roland Duo-Capture mk2 right now and it's working.

Related

iOS line in via headphone jack (adapter?)

I want to record an audio signal with my Audio Unit on my iPhone which comes from a normal 3.5mm audio cable (e.g. with another iPhone acting as sound source).
A direct line-in is not possible, because the iPhone has a 4 port headphone jack.
I tried different kinds of these adapters:
http://www.amazon.com/StarTech-com-headsets-separate-headphone-microphone/dp/B004SP0WAQ/ref=sr_1_3?ie=UTF8&qid=1446196112&sr=8-3&keywords=3.5mm+headphone+mic+splitter
But none of these worked.
Am I doing something wrong?
What else could I try?
Thanks a lot and have a nice day!
You have to match the expected impedance for the microphone. Otherwise the device treats it as if it weren't there. Check this out for details.

iOS capturing audio via jack port

I know ios audio programming can route the audio signal to headphone jack port instead the speakers.
But How to treat the headphone jack port as input mic (and be able to capture the signal)?
is that possible?
this is what I need
cool video explaining what I need
thanks in advance
Dario
Apple has a nice demonstration project about using Audio Queue Services
http://developer.apple.com/library/ios/#samplecode/SpeakHere/Introduction/Intro.html
I would suggest going through this project, and it should show you what you need.

Using MediaPlayer and AVFoundation Framework simultaniously in XCode

I'm an inexperienced XCode use and programmer in general so keep that in mind. I'm trying to use the microphone on the iPhone while at the same time allowing the user to play audio while using the "iPod music picker", but when the user selects music and plays it the recorder stops working? I have no idea what is going on here? Also, on a side note, how do you implement forward and back iPod buttons?
Thanks so much!
Sounds like this is an Audio Session issue - you're probably in a mode where you can either play or record, but not both at the same time.
Check out the Audio Session Programming Guide which should explain how to configure your session.
AVAudioSessionCategoryPlayAndRecord — Use this category for an application that inputs and outputs audio. The input and output need not occur simultaneously, but can if needed. This is the category to use for audio chat applications.
AVAudioSessionCategoryAmbient - This category allows audio from the iPod, Safari, and other built-in applications to play while your application is playing audio. You could, for example, use this category for an application that provides a virtual musical instrument that a user plays along to iPod audio.

iPhone recording audio

I'm currently working on a project where it is necessary to record sound being played by the iPhone. By this, I mean recording sound being played in the background like a sound clip or whatever, NOT using the built-in microphone.
Can this be done? I am currently experimenting with the AVAudioRecorder but this only captures sound with the built-in microphone.
Any help would be appreciated!
This is possible only when using only the Audio Unit RemoteIO API or only the Audio Queue API with uncompressed raw audio, and with no background audio mixed in. Then you have full access to the audio samples, and can queue them up to be saved in a file.
It is not possible to record sound output of the device itself using any of the other public audio APIs.
Just to elaborate on hotpaw2's answer, if you are responsible for generating the sound then you can retrieve it. But if you are not, you cannot. You only have any control over sounds in your process. yes, you can choose to stifle sounds coming from different processes. but you can't actually get the data for these sounds or process them in any way.

Is it possible to both play a sound and record from the microphone at the same time on the iPhone?

I want to both play sound and record sound at the same time on the iPhone.
All the apps which record sound first disable any music playing. However as music would disrupt their purpose I don't know if they're doing this deliberately or whether the iPhone does it automatically when you record from the microphone.
Does anyone have experience with this?
Refer to this page. Good luck!
I've heard something about this on one episode of the mobile orchard podcast - the one with Michael Tyson, the creator of Loopy. During the discussion, Michael explained that he had to include some code to filter out the sounds that were coming in through the microphone in realtime as other sounds were being played on the speaker.
Based on that discussion, it seems entirely possible to both play and record at the same time, but I'm sure you'll have to do your own filtering to avoid recording the sounds your playing.
You can use either a core audio unit or an audio queue, and
you need to make sure that your audio session category is set to kAudioSessionCategory_PlayAndRecord.
Beware that sound output when you use this session is much quieter
than the normal solo session (observed on 3.0).