public void PerformTest()
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Title  = "Open Sound File";
            ofd.Filter = "ADPCM Wave File (*.wav)|*.wav";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Title  = "Save Sound File";
                sfd.Filter = "Wave File (*.wav)|*.wav";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    Stream    input   = ofd.OpenFile();
                    XboxADPCM encoded = new XboxADPCM(input);
                    PCM       decoded = new PCM(encoded.ChannelCount, encoded.SampleRate);
                    decoded.SetRawData(encoded.GetRaw());
                    Stream output = File.OpenWrite(sfd.FileName);
                    decoded.Write(output);
                    output.Close();
                    input.Close();
                }
            }
        }
Beispiel #2
0
        private static byte[] DecodeSamples(byte[] binary, short encoding, WaveFormat format)
        {
            switch (encoding)
            {
            case 0: // none
                PCM pcm = new PCM(format.Channels, format.SamplesPerSecond);
                pcm.SetEncodedData(binary);
                return(pcm.GetRaw());

            case 1: // xbox adpcm
                XboxADPCM xbadpcm = new XboxADPCM(format.Channels, format.SamplesPerSecond);
                xbadpcm.SetEncodedData(binary);
                return(xbadpcm.GetRaw());

            case 2: // ima adpcm
                throw new HaloException("The sound encoding 'ima adpcm' is not yet supported.");

            case 3: // ogg vorbis
                throw new HaloException("The sound encoding 'ogg vorbis' is not yet supported.");

            default:
                throw new HaloException("The sound encoding {0} does not exist.", encoding);
            }
        }