• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: iPad USB Audio Output
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iPad USB Audio Output


  • Subject: Re: iPad USB Audio Output
  • From: Stuart MacLean <email@hidden>
  • Date: Fri, 23 Sep 2011 12:01:26 +0100
  • Organization: Black Omega

Hi Aran

It is the case that for whatever reason using the AudioQueue API allows me to have audio playback via USB. The reason for trying out AudioQueue came from this discussion forum

http://www.computeraudiophile.com/content/iOS-2496-Output-Possible

where Dan Leehr talks about using AudioQueue.

Before trying this solution I had pretty much exhausted all options trying to get playback via AudioUnits for which I had no success. So I had tried different LPCM stream formats, using different Audio Session configurations and any number of AudioUnit property flags that seemed plausable or might make a difference.

So for whatever reason why AudioQueue works and AudioUnit doesn't work I do not know but I would be really interested to know why. But at the end of the day I managed to get playback through USB using AudioQueue.

Cheers Stuart

On 23/09/2011 01:45, Aran Mulholland wrote:
You said "So to get USB Audio working through a DAC the AudioQueue API
has to employed."

I really doubt this. AudioQueue probably uses AudioUnits under the
surface anyway.

On Thu, Sep 22, 2011 at 6:19 PM, Stuart MacLean<email@hidden> wrote:
Hi

I managed to have success making the USB Audio work from the iPad. Instead
of using the AudioUnit API to play sound I used the AudioQueue API for
playback. So to get USB Audio working through a DAC the AudioQueue API has
to employed.

Cheers for the help.

Stuart

On 21/09/2011 03:07, Patrick Shirkey wrote:
Stuart,

This is more of an iOS issue, and probably belongs in the iOS Dev Center
forums.

I will briefly say, though, that my guess is that either your Duet 2
is acting as a plain old lineout output route or it is interacting
with the iPod app in a manner that you will not be able to capitalize
on. I don't have a Duet 2, though, so I can't say for sure.

I agree it does sound like different functionality for the ipod and ipad.





On Tue, Sep 20, 2011 at 5:16 AM, Stuart MacLean<email@hidden>
wrote:
Hi

I am trying to support the ability to playback audio through an external
DAC
connected to an iPad via USB
using the Camera Connector Kit employing CoreAudio. However I have not
had
any luck in getting any audio
output from my app to my external DAC. My specific setup is

iPad ->    Camera Connector Kit ->    USB Hub ->    Apogee Duet 2 ->
  Amplifier

I know this setup works as I am able to successfully play music through
the
iPod App to my external DAC.

I have attached the code I am using to configure the AudioSession and
open
RemoteIO Audio Unit for rendering the audio output below.

Now I have tried a number of different types of stream formats (but
tried to
keep it to 44.1kHz at 16bit PCM sample) and I see the
audio route change to 'USB' when connected. But I have not been able to
get
any playback through the external DAC.

So I was wondering if anyone can help me to get this working?

With kind regards

Stuart MacLean


//-------------------------------------------------------------------------------------------

- (bool) openAudio
{
    OSStatus err;
    AudioComponent comp;
    AudioComponentDescription ioUnitDescription;

    ioUnitDescription.componentType = kAudioUnitType_Output;
    ioUnitDescription.componentSubType = kAudioUnitSubType_RemoteIO;
    ioUnitDescription.componentManufacturer =
kAudioUnitManufacturer_Apple;
    ioUnitDescription.componentFlags = 0;
    ioUnitDescription.componentFlagsMask = 0;

    comp = AudioComponentFindNext(0,&ioUnitDescription);
    if(comp==0)
        return false;
    err = AudioComponentInstanceNew(comp,&m_audioOutputUnit);
    if(err!oErr)
        return false;

    UInt32 enableIO = 1;
    err =

AudioUnitSetProperty(m_audioOutputUnit,kAudioOutputUnitProperty_EnableIO,kAudioUnitScope_Output,0,&enableIO,sizeof(enableIO));
    if(err!oErr)
        return false;

    AudioStreamBasicDescription streamFormat;
    memset(&streamFormat,0,sizeof(AudioStreamBasicDescription));
    streamFormat.mFormatID = kAudioFormatLinearPCM;
    streamFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger |
kAudioFormatFlagIsPacked;
    streamFormat.mSampleRate = 44100.0;
    streamFormat.mFramesPerPacket = 1;
    streamFormat.mBitsPerChannel = 16;
    streamFormat.mBytesPerPacket = 2;
    streamFormat.mBytesPerFrame = 2;
    streamFormat.mChannelsPerFrame = 1;

    err =

AudioUnitSetProperty(m_audioOutputUnit,kAudioUnitProperty_StreamFormat,kAudioUnitScope_Input,0,&streamFormat,sizeof(AudioStreamBasicDescription));
    if(err!oErr)
        return false;

    AURenderCallbackStruct renderCallback;
    memset(&renderCallback,0,sizeof(AURenderCallbackStruct));
    renderCallback.inputProc = OmegaAudioCallbackIOProc;
    renderCallback.inputProcRefCon = (void *)(self);

    err =

AudioUnitSetProperty(m_audioOutputUnit,kAudioUnitProperty_SetRenderCallback,kAudioUnitScope_Global,0,&renderCallback,sizeof(renderCallback));
    if(err!oErr)
        return false;

    err = AudioUnitInitialize(m_audioOutputUnit);
    if(err!oErr)
        return false;

    err = AudioOutputUnitStart(m_audioOutputUnit);
    if(err!oErr)
        return false;

    return true;
}


//-------------------------------------------------------------------------------------------

- (void) setupAudioSession
{
    AVAudioSession *aSession = [AVAudioSession sharedInstance];

    [aSession setDelegate:self];

    NSError *audioSessionError = nil;
    [aSession setCategory:AVAudioSessionCategoryPlayback
error:&audioSessionError];
    if(audioSessionError!il)
    {
        NSLog(@"Error setting audio session category.");
        return;
    }

    [aSession setPreferredHardwareSampleRate:44100.0
error:&audioSessionError];
    if(audioSessionError!il)
    {
        NSLog(@"Error setting preferred audio hardware sample rate.");
        return;
    }

    UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;


AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,sizeof(sessionCategory),&sessionCategory);

    UInt32 allowMixing = false;


AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers,sizeof(allowMixing),&allowMixing);

    [aSession setActive:YES error:&audioSessionError];
    if(audioSessionError!il)
    {
        NSLog(@"Error activating audio session during initial setup.");
        return;
    }



  AudioSessionAddPropertyListener(kAudioSessionProperty_AudioRouteChange,audioRouteChangeListenerCallback,(void*)self);
}


//-------------------------------------------------------------------------------------------

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

--
Patrick Shirkey
Boost Hardware Ltd
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Coreaudio-api mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >iPad USB Audio Output (From: Stuart MacLean <email@hidden>)
 >Re: iPad USB Audio Output (From: Bill Phillips <email@hidden>)
 >Re: iPad USB Audio Output (From: Patrick Shirkey <email@hidden>)
 >Re: iPad USB Audio Output (From: Stuart MacLean <email@hidden>)
 >Re: iPad USB Audio Output (From: Aran Mulholland <email@hidden>)

  • Prev by Date: AVAudioPLayer Loop Issue
  • Next by Date: ExtAudioFileRead ioNumberFrames parameter can only be adjusted downward?
  • Previous by thread: Re: iPad USB Audio Output
  • Next by thread: Aggregate device recording
  • Index(es):
    • Date
    • Thread