Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8451429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:14:17+00:00 2026-06-10T11:14:17+00:00

I am able to join multiple CAF files with encoded PCM audio inside. First

  • 0

I am able to join multiple CAF files with encoded PCM audio inside. First I read data format from one of CAF files.

UInt32 size = sizeof(srcFormatDescription);
        status = AudioFileGetProperty(srcAudioFile, kAudioFilePropertyDataFormat, &size, &srcFormatDescription);

for PCM data format looks like this

[Line 7697] mSampleRate: 44100.000000
[Line 7698] mFormatID: 1819304813d
[Line 7699] mFormatFlags: 12d
[Line 7700] mBytesPerPacket: 2d
[Line 7701] mFramesPerPacket: 1d
[Line 7702] mBytesPerFrame: 2d
[Line 7703] mChannelsPerFrame: 1d
[Line 7704] mBitsPerChannel: 16d
[Line 7705] mReserved: 0d

Then i set data format for destination file, which will contain all CAF’s.

destFormatDescription = srcFormatDescription;
status = AudioFileCreateWithURL(dest, kAudioFileCAFType, &destFormatDescription, kAudioFileFlags_EraseFile, &destAudioFile);

In next step I read data from CAF

status = AudioFileReadBytes(srcAudioFile,
                                    FALSE,
                                    currentStartForReading,
                                    &bytesNumberToRead,
                                    buffer);

and write it to destAudioFile

status = AudioFileWriteBytes(destAudioFile,
                                     FALSE,
                                     writePosition,
                                     &bytesNumberToWrite,
                                     buffer);

this steps are done in a loop. It works great.
However I have big problem, now I try to do the same steps for CAF files, which contains data in ALAC format. It doesn’t work. AudioFileWriteBytes return error operation not supported.

for ALAC data format looks like this

[Line 7697] mSampleRate: 44100.000000
[Line 7698] mFormatID: 1634492771d
[Line 7699] mFormatFlags: 1d
[Line 7700] mBytesPerPacket: 0d
[Line 7701] mFramesPerPacket: 4096d
[Line 7702] mBytesPerFrame: 0d
[Line 7703] mChannelsPerFrame: 1d
[Line 7704] mBitsPerChannel: 0d
[Line 7705] mReserved: 0d

Does anybody know how can I join multiple CAF files with Apple Lossless data inside?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:14:18+00:00Added an answer on June 10, 2026 at 11:14 am

    I am able to join multiple CAF files with encoded PCM audio inside. First I read data format from one of CAF files.

    If the ASBDs match, then your audio file would be correct. However, if the input file’s sample formats do not match, then your data would be corrupt. This is because each CAF file defines exactly one sample data chunk, and one audio description chunk.

    Therefore, it would be an error to attempt to append sample data of multiple formats into one audio data chunk. (whether that is or is not what you are attempting is not specified)

    Furthermore, compressed formats have an additional field which must be set – that is the magic cookie. All cookies would have to be equal (this is an opaque data representation, btw).

    Finally, the proper way to write compressed data is using Packet Table Chunks. The VBR/VFR formats must specify exactly one Packet Table Chunk.

    Does anybody know how can I join multiple CAF files with Apple Lossless data inside?

    What this all means: There will be a high failure rate using the approach you have chosen in the case of ALAC. As well, there’s a lot that goes into keeping these files and their chunks correctly synchronized with all the Packet detail that is involved.

    So, let’s approach this from another angle:

    • use ExtAudioFileCreateWithURL to create a new ALAC file
    • use ExtAudioFileOpenURL to open your input files
    • determine a common sample format from your input files
    • use ExtAudioFileSetProperty + kExtAudioFileProperty_ClientDataFormat to specify the common PCM format
    • Configure the destination/ALAC file’s convertor to expect the common PCM format you have chosen.
    • read an input file’s sample data, writing to the destination
    • repeat for remaining files
    • close all files

    That should be it (but it will probably require a few hundred lines of code, if you are dealing with the raw AudioFile APIs).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to be able to use multiple keys to join two tables. Is
I'm working on a query where I pull data from multiple tables using left
This is a follow-up question to Merging multiple encoded polylines into one encoded polyline
I've got a bunch of .coffee files that I need to join into one
In my case, I'm deleting from multiple tables using LEFT JOIN and need to
I have multiple URLs that returns zip files. Most of the files, I'm able
I am trying to join two tables; the purpose being able to search and
Not able to download artifacts from central maven repository. <mirrors> <!-- mirror | Specifies
Not able to store all binary data values into sqlite3 table using QT. For
I need to be able to search through multiple 2D arrays and search the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.