Example #1
0
        private WavData ReadWavFile(string path)
        {
            WavData wavData = new WavData();

            Console.WriteLine(rm.GetString("ReadFileStarted"), path);

            using (BinaryReader br1 = new BinaryReader(File.Open(path, FileMode.Open))) {
                if (!wavData.Read(br1))
                {
                    textBoxConsole.Text += string.Format(rm.GetString("ReadFileFailFormat"), path) + "\r\n";
                    return(null);
                }
                if (16 != wavData.BitsPerSample)
                {
                    textBoxConsole.Text += string.Format(rm.GetString("BitsPerSampleFailFormat"), path, wavData.BitsPerSample) + "\r\n";
                    return(null);
                }

                if (wavData.NumSamples < wavData.SampleRate * (double)numericStartDelayTorelance.Value + (double)numericAccumulateSeconds.Value)
                {
                    textBoxConsole.Text += string.Format(rm.GetString("WavFileTooShort"), path, (double)numericStartDelayTorelance.Value + (double)numericAccumulateSeconds.Value) + "\r\n";
                    return(null);
                }
            }

            return(wavData);
        }
Example #2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            int    startPos      = (int)numericStartPos.Value;
            int    outputSamples = (int)numericOutputSamples.Value;
            string path          = textBoxReadWavFile.Text;


            WavData wavData = new WavData();

            Console.WriteLine(rm.GetString("ReadFileStarted"), path);
            using (BinaryReader br1 = new BinaryReader(File.Open(path, FileMode.Open))) {
                if (!wavData.Read(br1))
                {
                    resultString = string.Format(rm.GetString("ReadFileFailFormat"), path) + "\r\n";
                    e.Result     = false;
                    return;
                }
                if (wavData.NumSamples < startPos + outputSamples)
                {
                    resultString = string.Format(rm.GetString("WavFileTooShort"), startPos + outputSamples, wavData.NumSamples, path) + "\r\n";
                    e.Result     = false;
                    return;
                }
            }

            Console.WriteLine(rm.GetString("WavFileSummary"), wavData.NumSamples);
            resultString += string.Format(rm.GetString("WavFileSummary"), wavData.NumSamples);
            double offset = (double)numericUpDownSubSampleOffset.Value;

            if (checkBoxCh0.Checked && !checkBoxCh1.Checked)
            {
                using (StreamWriter sw = new StreamWriter(textBoxWriteFile.Text)) {
                    for (int i = startPos; i < startPos + outputSamples; ++i)
                    {
                        sw.WriteLine("{0} {1}", i + offset, wavData.Sample16Get(0, i));
                    }
                }
            }
            else if (!checkBoxCh0.Checked && checkBoxCh1.Checked)
            {
                using (StreamWriter sw = new StreamWriter(textBoxWriteFile.Text)) {
                    for (int i = startPos; i < startPos + outputSamples; ++i)
                    {
                        sw.WriteLine("{0} {1}", i + offset, wavData.Sample16Get(1, i));
                    }
                }
            }
            else if (checkBoxCh0.Checked && checkBoxCh1.Checked)
            {
                using (StreamWriter sw = new StreamWriter(textBoxWriteFile.Text)) {
                    for (int i = startPos; i < startPos + outputSamples; ++i)
                    {
                        sw.WriteLine("{0} {1} {2}", i + offset, wavData.Sample16Get(0, i), wavData.Sample16Get(1, i));
                    }
                }
            }
            e.Result = true;
        }
Example #3
0
        static WavData ReadWavFromFile(string path)
        {
            WavData wavData = new WavData();

            using (BinaryReader br = new BinaryReader(File.Open(path, FileMode.Open))) {
                if (!wavData.Read(br))
                {
                    Console.WriteLine("E: Read failed. unknown format. {0}", path);
                    PrintUsageAndExit();
                }
            }
            return(wavData);
        }
Example #4
0
        private WavData ReadWavFile(string path)
        {
            WavData wavData = new WavData();

            Console.WriteLine(rm.GetString("ReadWavFileStarted"), path);

            using (BinaryReader br1 = new BinaryReader(File.Open(path, FileMode.Open))) {
                if (!wavData.Read(br1))
                {
                    return(null);
                }
                if (16 != wavData.BitsPerSample)
                {
                    return(null);
                }
            }

            return(wavData);
        }
Example #5
0
        private WavData ReadWavFile(string path)
        {
            WavData wavData = new WavData();

            Console.WriteLine(rm.GetString("ReadWavFileStarted"), path);

            using (BinaryReader br1 = new BinaryReader(File.Open(path, FileMode.Open))) {
                if (!wavData.Read(br1)) {
                    return null;
                }
                if (16 != wavData.BitsPerSample) {
                    return null;
                }
            }

            return wavData;
        }