Search code examples
iosavfoundationcore-audio

Capture iOS microphone audio in ulaw format


I need to capture microphone voice input in real time and stream upstream via RTSP. The audio format needs to be in ulaw. I need to obtain the raw bytes so I can feed it to the Live 555 RTSP library. Given various stuffs in Core Audio and AV Foundation and I do not know where to start.

  1. What's the native audio format from the microphone? Is it linear PCM?

  2. Does iOS 8 only AV Audio Engine have conversion capability to it? Though I probably need support for iOS 7.

  3. Can I use AQRecorder? But it seems like it saves to file, but I need to stream it.

  4. Can I use AVCaptureDevice? But how do I convert it to ulaw if it's not in it?

Help appreciated, thanks.


Solution

    1. Yes, it's linear PCM;

    2. I don't know much about AVAudioEngine, maybe you can try Audio Converter;

    3&4. Maybe you need to use Audio Unit & Audio Converter & Audio Stream. It's complicated, but since you need to capture microphone in real time and convert it to ulaw and upload, you'll need to dive into deeper level. Audio Unit is a good choice.

    There are some popular 3rd party libraries here for your reference:

    Novocaine, which capture real-time voice data from microphone;

    AudioStreamer & FreeStreamer, which download data from network and play it;

    TheAmazingAudioEngine, said to be very powerful;

    Maybe these are too complicated for you, I wrote some easy examples:

    ExtAudioFileConverter: which convert audio file from one format to another format;

    iOSEchoCancellaion: is an example to capture voice and playback synchronously.