コード例 #1
0
        static void DecodeStreamAdpcm(aBinaryReader reader, aBinaryWriter writer, int sampleCount)
        {
            var left = new short[16];
            int left_last = 0, left_penult = 0;

            var right = new short[16];
            int right_last = 0, right_penult = 0;

            for (var i = 0; i < sampleCount; i += 16)
            {
                Waveform.Adpcm4toPcm16(reader.Read8s(9), left, ref left_last, ref left_penult);
                Waveform.Adpcm4toPcm16(reader.Read8s(9), right, ref right_last, ref right_penult);

                for (var j = 0; j < 16 && (i + j) < sampleCount; ++j)
                {
                    writer.WriteS16(left[j]);
                    writer.WriteS16(right[j]);
                }

                if ((i % cMessageInterval) == 0 || (i + 16) >= sampleCount)
                {
                    mareep.WriteMessage("\rSamples encoded: {0}/{1}", System.Math.Min((i + 16), sampleCount), sampleCount);
                }
            }
        }