static IntPtr GetMagicCookie([NotNull] AudioFile audioFile, [NotNull] AudioConverter converter)
        {
            audioFile.GetPropertyInfo(AudioFilePropertyId.MagicCookieData, out var dataSize, out _);
            var cookie = audioFile.GetProperty(AudioFilePropertyId.MagicCookieData, dataSize);

            converter.SetProperty(AudioConverterPropertyId.DecompressionMagicCookie, dataSize, cookie);
            return(cookie);
        }
        public void Initialize(Stream stream)
        {
            _audioFile = new AudioFile(AudioFileType.M4A, stream);

            var inputDescription = _audioFile.GetProperty <AudioStreamBasicDescription>(AudioFilePropertyId.DataFormat);

            if (inputDescription.AudioFormat != AudioFormat.AppleLossless)
            {
                throw new AudioUnsupportedException("The stream is not in Apple Lossless format.");
            }

            _outputDescription = GetOutputDescription(inputDescription);

            _converter   = new AudioConverter(ref inputDescription, ref _outputDescription, _audioFile);
            _magicCookie = GetMagicCookie(_audioFile, _converter);
        }