Sound too quiet when using kAMM_PlayAndRecord

Forums Programming sound engine: CocosDenshion et al Sound too quiet when using kAMM_PlayAndRecord

This topic contains 4 replies, has 3 voices, and was last updated by  Richard Groves 1 year, 11 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
Author Posts
Author Posts
March 27, 2010 at 1:23 am #220671

jj0b
@jj0b

For my app I needed to monitor the microphone input level while also playing back sound effects so I changed the SimpleAudioEngine’s init to configure the CDAudioManager for kAMM_PlayAndRecord:

[CDAudioManager configure:kAMM_PlayAndRecord channelGroupDefinitions:channelGroups channelGroupTotal:1];

Everything is working fine except that now the output level of sounds in my app are extremely low.

When I change it back to the default kAMM_FxPlusMusicIfNoOtherAudio the audio output is fine. But of course I can’t monitor the microphone input.

I have searched this forum and used Google but there is almost no information about kAMM_PlayAndRecord anywhere that I can find.

Does anyone know how I might increase the output level of sound while using kAMM_PlayAndRecord?

(EDIT: The effectsVolume is set at 1.0 which I think is max)

Also, is changing the SimpleAudioEngine’s init the correct way to do this?

Thank you.

March 27, 2010 at 1:37 am #277853

Steffen Altwiese
Moderator
@steve-oldmeadow

kAMM_PlayAndRecord is a CocosDenshion constant so you won’t find much info searching on that. It maps to kAudioSessionCategory_PlayAndRecord. This Apple documentation explains why your audio is quiet and how to fix the problem:

http://developer.apple.com/iphone/library/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Cookbook/Cookbook.html#//apple_ref/doc/uid/TP40007875-CH6-SW13

March 27, 2010 at 4:46 am #277854

jj0b
@jj0b

Hey Steve,

Thanks for the reply.

I read through the linked document but I must be missing something. I don’t see where it discusses the low volume or how to fix it.

Could you tell me which section of the document I should be concentrating on?

March 27, 2010 at 4:50 am #277855

Steffen Altwiese
Moderator
@steve-oldmeadow

The Redirecting Output Audio section, specifically

When using the “play and record” category—which indicates your intention to use both audio input and output—output audio normally goes to the receiver. You can redirect this audio to the speaker at the bottom of the phone in two ways:

Then they give code to redirect output to the main speaker.

May 21, 2012 at 10:58 am #277856

Richard Groves
Participant
@richard-groves

For anyone else coming across this old thread having the ‘audio playback quiet in kAMM_PlayAndRecord mode’ problem here is the code I’ve used to make it work (from the linked Apple doc):

[[CDAudioManager sharedManager] setMode:kAMM_PlayAndRecord];

UInt32 doChangeDefaultRoute = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute);

doesn’t appear to need un-setting after I switch back to kAMM_FxPlusMusicIfNoOtherAudio mode (document says it is reset when the audio mode is next changed so that makes sense).

I’ve made the above change just run on the iPhone, but it didn’t seem to have any effect on iPad (which doesn’t have the phone receiver speaker to route the audio too, so doesn’t suffer the change anyway).

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.