I feel a bit ridiculous, but ten minutes after posting to you all, it's working for me! I sorted it out shortly after I hit send. I reread my code carefully, and I had *lots* of things wrong.
For starters, I misunderstood how to set up the Client ASBD for non-interleaved PCM audio. What is working fine for me now is: bytes_per_packet: Per *single* buffer frames_per_packet: Per *single* buffer bytes_per_frame: Per *single* buffer channels_per_frame: Of *all* buffers bits_per_channel: Per *single* buffer Another change I made in the version that is okay is that I also am no longer storing my UnsafeMutableAudioBufferListPointer (or rather its memory) as an AudioBufferList. I just pass it in as is to ExtAudioFileWrite, which takes a pointer anyways. I guess the cast was shortening its length. The other errors are not interesting for anyone. Anyways, I'm quite happy the code is working. Cheers! On Sun, Aug 16, 2015 at 5:42 PM, Charles Constant <[email protected]> wrote: > Hello CoreAudio people, > > My app has a bunch of PCM float vectors in memory. I want to write them to > disk as a single uncompressed file (CAF, AIFF, or Wave file). The output > file on disk should be interleaved. Do I absolutely have to do this > interleaving on my end? > > My code to attempt this is currently failing with "fmt?" when I try to set > the Client ASBD. I'm pretty sure the flags are correct though [Float, > Packed, NonInterleaved], and I filled out the rest of the ASBD for the > total number of vectors. > > I have two theories: > a) the only PCM support for writing ExtAudioFileWrite is for you to > interleave vectors as a single mBuffer? > b) it is supported, but only if you set a valid AudioChannelLayout? > > Does anyone know if it's possible? > > Thanks, > > Charles > > PS: > As an aside, here's a snippet of how to create an AudioBufferList in Swift > containing more than one mBuffer. Maybe it will save the next guy the pain: > > var abl_ptr = AudioBufferList.allocate( maximumBuffers: buffers.count ) > defer { > free( abl_ptr.unsafeMutablePointer ) > } > for i in 0 ..< buffers.count { > abl_ptr[i] = buffers[i] > } > let abl = abl_ptr.unsafePointer.memory > >
_______________________________________________ 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]
