Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS Core Audio : Converting between kAudioFormatFlagsCanonical and kAudioFormatFlagsAudioUnitCanonical
    primarykey
    data
    text
    <p>I need to convert between this format : </p> <pre><code> format.mSampleRate = 44100.0; format.mFormatID = kAudioFormatLinearPCM; format.mFormatFlags = kAudioFormatFlagsCanonical | kLinearPCMFormatFlagIsNonInterleaved; format.mBytesPerPacket = sizeof(AudioUnitSampleType); format.mFramesPerPacket = 1; format.mBytesPerFrame = sizeof(AudioUnitSampleType); format.mChannelsPerFrame = 2 ; format.mBitsPerChannel = sizeof(AudioUnitSampleType)*8; </code></pre> <p>and this format </p> <pre><code>format.mSampleRate = 44100.0; format.mFormatID = kAudioFormatLinearPCM; format.mFormatFlags = kAudioFormatFlagsAudioUnitCanonical; format.mBytesPerPacket = sizeof(AudioUnitSampleType); format.mFramesPerPacket = 1; format.mBytesPerFrame = sizeof(AudioUnitSampleType); format.mChannelsPerFrame = 2; format.mBitsPerChannel = sizeof(AudioUnitSampleType)*8; </code></pre> <p>within the confines of a audio render callback where there is the following code and buffer[] is in the 2nd format and array[] requires the 1st format. </p> <pre><code>for (k = 0; k &lt; channels; k++){ buffer = (AudioUnitSampleType *) ioData-&gt;mBuffers[k].mData; for(j=0; j &lt; samples; j++){ array[j] = buffer[j]; } } </code></pre> <p>I know you can use the Apple converter unit, but I cannot use the Apple Converter audio unit in my situation (there's a reason). </p> <p>Basically the only difference between the 2 formats the following flag for format.mFormatFlags (kAudioUnitSampleFractionBits &lt;&lt; kLinearPCMFormatFlagsSampleFractionShift). </p> <p>How can I convert buffer[] (containing data in the 2nd format) to array[] (containing data in the 1st format) and vice-versa? </p> <p>Thank you. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload