• 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: Do I Need to Set the ASBD of a FilePlayer Audio Unit?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Do I Need to Set the ASBD of a FilePlayer Audio Unit?


  • Subject: Re: Do I Need to Set the ASBD of a FilePlayer Audio Unit?
  • From: Tim Kemp <email@hidden>
  • Date: Tue, 25 Dec 2012 08:07:35 -0500

You don't need to set the output stream on the file player - or on the mixer input. You should update the fp's output ASBD with the number of channels and your sample rate if you need it, but leave it alone otherwise. The mixer unit will get its stream format from the input node (ie the file player) and if you try to set it, it will fail silently. In short, modify the file player's ASBD and let it negotiate a stream format with the mixer.

// Get the ASBD from the player unit, update with channels
    UInt32 playerASBDsize;
    checkError(AudioUnitGetProperty(_playerUnit,
                                    kAudioUnitProperty_StreamFormat,
                                    kAudioUnitScope_Output,
                                    BUS_PLAYER_OUTPUT,
                                    &_playerASBD,
                                    &playerASBDsize),
               "AudioUnitSetProperty failed: getting stream format from the player unit", false);
    _playerASBD.mChannelsPerFrame = 2;
    _playerASBD.mSampleRate = 44100.0;
    checkError(AudioUnitSetProperty(_playerUnit,
                                    kAudioUnitProperty_StreamFormat,
                                    kAudioUnitScope_Output,
                                    BUS_PLAYER_OUTPUT,
                                    &_playerASBD,
                                    sizeof(_playerASBD)),
               "AudioUnitSetProperty failed: setting channels & sample rate to player output ASBD", false);

That's all I do with stream formats for a file player hooked to a multichannel mixer. (I do set mixer output, RIO input etc.)

Hope that helps.

On 24 Dec 2012, at 23:36, n ketter wrote:

I've specified and instantiated two Audio Units: a multichannel mixer unit and a generator of subtype AudioFilePlayer.

I would have thought I needed to set the ASBD of the filePlayer's output to match the ASBD I set for the mixer input. However when I attempt to set the filePlayer's output I get a kAudioUnitErr_FormatNotSupported (-10868) error.

Here's the stream format I set on the mixer input (successfully) and am also trying to set on the filePlayer (it's the monostream format copied from Apple's "mixerhost" sample project):

Sample Rate:              44100
Format ID:                 lpcm
Format Flags:                 C
Bytes per Packet:             2
Frames per Packet:            1
Bytes per Frame:              2
Channels per Frame:           1
Bits per Channel:            16

In the course of troubleshooting this I queried the filePlayer AU for the format it is 'natively' set to. This is what's returned:

Sample Rate:              44100
Format ID:                 lpcm
Format Flags:                29
Bytes per Packet:             4
Frames per Packet:            1
Bytes per Frame:              4
Channels per Frame:           2
Bits per Channel:            32

All the example code I've found sends the output of the filePlayer unit to an effect unit and set the filePlayer's output to match the ASBD set for the effect unit. Given I have no effect unit it seems like setting the filePlayer's output to the mixer input's ASBD would be the correct - and required - thing to do.

Clearly I'm missing something. 

Thanks in advance!


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: 
 >Do I Need to Set the ASBD of a FilePlayer Audio Unit? (From: n ketter <email@hidden>)

  • Prev by Date: [no subject]
  • Next by Date: driver audio object id
  • Previous by thread: Do I Need to Set the ASBD of a FilePlayer Audio Unit?
  • Next by thread: [no subject]
  • Index(es):
    • Date
    • Thread