TAAE2 - Audiobus is not working on iPhone

Hello,

I am working on audiobus in my app and I am getting following error in log when i test audiobus sender function.

AudioBufferList passed to ABSenderPortSend does not match clientFormat

It is working on iPad but not working on iPhone. I even tested with TAAE2 sample code. but same error is showing.

Please help.

Comments

  • Can you share the code you put into the sample app, @pratik?

  • edited August 2016

    Please check the code :

    // audiobus code
        self.audiobusController = [[ABAudiobusController alloc] initWithApiKey:ABKey];
    
        // Create sender port, to send audio
        ABSenderPort *sender = [[ABSenderPort alloc] initWithName:@"xmeinc:Sender"
                                                   title:@"sender"
                               audioComponentDescription:(AudioComponentDescription) {
                                   .componentType = kAudioUnitType_RemoteGenerator,
                                   .componentSubType = 'bnks',
                                   .componentManufacturer = 'xmei' }];
        [_audiobusController addSenderPort:sender];
    
        //control the play/stop trigger during audiobus
        self.playTrigger = [ABTrigger triggerWithSystemType:ABTriggerTypePlayToggle
                                                      block:^(ABTrigger *trigger, NSSet *ports) {
                                                           [self togglePlay];
                                                      }];
    
        [_audiobusController addTrigger:self.playTrigger];
    
    // render block
     renderer.block = ^(const AERenderContext * _Nonnull context) {
    
            __unsafe_unretained AEMixerModule * aggregator
            = (__bridge AEMixerModule *)AEManagedValueGetValue(sampleValue);
    
            // Run varispeed unit, which will run its own render loop, above
            AEModuleProcess(aggregator, context);
            AERenderContextOutput(context, 1);
    
    
            if ( ABSenderPortIsConnected(sender) )
                ABSenderPortSend(sender, context->output, context->frames, context->timestamp);
    
            // Now mute, if appropriate
            if ( ABSenderPortIsMuted(sender) ) {
                // If we should be muted, then mute
                for ( int i=0; i<context->output->mNumberBuffers; i++ ) {
                   memset(context->output->mBuffers[i].mData, 0, context->output->mBuffers[i].mDataByteSize);
                }
            }
    
        };
    

    Code is working smoothly on iPad but not on iPhone.

    Please help friend.

  • edited August 2016

    Ah, you're not setting the clientFormat property.

    sender.clientFormat = AEAudioDescription;
    

    But is there any reason you're using ABSenderPortSend directly? You should, if at all possible, just pass in the output audio unit.

    Check out the Audiobus documentation for details and further info (I highly recommend reading the integration guide at the very least).

  • edited August 2016

    Well I already tried that and also read full documentation before.

    and again just updated code but it's not working.

     // output unit
        self.output = [[AEAudioUnitOutput alloc] initWithRenderer:renderer];
    
        // audiobus code
        self.audiobusController = [[ABAudiobusController alloc] initWithApiKey:ABKey];
    
        // Create sender port, to send audio
        ABSenderPort *sender = [[ABSenderPort alloc] initWithName:@"xmeinc:Sender"
                                                   title:@"sender"
                               audioComponentDescription:(AudioComponentDescription) {
                                   .componentType = kAudioUnitType_RemoteGenerator,
                                   .componentSubType = 'bnks',
                                   .componentManufacturer = 'xmei' } audioUnit:self.output.audioUnit];
    
        sender.clientFormat = AEAudioDescription;
    
        [_audiobusController addSenderPort:sender];
    

    strange thing is it's only working on iPad.

    I also tried following 2 things alternatively but same behavior.

    // output unit
        self.output = [[AEAudioUnitOutput alloc] initWithRenderer:renderer];
    
        // audiobus code
        self.audiobusController = [[ABAudiobusController alloc] initWithApiKey:ABKey];
    
        // Create sender port, to send audio
        ABSenderPort *sender = [[ABSenderPort alloc] initWithName:@"xmeinc:Sender"
                                                   title:@"sender"
                               audioComponentDescription:(AudioComponentDescription) {
                                   .componentType = kAudioUnitType_RemoteGenerator,
                                   .componentSubType = 'bnks',
                                   .componentManufacturer = 'xmei' }];
    
        sender.clientFormat = AEAudioDescription;
    
        [_audiobusController addSenderPort:sender];
    

    and

    // output unit
        self.output = [[AEAudioUnitOutput alloc] initWithRenderer:renderer];
    
        // audiobus code
        self.audiobusController = [[ABAudiobusController alloc] initWithApiKey:ABKey];
    
        // Create sender port, to send audio
        ABSenderPort *sender = [[ABSenderPort alloc] initWithName:@"xmeinc:Sender"
                                                   title:@"sender"
                               audioComponentDescription:(AudioComponentDescription) {
                                   .componentType = kAudioUnitType_RemoteGenerator,
                                   .componentSubType = 'bnks',
                                   .componentManufacturer = 'xmei' } audioUnit:self.output.audioUnit];
    
        [_audiobusController addSenderPort:sender];
    
  • Ah, I think I know what's happening - the output unit needs to be setup before you fetch its audio unit, so you're effectively passing NULL as the audio unit to ABSenderPort. I've just added some commits to the repository which will automatically set up the audio unit if you try to fetch it before it's setup. Grab those and try again - or just add:

    [self.output setup:NULL];
    

    before your ABSenderPort initialisation.

    I just tried it on my iPhone 6S Plus and that's working.

  • Thanks for reply friend.

    It is working on iPhone now but it seems to be little distorted when record and playback in receiver app. it is loud and distorted.

    again no issue in iPad but just issue with iPhone.

  • Here is my new code :

    // output unit
        self.output = [[AEAudioUnitOutput alloc] initWithRenderer:renderer];
    
        [self.output setup:NULL];
    
        // audiobus code
        self.audiobusController = [[ABAudiobusController alloc] initWithApiKey:ABKey];
    
        // Create sender port, to send audio
        ABSenderPort *sender = [[ABSenderPort alloc] initWithName:@"xmeinc:Sender"
                                                   title:@"sender"
                               audioComponentDescription:(AudioComponentDescription) {
                                   .componentType = kAudioUnitType_RemoteGenerator,
                                   .componentSubType = 'bnks',
                                   .componentManufacturer = 'xmei' } audioUnit:self.output.audioUnit];
    
        [_audiobusController addSenderPort:sender];
    
     renderer.block = ^(const AERenderContext * _Nonnull context) {
    
            __unsafe_unretained AEMixerModule * aggregator
            = (__bridge AEMixerModule *)AEManagedValueGetValue(sampleValue);
    
            // Run varispeed unit, which will run its own render loop, above
            AEModuleProcess(aggregator, context);
            AERenderContextOutput(context, 1);        
        };
    
  • What happens if you put this code in the TAAE sample app? I integrated Audiobus there to check, and it's working well

Sign In or Register to comment.