Here is a helper function I use to get ASBDs. I use floats because they
work with the accelerate framework and they are easier on the eye. When
setting the kExtAudioFileProperty_ClientDataFormat property on your
extAudioFileRef, you should use an ASBD for interleaved, and when setting
ASBDs for audio units you should not use interleaved.  So in your case i
would use this function to get ASBDs like this:

AudioStreamBasicDescription extAudioClientASBD = asbdWithInfo(1,2,1);
AudioStreamBasicDescription mixerInputASBD = asbdWithInfo(1,2,0);

AudioStreamBasicDescription asbdWithInfo(Boolean isFloat,int
numberOfChannels,Boolean interleavedIfStereo){

    AudioStreamBasicDescription asbd = {0};

    int sampleSize          = isFloat ? sizeof(float) : sizeof(SInt16);

    asbd.mChannelsPerFrame  = (numberOfChannels == 1) ? 1 : 2;

    asbd.mBitsPerChannel    = 8 * sampleSize;

    asbd.mFramesPerPacket   = 1;

    asbd.mSampleRate        = 44100.0;

    asbd.mBytesPerFrame     = interleavedIfStereo ? sampleSize * asbd.
mChannelsPerFrame : sampleSize;

    asbd.mBytesPerPacket    = asbd.mBytesPerFrame;

    asbd.mReserved          = 0;

    asbd.mFormatID          = kAudioFormatLinearPCM;

    if (isFloat) {

        asbd.mFormatFlags = kAudioFormatFlagIsFloat;

        if (interleavedIfStereo) {

            if (numberOfChannels == 1) {

                asbd.mFormatFlags = asbd.mFormatFlags |
kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked |
kAudioFormatFlagIsNonInterleaved;

            }

        }

        else{

            asbd.mFormatFlags = asbd.mFormatFlags |
kAudioFormatFlagIsNonInterleaved | kAudioFormatFlagIsPacked ;

        }

    }

    else{

        asbd.mFormatFlags = kAudioFormatFlagIsSignedInteger |
kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked;

        if (!interleavedIfStereo) {

            if (numberOfChannels > 1) {

                asbd.mFormatFlags = asbd.mFormatFlags |
kAudioFormatFlagIsNonInterleaved;

            }



        }

    }

    return asbd;

}

On Mon, Jan 12, 2015 at 8:49 AM, Robert Carroll <[email protected]> wrote:

> Can I ask what data type you are using for your samples?
>
> I replaced all references to AudioUnitSampleType with float this morning.
> That gets me correct playback on iOS8, but on iOS7 I get overloaded noise.
> On iOS7 AudioUnitSampleType was working, as was SInt32.
>
> I’m running this on 2 iPads with the two iOS’s. Testing the arch with #if
> __LP64__ shows 32-bit for both devices. I can try switching to a fixed
> width int as per Doug Wyatt;s suggestion. My preference is to find a
> structure that will run on both iOS’s.
>
> rob
>
>
> On Jan 11, 2015, at 8:31 PM, Dave O'Neill <[email protected]> wrote:
>
> Are there any other audio units in your chain?  Be sure to set the output
> ASBD of each audio unit to the input ASBD of the audio unit it is connected
> to (downstream).  Just as a troubleshooting technique you can try putting
> AUConverters between various audio units to see if that fixes things.
> Maybe you could post your ASBD and we can spot an issue.  Instead of using 
> AudioUnitSampleType
> just find out what it is typedef'd to and substitute it with that ( you can
> just highlight it and "jump to definition" in Xcode).  All of the iOS8
> specific issues I've had were all traced back 32-64 bit issues. Here is a
> handy guide that points out some common gotchas:
> https://developer.apple.com/library/ios/documentation/General/Conceptual/CocoaTouch64BitGuide/ConvertingYourAppto64-Bit/ConvertingYourAppto64-Bit.html#//apple_ref/doc/uid/TP40013501-CH3-SW1
>
>
> On Sun, Jan 11, 2015 at 5:00 PM, Matt Hart <[email protected]> wrote:
>
>> I haven't tested with m4a lossless, but I have played about 14 or so
>> lossless wav simultaneously as well as that many m4a compressed files. They
>> are all buffered though.
>>
>> On Jan 11, 2015, at 7:08 PM, Robert Carroll <[email protected]> wrote:
>>
>> Hi.
>>
>> Thanks. I am doing that with the same function call.
>>
>> Further investigation is pointing to some other issue. My code that reads
>> the ExtAudioFile objects is playing single m4a files, but not multiple
>> files set up on different mixer buses. I was testing with a single A440.if
>> file then with 3 m4a lossless files for C4, E4, G4 which should play
>> simultaneously.
>>
>> On iOS 7 it works, on iOS 8 I get a brief burst of vicious white noise.
>>
>> I’m inclined to think this is back to the storage type for the sample
>> data. Since, I haven’t found an answer to a replacement for the
>> AudioUnitSampleType on iOS, I had reverted my code to using that type.
>>
>> rob
>>
>> On Jan 11, 2015, at 6:25 PM, Matt Hart <[email protected]> wrote:
>>
>> I use this with iOS 8 and 7 without any issues. Did you set the expected
>> client data format onto the audio file property?
>>
>> status = ExtAudioFileSetProperty(_audioFile,
>> kExtAudioFileProperty_ClientDataFormat, sizeof(_targetAudioDescription),
>> &_targetAudioDescription);
>>
>>
>> On Jan 11, 2015, at 1:56 PM, Robert Carroll <[email protected]> wrote:
>>
>> I am attempting to narrow down the options why my audiograph code is
>> failing on iOS 8.
>>
>> I am using ExtAudioFileRead to extract data from applelossless source
>> files and load structs set up for this purpose.
>> The buffers and audioData parts of the struct are typed as
>> AudioUnitSampleType.
>>
>> All of this works as it should on iOS’s up to 7.x. Running on iOS 8.1.2 I
>> can play aiff source files with this code but get distortion if I load the
>> m4a (lossless) files.
>>
>> What changed in iOS 8 with extaudiofile that would account for this issue?
>>
>> thanks
>>
>> rob
>>
>>
>> Robert Carroll
>> RSM Records
>> Toronto
>> http://www.rsmrecords.com
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Coreaudio-api mailing list      ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/coreaudio-api/matt%40matthart.com
>>
>> This email sent to [email protected]
>>
>>
>>
>>
>>
>>  _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Coreaudio-api mailing list      ([email protected])
>> Help/Unsubscribe/Update your Subscription:
>>
>> https://lists.apple.com/mailman/options/coreaudio-api/oneill707%40gmail.com
>>
>> This email sent to [email protected]
>>
>
>
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to