コード例 #1
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            sbyte[] tempBuf = new sbyte[count];

            // Decode samples into tempBuf.
            int retrievedBlocks;

            ApeNative.c_APEDecompress_GetData(Handle, tempBuf, count / BlockAlign, out retrievedBlocks);

            // Shift them over to the actual sample buffer for NAudio.
            Buffer.BlockCopy(tempBuf, 0, buffer, 0, tempBuf.Length);
            return(count);
        }
コード例 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="filename">Path to the APE file to read.</param>
        public ApeReader(string filename)
        {
            // Attempt to get a decoding instance.
            int ret;

            Handle = ApeNative.c_APEDecompress_Create(filename, out ret);
            if (ret != 0)
            {
                throw new ArgumentException("Unable to create a decoder.");
            }

            // Initialize the WaveFormat
            int sampleRate    = ApeNative.Decompress_GetInfoInt(Handle, ApeNative.DecompressInfo.SampleRate);
            int bitsPerSample = ApeNative.Decompress_GetInfoInt(Handle, ApeNative.DecompressInfo.BitsPerSample);
            int channels      = ApeNative.Decompress_GetInfoInt(Handle, ApeNative.DecompressInfo.Channels);

            this.waveFormat = new WaveFormat(sampleRate, bitsPerSample, channels);
        }
コード例 #3
0
 protected override void Dispose(bool disposing)
 {
     ApeNative.c_APEDecompress_Destroy(Handle);
     base.Dispose(disposing);
 }