//private static int Main(string[] args)
        //{
        //	var parameters = new RunParameters();
        //	parameters.TempoDelta = 50;
        //	parameters.PitchDelta = 5;
        //	parameters.Speech = true;
        //	var inBytes = System.IO.File.ReadAllBytes("Test.wav");
        //	var inStream = new MemoryStream(inBytes);
        //	var outStream = new MemoryStream();
        //	Process(inStream, outStream, parameters);
        //	var outBytes = outStream.ToArray();
        //	File.WriteAllBytes("Test_Pith_Tempo_ms.wav", outBytes);
        //	return 0;
        //}


        public static void Process(Stream inStream, Stream outStream, RunParameters parameters)
        {
            var soundTouch = new SoundTouch <TSampleType, TLongSampleType>();
            // Open Input file.
            var inFile = new WavInFile(inStream);

            //var inFile = new WavInFile("Test.wav");
            int bits       = inFile.GetNumBits();
            int samplerate = inFile.GetSampleRate();
            int channels   = inFile.GetNumChannels();
            // Open output file.
            var outFile = new WavOutFile(outStream, samplerate, bits, channels);

            //var outFile = new WavOutFile("Test_Pith_Tempo.wav", samplerate, bits, channels);
            if (parameters.DetectBpm)
            {
                // detect sound BPM (and adjust processing parameters
                //  accordingly if necessary)
                DetectBpm(inFile, parameters);
            }
            // Setup the 'SoundTouch' object for processing the sound
            int sampleRate = inFile.GetSampleRate();

            soundTouch.SetSampleRate(sampleRate);
            soundTouch.SetChannels(channels);
            soundTouch.SetTempoChange(parameters.TempoDelta);
            soundTouch.SetPitchSemiTones(parameters.PitchDelta);
            soundTouch.SetRateChange(parameters.RateDelta);
            soundTouch.SetSetting(SettingId.UseQuickseek, parameters.Quick);
            soundTouch.SetSetting(SettingId.UseAntiAliasFilter, (parameters.NoAntiAlias == 1) ? 0 : 1);
            if (parameters.Speech)
            {
                // use settings for speech processing
                soundTouch.SetSetting(SettingId.SequenceDurationMs, 40);
                soundTouch.SetSetting(SettingId.SeekwindowDurationMs, 15);
                soundTouch.SetSetting(SettingId.OverlapDurationMs, 8);
            }
            // Process the sound
            Process(soundTouch, inFile, outFile);
            if (inFile != null)
            {
                inFile.Dispose();
            }
            if (outFile != null)
            {
                outFile.Dispose();
            }
        }