erikd/libsndfile — Issue #4: New ALAC support doesn't report proper file length for "Apple Loops"
Author: cvanwinkle
Created: 2012-03-06 18:42:59+00:00
State: open

# VERSION:
libsndfile-1.0.26pre2 (supplied by ErikD)

# PLATFORM:
32-bit libsndfile on Windows 7 x64

# DESCRIPTION:
Apple ships many 'alac'-encoded CAF files with their video products for stock sound effects and stock loops. Many of the loops that came with Apple Soundtrack Pro and Apple Logic (possibly also Apple Garageband) are in what is called "Apple Loops" format. I'm unfamiliar with what the distinction is, but Apple QuickTime doesn't decode the file length properly (sample file attached), whereas the newer API, Apple AudioToolbox, does correctly report a file length that accomodates seemless looping. When decoded through libsndfile-1.0.26pre2, there is noise at the end of the file (probably repeated buffer), whereas QuickTime has silence where libsndfile has noise. AudioToolbox, doesn't have this extra space at the end.

# REPRO STEPS:
1) Download the sample files from here: http://dl.dropbox.com/u/24880982/Apple_Loop_Test.zip
- Contents:
- The original 'alac' CAF file
- An AIFF showing the decode from libsndfile-1.0.26pre2
- An AIFF showing the decode from QuickTime on OSX 10.6.8
- An AIFF showing the decode from Apple AudioToolbox on OSX 10.6.8
2) Decode the file through libsndfile

# RESULT:
(see attached decode file)

# SNDFILE-INFO DUMP:
C:\Users\cvanwink\Desktop\libsndfile-1.0.26pre2-w32\bin>sndfile-info.exe "C:\Users\cvanwink\Desktop\CAF\Acoustic Drum Kit Groove 23.caf"

Version : libsndfile-1.0.26pre2

File : C:\Users\cvanwink\Desktop\CAF\Acoustic Drum Kit Groove 23.caf
Length : 399277
caff
Version : 1
Flags : 0
desc : 32
Sample rate : 44100.000
Format id : alac
Format flags : 1
Bytes / packet : 0
Frames / packet : 4096
Channels / frame : 2
Bits / channel : 0
kuki : 56
pakt : 112
uuid : 209 (skipped)
uuid : 432 (skipped)
info : 80 (skipped)
free : 3067
data : 392409 (should be 392413)
edit : 1
End

Sample Rate : 44100
Frames : 180224
Channels : 2
Format : 0x00180070
Sections : 1
Seekable : TRUE
Duration : 00:00:04.087
Signal Max : 32768 (0.00 dB)

# AFINFO DUMP (OSX terminal command that utilizes AudioToolbox):
nagra:Apple Loop Test cvanwink$ afinfo /Users/cvanwink/Desktop/Apple\ Loop\ Test/Acoustic\ Drum\ Kit\ Groove\ 23.caf
File: /Users/cvanwink/Desktop/Apple Loop Test/Acoustic Drum Kit Groove 23.caf
File type ID: caff
Data format: 2 ch, 44100 Hz, 'alac' (0x00000001) from 16-bit source, 4096 frames/packet
no channel layout.
estimated duration: 3.997755 sec
audio bytes: 392405
audio packets: 44
audio 176301 valid frames + 0 priming + 3923 remainder = 180224
bit rate: 768157 bits per second
packet size upper bound: 11667
audio data file offset: 4096
not optimized
source bit depth: I16
sound check:
approximate duration in seconds 3.998
copyright PowerFX Systems AB
comments SL00626
artist http://www.PowerFX.com

# EXPECTED:
File length and decoding like Apple AudioToolbox for these types of files