Beispiel #1
0
        private static void Wav2Vox(string inFile, string outFile, int samplesPerSec, bool isResample)
        {
            WaveReader wr     = new WaveReader(File.OpenRead(inFile));
            IntPtr     format = wr.ReadFormat();

            byte[] data = wr.ReadData();
            wr.Close();
            WaveFormat wf = AudioCompressionManager.GetWaveFormat(format);

            if (wf.wFormatTag != AudioCompressionManager.PcmFormatTag)//Decode if not PCM data
            {
                Decode2Pcm(ref format, ref data, ref wf);
            }
            if (isResample && wf.nSamplesPerSec != samplesPerSec)
            {
                Resample(ref format, ref data, ref wf, samplesPerSec);
            }
            BinaryWriter bw = new BinaryWriter(File.OpenWrite(outFile));
            BinaryReader br = new BinaryReader(new MemoryStream(data));

            Vox.Raw2Vox(br, bw, wf.wBitsPerSample);
            br.Close();
            bw.Close();
        }