Record Voice from microphone and monitor with delay - ios

What I need to do is Record my voice using the microphone and simultaneously listen to what I am saying with latency.
I have tried using AVAudioRecorder and AVAudioPlayer (firing the AVAudioPlayer let's say 1 second later to play the file from the same nsurl as I am recording to) but that does not work.
Any ideas?

AVAudioRecorder and AVAudioPlayer both deal with discrete audio files.
You are going to need to deal with streaming audio. You probably want to AVFoundation and create both an AVAssetReader and an AVAssetWriter, connect the reader to the microphone, and connect the writer to an output stream.
AVFoundation is tricky to figure out. I haven't worked with it in quite a while, and I'm no expert. I suggest you do some digging using those specific search terms.

Related

How to record all audio generated from my app (might from AVPlayer or others) in iOS? (not mic)

There are many audio generated from my app, the sources could be AVPlayer, AudioUnit, etc. I want to record all the audio(not from mic because that would record user voice) into a single file. Is there any way to get the final mixed audio data before sent to the audio playback hardware?
I've tried AudioUnit, and The Amazing Audio Engine. However it could only record audio played by AudioUnit.
Also read the MTAudioProcessingTap, but it has to inject some code into AVPlayer, and seems complicated to mix all the audio.

Record audio streamed from AVPlayer

I'm trying to record/capture audio that's being streamed via an AVPlayer. The AVAudioRecorder only records from the microphone which may work if the audio is played via speakerphone (although quality will suffer) but it'll definitely not work if the headphones are plugged in.
I've looked everywhere for a solution but still haven't found a solution that'll work for me. Would I need to grab the audio buffer? Is there another way to capture what's being played?
You can grab audio buffers by adding an MTAudioProcessingTap to your AVPlayer.
The process is a little convoluted, but there is some information out there.
The easiest approach nowadays is to play and record using AVAudioEngine.

ios Can I use MPMoviePlayerController to play .mp3 url

My app needs to play some music files, like .mp3. I would like to use MPMoviePlayerController because it has implemented all the UI stuff for me, i.e. I do not want to bother implementing progress slide bar and things like this.
I tested to use it to play a .mp3 file and it worked fine but I do not know if it is fine to use it to do this because its name says "movie player" and it seems it is supposed to play a movie. Would apple reject this? Thank you.
For playing audio from a file or memory, AVAudioPlayer is your best option but unfortunately it doesn't support a network stream while MPMoviePlayerController can
From documentation :
An instance of the AVAudioPlayer class, called an audio player,
provides playback of audio data from a file or memory.
Apple recommends that you use this class for audio playback unless you
are playing audio captured from a network stream or require very low
I/O latency.
For the Apple validation I don't think that your application can be rejected because you're using the Media Player Framework to play an audio file. In fact here they explicitly say that you can do just that:
Choose the right technology for your needs:
To play the audio items in a user’s iPod library, or to play local or
streamed movies, use the Media Player framework. Classes in this
framework automatically support sending audio and video to AirPlay
devices such as Apple TV.
Not sure about performance and memory issues though!
Best of luck.

How to play stream audio in iPhone/iPad

I want to play sounds from an internet server in my own program. But the sample codes Apple supplied concerned about sound play are all open an audio file, and then play it.
I want to know how can I play PCM data from memory, which received from internet continuously. Either OpenAL or AudioQueue is OK.
Give this a look:
http://cocoawithlove.com/2008/09/streaming-and-playing-live-mp3-stream.html
http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/AudioandVideoTechnologies/AudioandVideoTechnologies.html#//apple_ref/doc/uid/TP40007072-CH19-SW8

How to record audio running out of iphone speakers?

Hey, I'm a new developer in Objective C. I'm trying to record the audio running out of iPhone speakers. I can capture the audio by mouth speaker and record it. But I cannot record the audio producing from my iPhone. Please help me.
Unfortunately, there is no way to directly capture from the "audio bus". You can either capture the audio via the internal microphone or headset microphone, but that's it. If you are rendering the audio, you could obviously also write that audio out to a file as well at the same time. That's pretty much your only option.
yes, you only get a handle on the audio generated by your process. There is no way to get the audio generated by the rest of the system.

Resources