Record and play using Audio Queues in iPhone - iphone

Can someone explain how we can use Audio Queue services to record sound from Microphone and play it live? Explain how we can achieve it. If possible give code snippets.

Use RemoteIO Audio Unit. This awesome code will get you on the right path.

Related

Playback and Recording simultaneously using Core Audio in iOS

I need to play and record simultaneously using Core Audio. I really do not want to use AVFoundation API (AVAudioPlayer + AVAudioRecorder) to do this as I am making a music app and cannot have any latency issues.
I've looked at the following source code from Apple:
aurioTouch
MixerHost
I've already looked into the following posts:
iOS: Sample code for simultaneous record and playback
Record and play audio Simultaneously
I am still not clear on how I can do playback and record the same thing simultaneously using Core Audio. Any pointers towards how I can achieve this will be greatly appreciable. Any pointers to any sample source code will also be of great help.
The RemoteIO Audio Unit can be used for simultaneous record and play. There are plenty of examples of recording using RemoteIO (aurioTouch) and playing using RemoteIO. Just enable both unit input and unit output, and handle both buffer callbacks. See an example here

How to play record the sound programmatically and how to play that recorded audio?

I am developing one application. In that I want to record the sounds and I want to play that recorded sound file. I know the frameworks for doing this. But how to develop programmatically by using that frameworks?
You can refer to this link:
I have implemented this code in one of my apps and it works completely fine.
How do I record audio on iPhone with AVAudioRecorder?
For Playing the sound you have option to use AVAudioRecorder.
Hope this helps.
The best way to do it - and I am talking from painful experience here - is with the RemoteIO audio unit. You can also do it with AudioQueue, but it has a higher latency, and the queue type approach becomes very problematic.
So, I think that they are really different tools for different jobs. Note that you won't play a sound file as such. You will play the contents of a buffer held in memory. As long as the buffer is not too large, this should not be an issue.
So, going with RemoteIO, you will find this blog and tutorial very useful. It includes code samples.
Using RemoteIO audio unit By MICHAEL TYSON

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.

Accessing audio samples on the iPhone

I want to code up a audio fx program that would process the samples coming in through the mic input and play them through the audio output in near realtime. But I cannot seem to figure out how to get accesses to the individual audio samples as they come in. Can. Anybody point me in the right direction and possibly some sample code? Thanks.
The audio-processing framework in iOS is called Core Audio. See the Core Audio Overview. For sample code see the iOS Reference Library sample code. You can filter for audio using the searchbox
You probably want to be looking at the Audio Queue services (most/all of the function names begin with "AudioQueue").

AudioQueueOfflineRender questions

I have a few questions about this after reading the iPhone documentation on it:
Does this take the audio being played and save it to a buffer so it can be written to a file?
If so does the audio being played have to be played using a playback audio queue or can it be played via a higher level class such as AVAudioPlayer.
Can anyone point me in the direction of some sample code or further help than the docs.
Thanks
Yes
Pretty sure you need to use a/the playback audio queue.
This Apple QA points to a file called aqrender.cpp which implements point 1.