Is it possible to play back a sound while it is recording it, live?
I found this question/answer which shows how to record sound with AVAudioSession.
If so, at what should I be looking at? Can AVAudioSession play sound as well?
(Basically like an amplifier, outputting the sound as it comes in)
You can use either the Audio Queue API or the RemoteIO Audio Unit for streaming audio record and play. The RemoteIO unit will have a much lower latency. Either way, you should initialize your audio session and set it for kAudioSessionCategory_PlayAndRecord.
Related
I am trying to record the sound from iPhone speaker. I am able to do that, but I am unable to avoid mic input in the recorded output. Tried with sample code available in different websites with no luck.
The sample which I used does the recording with audio units. I need to know if there is any property for audio unit to set the mic input volume to zero. Above that I came to from other posts that Audio Queue services can do the thing for me. Can any one redirect me with sample code for the audio queue services implementation. I need to know whether there is a way of writing the data to an separate audio file before sending it as input to speaker.
Thanks in advance
There is no public iOS API or property for recording generic audio sent to the iPhone speaker. Only mic input can be recorded.
But if you are playing audio in your app using only uncompressed samples with Audio Queues or the RemoteIO Audio Unit, you can just copy those samples to a file before you write them to the audio callback buffers. Those saved samples can be used to construct a recording.
In my application, I'm playing an audio using audio toolbox framework.
When its playing, how can I record the same?
I tried using AVAudioRecording by setting audio session "Play and Record". But when recording, the volume of the audio being played is getting reduced.
How can I use Audiotoolbox framework itself and record the audio?
Can some one help me?
You can't use the AVAudioRecorder to record itself. You can use the Audio Queue or the Audio Unit RemoteIO APIs, and capture the audio samples you are putting in the output buffers to play as you play them.
I'm creating some application that plays sounds like piano, drums etc.
I have a recording feature in that. Its recording well and good. I'm using AVAudioRecorder.
But along with application sound, outside sound is also being added. How can I make my recorder record only app sounds.....
Is there any other class/framework that I've to use.
There is no API that will redirect an iPhone app's audio output to a file.
I think your only option is to use a low level audio API (either AudioQueues or RemoteIO units) and when recording write the samples out to a file (via a buffer) as well as to the speaker.
This would require you to generate, arrange and mix the instrument samples, something wouldn't have to worry about with a higher level API.
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.
Instead of playing something out the speaker and recording it through the mic, can I just record the system sound and not use the mic at all? How should I proceed for this? What should I use as framework?
If you are playing uncompressed sounds using the Audio Queue or Audio Unit Remote IO APIs, you can just write to a file the same sound samples which you use to fill the callback buffers, and you will have recorded what you played.