1

I already found an example code to recording with AVAudioEngine & success to output sampleRate 22050 aac format audioFile.

After I review the code, there is a problem that I have to setCategory AVAudioSessionCategoryPlayAndRecord instead of AVAudioSessionCategoryRecord.

How to improve the code for using "AVAudioSessionCategoryRecord" without "PlayAndRecord"?

(In this case I should use "AVAudioSessionCategoryRecord", right?)

If I setCategory to AVAudioSessionCategoryRecord, I get an ERROR:

AVAudioEngineGraph.mm:1070: Initialize: required condition is false: IsFormatSampleRateAndChannelCountValid(outputHWFormat)

Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(outputHWFormat)'

There is an example about using microphone in AVAudioSessionCategoryRecord, it seems to me that we can record only with inputNode. https://developer.apple.com/library/prerelease/content/samplecode/SpeakToMe/Introduction/Intro.html

The following is code can work now.

Related link

How can I specify the format of AVAudioEngine Mic-Input?

Recording audio file using AVAudioEngine

Community
  • 1
  • 1
w91379137
  • 21
  • 5

1 Answers1

0

The AVAudioMixerNode is not capable of converting between non-compressed and compressed formats. For that you need the AVAudioConverter.

DrMickeyLauer
  • 4,455
  • 3
  • 31
  • 67