private bool DetectWindowsN()
 {
     try
     {
         var dmoResampler = new DmoResampler();
         dmoResampler.Dispose();
         return(false);
     }
     catch (Exception)
     {
         return(true);
     }
 }
 private bool DetectWindowsN()
 {
     try
     {
         var dmoResampler = new DmoResampler();
         dmoResampler.Dispose();
         return(false);
     }
     catch (Exception)
     {
         Logger.Warn("Windows N Detected - using inbuilt resampler");
         return(true);
     }
 }
Пример #3
0
        private void output_to_file()
        {
            streamReader = new WaveFileReader(textOutputFile.Text);
            Console.WriteLine(streamReader.WaveFormat);
            resampler = new DmoResampler(streamReader, sampleRate);

            //resampler = new DmoResampler(streamReader, new WaveFormat(sampleRate, 16, capture.WaveFormat.Channels));
            //resampler.WriteToFile("C:\\Users\\Witty-me\\Desktop\\tmp.wav");

            //streamReader.Dispose();
            //resampler.WriteToFile(textOutputFile.Text);

            //resampler.Dispose();
            //streamReader = new WaveFileReader("C:\\Users\\Witty-me\\Desktop\\tmp");
            //streamReader = new WaveFileReader(textOutputFile.Text);
            //Pcm16BitToSample con = new Pcm16BitToSample(streamReader);



            //Console.WriteLine(streamReader.WaveFormat);
            //Console.WriteLine(resampler.BaseStream.WaveFormat);
            //Pcm16BitToSample con = new Pcm16BitToSample(resampler.BaseStream);

            /*byte[] array = new byte[resampler.Length];
             * //con.Read(array, 0, (int)con.Length);
             * resampler.Read(array, 0, (int)resampler.Length);
             * resampler.Dispose();*/

            byte[] array = new byte[bufsize];

            //Console.WriteLine(resampler.BaseStream.Length);
            //Console.WriteLine(streamReader.Length);
            //Console.WriteLine(resampler.Length);
            //streamReader.Read(array, 0, (int)streamReader.Length);
            //streamReader.Dispose();
            sw = new StreamWriter(textOutputFile.Text.Insert
                                      (textOutputFile.Text.Length - 4, "_resample"));

            while (true)
            {
                int rdcnt = resampler.Read(array, 0, bufsize);
                if (rdcnt <= 0)
                {
                    break;
                }
                for (int i = 0; i < array.Length; i += 8)
                {
                    sw.WriteLine(BitConverter.ToSingle(array, i)
                                 + "\t"
                                 + BitConverter.ToSingle(array, i + 4));
                }
            }
            resampler.Dispose();
            streamReader.Dispose();
            sw.Dispose();


            streamReader = new WaveFileReader(textOutputFile.Text);
            array        = new byte[streamReader.Length];
            streamReader.Read(array, 0, (int)streamReader.Length);
            streamReader.Dispose();
            sw = new StreamWriter(textOutputFile.Text);
            for (int i = 0; i < array.Length; i += 8)
            {
                sw.WriteLine(BitConverter.ToSingle(array, i)
                             + "\t"
                             + BitConverter.ToSingle(array, i + 4));
            }
            sw.Dispose();
        }
Пример #4
0
        //IDisposable

        /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
        public void Dispose()
        {
            dmo.Dispose();
        }