kino-alac

kino-alac

Pure Crystal ALAC packet decoder with no shard dependencies.

require "kino-alac"

decoder = Kino::ALAC::Decoder.new(config) # 24-byte ALACSpecificConfig
pcm = decoder.decode(packet)            # interleaved Float32

Supports mono/stereo compressed and escape packets, Rice coding and zero runs, linear prediction, stereo decorrelation and shifted low bytes. Accepts 16/20/24/32-bit configurations with residual widths up to 32 bits. Float32 output cannot retain all precision of 32-bit integer audio. Multichannel decoding and encoding are unsupported.

For M4A, combine with kino-mp4: take codec_config from its ALAC audio track and pass each sample's data to this decoder. Container demuxing and seeking remain the caller's responsibility. No MP4 or other codec dependency is needed when decoding packets from another source.

Run crystal spec. Checked-in packet/config/PCM fixtures were extracted from the FFmpeg 8.1 M4A interoperability fixtures in Kino; tests compare every output sample without invoking FFmpeg.

Algorithm adapted from Apple's ALAC reference decoder, Copyright (c) 2011 Apple Inc., licensed under Apache-2.0: https://github.com/macosforge/alac/tree/master/codec See licenses/Apache-2.0.txt.

Repository

kino-alac

Owner
Statistic
  • 0
  • 0
  • 0
  • 1
  • 0
  • about 1 hour ago
  • December 4, 2026
License

MIT License

Links
Synced at

Fri, 04 Dec 2026 15:48:41 GMT

Languages