Microsoft Windows dynamic-link library (DLL) implementation of the Apple Lossless Audio Codec (ALAC). Mirror copy of the ALAC encoder and decoder from http://alac.macosforge.org/ with changes for compiling as DLL in Visual Studio 2017.
.NET standard wrapper for the native dynamic-link library (DLL) implementation of the Apple Lossless Audio Codec (ALAC).
Use Git or SVN to download the source code using the web URL:
https://github.com/GiteKat/LibALAC.git Install the LibALAC NuGet package:
Install-Package LibALAC The following example show resampling, ALAC-encoding and decoding of a .mp3 input file using the excellent CSCore .NET Audio Library and LibALAC:
using CSCore; using CSCore.Codecs; using CSCore.DSP; using LibALAC; using System; using System.Linq; namespace Demo { class Program { const string FileName = @"C:\Music\demo.mp3"; const int SampleRate = 44100; const int Channels = 2; const int BitsPerSample = 16; const int FramesPerPacket = 4096; static void Main(string[] args) { DateTime startTime = DateTime.Now; Encoder encoder = new Encoder(SampleRate, Channels, BitsPerSample, FramesPerPacket); Decoder decoder = new Decoder(SampleRate, Channels, BitsPerSample, FramesPerPacket); using (IWaveSource waveSource = CodecFactory.Instance.GetCodec(FileName)) { WaveFormat waveFormat = new WaveFormatExtensible(SampleRate, BitsPerSample, Channels, AudioSubTypes.Pcm); using (DmoResampler resampler = new DmoResampler(waveSource, waveFormat)) { int read; byte[] buffer = new byte[encoder.BytesPerPacket]; while ((read = resampler.Read(buffer, 0, encoder.BytesPerPacket)) > 0) { byte[] encoded = encoder.Encode(buffer, read); byte[] decoded = decoder.Decode(encoded); if (read < buffer.Length) Array.Resize(ref buffer, read); if (!decoded.SequenceEqual(buffer)) throw new Exception("Encoding/Decoding error!"); } } } encoder.Dispose(); decoder.Dispose(); Console.WriteLine("Encoding/Decoding-Time: " + DateTime.Now.Subtract(startTime)); Console.ReadLine(); } } }All sources are available under the Apache license 2.0.