How to send audio to iPhone loudspeaker instead of earspeaker?

Hi,

I'm new to TAAE. One of the problems I have on iPhone is that it automatically changes the audio output to the earspeaker. How can I send the audio to the loudspeaker? This doesn't happen on the iPad because there is no earspeaker.

Thanks in advance,

Regards,

Nuno

Comments

  • Strange - does this happen in the TAAE sample app for you, @sinosoidal?

  • Michael, didn't tried the sample. I have coded directly on my app. What should I look for? My initialisation code is like this:

    NSLog(@Initializing DRCAppDelegate);
    self.audioController = [[AEAudioController alloc] initWithAudioDescription:[AEAudioController nonInterleaved16BitStereoAudioDescription] inputEnabled:NO];

        BOOL result = [_audioController start:&error];
    
        if (!result)
        {
            // Report error
            NSLog(@"There was an error while starting AE");
        }
        else
        {
            NSLog(@"AE Started");
        }
    
        NSString *category = AVAudioSessionCategoryPlayAndRecord;
        AVAudioSessionCategoryOptions options = AVAudioSessionCategoryOptionMixWithOthers;
    
        if (![[AVAudioSession sharedInstance] setCategory:category withOptions:options error:&error])
        {
            NSLog(@"Couldn't set audio session category: %@", error);
        }
    
        self.channel = [AEBlockChannel channelWithBlock:^(const AudioTimeStamp  *time, UInt32 frames, AudioBufferList *audio)
        {
            Q_UNUSED(time)
    
            if (DRCController::instance())
            {
                if (DRCController::instance()->synth())
                {
                    //DRCController::instance()->synth()->process((float*)audio->mBuffers[0].mData, frames/2);
                    DRCController::instance()->synth()->process((float*)audio->mBuffers[0].mData, (float*)audio->mBuffers[1].mData, frames);
                }
            }
        }];
    
        _channel.audioDescription = [AEAudioController nonInterleavedFloatStereoAudioDescription];
        _channel.channelIsMuted = NO;
        _channel.volume = 1 ;
    
        [_audioController addChannels:@[_channel]];
    
        /*
        self.audiobusController = [[ABAudiobusController alloc] initWithApiKey:@"MTQzODU5ODc5MyoqKkRSQyoqKkRSQy0xLjAuYXVkaW9idXM6Ly8=:SXpF6BxtD5Aw97zkqWu7dTC6jHo4RWljWsYigmNkiL5urPUOuM8Gfq9przySRQ5EN+HpNZlI0rDWGcMPBErkfu8syUTXvHyFfw/KnbTZgA+xd48pZlpT5S77ub/1HE9D"];
        self.audiobusController.connectionPanelPosition = ABConnectionPanelPositionLeft;
    
        ABSenderPort *sender = [[ABSenderPort alloc] initWithName:@"DRC-1 Output"
         title:NSLocalizedString(@"DRC-1 Output", @"")
         audioComponentDescription:(AudioComponentDescription) {
         .componentType = kAudioUnitType_RemoteInstrument,
         .componentSubType = 'drc1',
         .componentManufacturer = 'imgo' }];
    
        [_audiobusController addSenderPort:sender];
    
        _audioController.audiobusSenderPort = sender;
    
        [_audiobusController addObserver:self forKeyPath:@"connected" options:0 context:kAudiobusConnectedOrActiveMemberChanged];
        [_audiobusController addObserver:self forKeyPath:@"memberOfActiveAudiobusSession" options:0 context:kAudiobusConnectedOrActiveMemberChanged];
         */
    

    Thanks,

    Regards,

    Nuno

  • I see you're interacting directly with AVAudioSession - I'd remove that stuff, as TAAE handles this for you, and you may be interfering with it.

  • Michael,

    It was that! Thanks! :)

    Regards,

    Nuno

Sign In or Register to comment.