// Method that stops recording private void stop_Click(object sender, EventArgs e) { Recognition_Form form = new Recognition_Form(null, null, null); form.Show(); this.microResultLabel = form.ms_result; this.mfcc_result = form.mfcc_result; this.lpc_result = form.lpc_result; if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } openWav(wavSaveName); recording_timer.Stop(); wavSaveName = null; System.Threading.Tasks.Task.Run(() => { processWavFile(algo); }); // processWavFile(algo); }
public void FlushUpdatesHeaderEvenIfDisposeNotCalled() { var ms = new MemoryStream(); var testSequence = new byte[] { 0x1, 0x2, 0xFF, 0xFE }; var testSequence2 = new byte[] { 0x3, 0x4, 0x5 }; var writer = new WaveFileWriter(new IgnoreDisposeStream(ms), new WaveFormat(16000, 24, 1)); writer.Write(testSequence, 0, testSequence.Length); writer.Flush(); // BUT NOT DISPOSED // another write that was not flushed writer.Write(testSequence2, 0, testSequence2.Length); // check the Reader can read it ms.Position = 0; using (var reader = new WaveFileReader(ms)) { Assert.AreEqual(16000, reader.WaveFormat.SampleRate, "Sample Rate"); Assert.AreEqual(24, reader.WaveFormat.BitsPerSample, "Bits Per Sample"); Assert.AreEqual(1, reader.WaveFormat.Channels, "Channels"); Assert.AreEqual(testSequence.Length, reader.Length, "File Length"); var buffer = new byte[600]; // 24 bit audio, block align is 3 int read = reader.Read(buffer, 0, buffer.Length); Assert.AreEqual(testSequence.Length, read, "Data Length"); for (int n = 0; n < read; n++) { Assert.AreEqual(testSequence[n], buffer[n], "Byte " + n); } } writer.Dispose(); // to stop the finalizer from moaning }
private void Source_RecordingStopped(object sender, StoppedEventArgs e) { if (this.InvokeRequired) { this.BeginInvoke(new EventHandler <StoppedEventArgs>(Source_RecordingStopped), sender, e); } else { if (source != null) // 关闭录音对象 { this.source.Dispose(); this.source = null; } if (encoder != null)//关闭文件流 { encoder.Close(); encoder.Dispose(); encoder = null; } if (e.Exception != null) { MessageBox.Show(String.Format("出现问题 {0}", e.Exception.Message)); } } }
static void Main(string[] args) { // for recording waveFileWriter = new WaveFileWriter(@"C:\rec\out.wav", new WaveFormat(44100, 2)); var sound = new MySound(); sound.SetWaveFormat(44100, 2); sound.init(); waveOut = new WaveOut(); waveOut.Init(sound); waveOut.Play(); ConsoleKeyInfo keyInfo; bool loop = true; while (loop) { keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.Q) { waveOut.Stop(); waveOut.Dispose(); waveFileWriter.Close(); waveFileWriter.Dispose(); loop = false; } } }
/// <summary> /// Closes the WAV file /// </summary> public void Dispose() { if (writer != null) { writer.Dispose(); writer = null; } }
//Event arguments to stop recording private void wavSource_RecordingStopped(object sender, EventArgs e) { wavSource.Dispose(); wavSource = null; wavFile.Close(); wavFile.Dispose(); wavFile = null; }
private void btn_RECSTOP_Click(object sender, EventArgs e) { if (!isRecording) { if (cmb_InputsList.SelectedItem == null) { MessageBox.Show("Error! \n No Input Selected, Please select an Audio Input before recording"); return; } SaveFileDialog save = new SaveFileDialog(); save.Filter = "Wave File(*.wav)|*.wav;"; if (save.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } else { lst_samplelist.Items.Add(save.FileName); } int deviceNumber = cmb_InputsList.SelectedIndex; InputStream = new NAudio.Wave.WaveIn(); InputStream.DeviceNumber = deviceNumber; InputStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels); InputStream.DataAvailable += new EventHandler <NAudio.Wave.WaveInEventArgs>(InputStream_DataAvailable); waveWriter = new NAudio.Wave.WaveFileWriter(save.FileName, InputStream.WaveFormat); InputStream.StartRecording(); btn_RECSTOP.Text = "STOP"; isRecording = true; } else { if (InputStream != null) { InputStream.StopRecording(); InputStream.Dispose(); InputStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } btn_RECSTOP.Text = "REC"; isRecording = false; } }
public void waveSource_RecordingStopped(object sender, StoppedEventArgs e) { if (WaveSource != null) { WaveSource.Dispose(); WaveSource = null; } if (WaveFile != null) { WaveFile.Dispose(); WaveFile = null; } }
private void stopButton_Click(object sender, EventArgs e) { state = "stop"; playButton.Enabled = true; recordButton.Enabled = true; if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } }
private void stopRecordSound() { if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } }
//Event args to stop recording events private void wavSource_RecordingStop(object sender, NAudio.Wave.StoppedEventArgs e) { if (wavSource != null) { wavSource.Dispose(); wavSource = null; } if (wavFile != null) { wavFile.Dispose(); wavFile = null; } //recBtn.Enabled = true; }
private void stopRecordSound() { if (_sourceStream != null) { _sourceStream.StopRecording(); _sourceStream.Dispose(); _sourceStream = null; } if (_waveWriter != null) { _waveWriter.Dispose(); _waveWriter = null; } }
private void button_stop_Click(object sender, EventArgs e) { waveOut?.Stop(); waveOut?.Dispose(); waveOut = null; sourceStream?.StopRecording(); sourceStream?.Dispose(); sourceStream = null; waveWriter?.Dispose(); waveWriter = null; //Label this.Label_Status.Text = "待機中"; }
private void frmRecording_FormClosed(object sender, FormClosedEventArgs e) { if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } }
private void button3_Click(object sender, EventArgs e) { if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } }
public virtual void RecordAudioFile() { string currentDirectory = AppDomain.CurrentDomain.BaseDirectory; string wavFile = Path.Combine (currentDirectory, "recording.wav"); long writtenSamples = 0; WaveFileWriter writer = new WaveFileWriter (wavFile, _jackIn.WaveFormat); _jackIn.DataAvailable += (sender, args) => { writer.Write (args.Buffer, 0, args.BytesRecorded); }; _jackIn.RecordingStopped += (sender, e) => { writer.Flush (); writer.Dispose (); long fileSize = new FileInfo (wavFile).Length; Assert.AreNotEqual (0, fileSize); }; _jackIn.StartRecording (); Thread.Sleep (100); _jackIn.StopRecording (); writtenSamples = writer.Length; Assert.AreNotEqual (0, writtenSamples); }
public static void CreateWaveFile2(string filename, IWaveProvider sourceProvider) { using (var writer = new WaveFileWriter(filename, sourceProvider.WaveFormat)) { long outputLength = 0; var buffer = new byte[sourceProvider.WaveFormat.AverageBytesPerSecond * 4]; while (true) { int bytesRead = sourceProvider.Read(buffer, 0, buffer.Length); if (bytesRead == 0) { // end of source provider break; } outputLength += bytesRead; // Write will throw exception if WAV file becomes too large if (bytesRead > 0) { writer.Write(buffer, 0, bytesRead); } } writer.Dispose(); } }
private void btnParar_Click(object sender, EventArgs e) { if (waveOut != null) { waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { waveWriter.Dispose(); waveWriter = null; } btnIniciar.Enabled = true; btnParar.Enabled = false; WaveAudioLevel.Value = 0; }
public static void TrimWavFile(string innPath, string outtPath, TimeSpan cutFromStart, TimeSpan cutFromEnd) { string inPath = "C:\\Users\\Administratorius\\Documents\\GitHub\\MusicEditor\\PawellsMusicEditor\\PawellsMusicEditor\\Content\\Songs\\NowEdited.WAV"; string outPath = "C:\\Users\\Administratorius\\Documents\\GitHub\\MusicEditor\\PawellsMusicEditor\\PawellsMusicEditor\\Content\\Songs\\NowEdited2.WAV"; Mp3ToWav(innPath, inPath); using (WaveFileReader reader = new WaveFileReader(inPath)) { using (WaveFileWriter writer = new WaveFileWriter(outPath, reader.WaveFormat)) { int bytesPerMillisecond = reader.WaveFormat.AverageBytesPerSecond / 1000; int startPos = (int)cutFromStart.TotalMilliseconds * bytesPerMillisecond; startPos = startPos - startPos % reader.WaveFormat.BlockAlign; int endBytes = (int)cutFromEnd.TotalMilliseconds * bytesPerMillisecond; endBytes = endBytes - endBytes % reader.WaveFormat.BlockAlign; int endPos = (int)reader.Length - endBytes; TrimWavFile(reader, writer, startPos, endPos); reader.Dispose(); writer.Dispose(); } ConvertWavToMp3(outPath, outtPath); } File.Delete(inPath); File.Delete(outPath); }
private static void TrimWavFile(WaveFileReader reader, WaveFileWriter writer, int startPos, int endPos) { reader.Position = startPos; byte[] buffer = new byte[1024]; while (reader.Position < endPos) { int bytesRequired = (int)(endPos - reader.Position); if (bytesRequired > 0) { int bytesToRead = Math.Min(bytesRequired, buffer.Length); int bytesRead = reader.Read(buffer, 0, bytesToRead); if (bytesRead > 0) { writer.WriteData(buffer, 0, bytesRead); } } } reader.Dispose(); writer.Dispose(); }
private async void tlumaczenienamorsapluszapis(object sender, EventArgs e) { textBox2.Text = null; if (sourceList.SelectedItems.Count == 0) { MessageBox.Show("Wybierz źródło nagrywania"); } else { SaveFileDialog save = new SaveFileDialog(); save.Filter = "Wave File (*.wav)|*.wav;"; if (save.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } int deviceNumber = sourceList.SelectedItems[0].Index; sourceStream = new NAudio.Wave.WaveIn(); sourceStream.DeviceNumber = deviceNumber; sourceStream.WaveFormat = new NAudio.Wave.WaveFormat(44100, NAudio.Wave.WaveIn.GetCapabilities(deviceNumber).Channels); sourceStream.DataAvailable += new EventHandler <NAudio.Wave.WaveInEventArgs>(sourceStream_DataAvailable); waveWriter = new NAudio.Wave.WaveFileWriter(save.FileName, sourceStream.WaveFormat); sourceStream.StartRecording(); char[] tablica = null; String input = textBox1.Text; input = input.ToUpper(); Dictionary <char, String> morse = new Dictionary <char, String>() { { 'A', ".-" }, { 'Ą', ".-.-" }, { 'B', "-..." }, { 'C', "-.-." }, { 'Ć', "-.-.." }, { 'D', "-.." }, { 'E', "." }, { 'Ę', "..-.." }, { 'F', "..-." }, { 'G', "--." }, { 'H', "...." }, { 'I', ".." }, { 'J', ".---" }, { 'K', "-.-" }, { 'L', ".-.." }, { 'Ł', ".-..-" }, { 'M', "--" }, { 'N', "-." }, { 'Ń', "--.--" }, { 'O', "---" }, { 'Ó', "---." }, { 'P', ".--." }, { 'Q', "--.-" }, { 'R', ".-." }, { 'S', "..." }, { 'Ś', "...-..." }, { 'T', "-" }, { 'U', "..-" }, { 'V', "...-" }, { 'W', ".--" }, { 'X', "-..-" }, { 'Y', "-.--" }, { 'Z', "--.." }, { 'Ż', "--..-." }, { 'Ź', "--..-" }, { '0', "-----" }, { '1', ".----" }, { '2', "..---" }, { '3', "...--" }, { '4', "....-" }, { '5', "....." }, { '6', "-...." }, { '7', "--..." }, { '8', "---.." }, { '9', "----." }, }; for (int i = 0; i < input.Length; i++) { if (i > 0) { textBox2.Text += "/"; await Task.Delay(2000); } if (input[i] == ' ') { await Task.Delay(5000); } else { char c = input[i]; if (morse.ContainsKey(c)) { textBox2.Text += morse[c]; } tablica = morse[c].ToCharArray(); for (int i2 = 0; i2 < tablica.Length; i2++) { if (tablica[i2] == '.') { Action beep = () => Console.Beep(1000, 600); await Task.Delay(2000); beep.BeginInvoke(null, null); } if (tablica[i2] == '-') { Action beep2 = () => Console.Beep(1000, 1000); await Task.Delay(2000); beep2.BeginInvoke(null, null); } } } } if (waveOut != null) { await Task.Delay(1000); waveOut.Stop(); waveOut.Dispose(); waveOut = null; } if (sourceStream != null) { await Task.Delay(1000); sourceStream.StopRecording(); sourceStream.Dispose(); sourceStream = null; } if (waveWriter != null) { await Task.Delay(1000); waveWriter.Dispose(); waveWriter = null; } } }
public static void HighPassFilter(string innPath, string outtPath) { string inPath = "C:\\Users\\Administratorius\\Documents\\GitHub\\MusicEditor\\PawellsMusicEditor\\PawellsMusicEditor\\Content\\Songs\\NowEdited.WAV"; string outPath = "C:\\Users\\Administratorius\\Documents\\GitHub\\MusicEditor\\PawellsMusicEditor\\PawellsMusicEditor\\Content\\Songs\\NowEdited3.WAV"; Mp3ToWav(innPath, inPath); WaveFileReader reader = new WaveFileReader(inPath); var myFilter = BiQuadFilter.HighPassFilter(44F, 10F, 0.5F); WaveFileWriter writer = new WaveFileWriter(outPath, reader.WaveFormat); reader.Position = 0; var endPos = reader.Length; while (reader.Position < endPos) { int bytesRequired = (int)(endPos - reader.Position); if (bytesRequired > 0) { float[] sample = new float[4]; for (int i = 0; i < 2; i++) { sample[i] = myFilter.Transform(reader.ReadNextSampleFrame()[i]); } writer.WriteSamples(sample, 0, 4); } } reader.Dispose(); writer.Dispose(); ConvertWavToMp3(outPath, outtPath); File.Delete(inPath); File.Delete(outPath); }
// Генерация WAV-файла public void WordToWAV() { // Считываем параметры с движков регуляторов numberofwords = trackBar_N.Value; interval = trackBar_Pause.Value; speed = trackBar_Speed.Value; tone = trackBar_Tone.Value; // Выбираем папку для звуковых файлов string fileName = GetAudioFolderName(); string fileNameOld = fileName; // Сохраним для переноса файлов из корня (в WinXP) if (fileName == "cancel") // Если папка не выбрана, то выходим return; if (alternative_mp3_flag) // В Windows-XP сохраняем в корень диска { fileName = fileName.Remove(fileName.IndexOf(":")+1); } // Текущая дата string currentDate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString(); string currentTime = DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString(); // Добавляем дату и время к именам звуковых файлов string audioFileName = originalAudioFileName + "-" + currentDate + currentTime; // Добавляем к папке имя звуковых файлов fileName = fileName + audioFileName; fileNameOld = fileNameOld + audioFileName; // Выставить параметры WAV-файла WaveFormat waveFormat = new WaveFormat(8000, 16, 2); int one_milli_second = 2 * waveFormat.SampleRate / 1000; float amplitude = 0.25f; float frequency = tone; using (WaveFileWriter writer = new WaveFileWriter(fileName + ".wav", waveFormat)) { // Воспроизведение слова int dot = speed_calibr * one_milli_second / speed; // Длительность точки int dash = 3 * dot; // Длительность тире int dash_conjoint = dash; // Промежуток между слитными буквами типа <KN> // Если стоит "галка", то использовать паузу перед началом if (checkBox_StartPause.Checked) { startpause_flag = true; // Использовать паузу WavPause(writer, startpause * 1000); // Задержка перед началом передачи } // Выводим случайные слова из массива Random rnd = new Random(); if (non_random_flag) { numberofwords = AllWords.Length; // При отмене случайного выбора слов выводим все слова } // один раз for (int i = 1; i <= numberofwords; i++) { int num; if (!non_random_flag) { num = rnd.Next(0, AllWords.Length); // Номер случайного слова } else { num = i - 1; } string word = AllWords[num].ToUpper(); // Получаем случайное слово в верхнем // регистре for (int j = 0; j < word.Length; j++) // Перебираем буквы в слове { // Воспроизводим букву char symbol = word[j]; // Слитные буквы для <AS> и т.п. if (symbol == '<') dash_conjoint = dot; // "<" - слитное слово if (symbol == '>') { dash_conjoint = dash; // ">" - раздельное слово WavPause(writer, dash_conjoint); } // Цифры if (symbol == '0') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == '1') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == '2') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == '3') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == '4') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == '5') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == '6') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == '7') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == '8') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == '9') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } // Буквы if (symbol == 'A' || symbol == 'А') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'B' || symbol == 'Б') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'C' || symbol == 'Ц') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'D' || symbol == 'Д') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'E' || symbol == 'Е' || symbol == 'Ё') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'F' || symbol == 'Ф') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'G' || symbol == 'Г') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'H' || symbol == 'Х') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'I' || symbol == 'И') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'J' || symbol == 'Й') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'K' || symbol == 'К') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'L' || symbol == 'Л') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'M' || symbol == 'М') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'N' || symbol == 'Н') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'O' || symbol == 'О') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'P' || symbol == 'П') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'Q' || symbol == 'Щ') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'R' || symbol == 'Р') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'S' || symbol == 'С') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'T' || symbol == 'Т') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'U' || symbol == 'У') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'V' || symbol == 'Ж') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'W' || symbol == 'В') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'X' || symbol == 'Ь') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'Y' || symbol == 'Ы') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'Z' || symbol == 'З') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'Ч') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'Ш') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'Э') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'Ю') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } if (symbol == 'Я') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dash_conjoint); } // Символы if (symbol == '=') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); Thread.Sleep(dash); } if (symbol == '?') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); Thread.Sleep(dash); } if (symbol == '/') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); Thread.Sleep(dash); } if (symbol == '@') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); Thread.Sleep(dash); } if (symbol == '.' && russianpunktuation_flag == true) { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); Thread.Sleep(dash); } if (symbol == '.' && russianpunktuation_flag == false) { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); Thread.Sleep(dash); } if (symbol == ',' && russianpunktuation_flag == true) { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); Thread.Sleep(dash); } if (symbol == ',' && russianpunktuation_flag == false) { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); Thread.Sleep(dash); } if (symbol == ';') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); Thread.Sleep(dash); } if (symbol == ':') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); Thread.Sleep(dash); } if (symbol == '!' && russianpunktuation_flag == true) { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); Thread.Sleep(dash); } if (symbol == '!' && russianpunktuation_flag == false) { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); Thread.Sleep(dash); } if (symbol == '-') { WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); Thread.Sleep(dash); } if (symbol == '\'') { WavPlay(writer, dot, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dash, amplitude, frequency); WavPause(writer, dot); WavPlay(writer, dot, amplitude, frequency); Thread.Sleep(dash); } } // End For j if (non_random_flag) { screen_Out(word); // вывод на label непрерывно } else { screen_Out_By_10(i, word); // вывод на label по 10 слов } int dynamic_interval = 1; // Длительность динамического интервала между словами if (dynamic_interval_flag) { dynamic_interval = word.Length; } WavPause(writer, interval * dash * dynamic_interval); // Пауза между словами } // End for(i) writer.Close(); writer.Dispose(); } // end using // Конвертим WAV-файл в MP3-файл if (File.Exists(fileName + ".wav")) ConvertWavToMP3(fileName); else { if (english_flag) MessageBox.Show("No exist WAV-file to conver in MP3."); else MessageBox.Show(fileName + ".wav ", "Нет WAV-файла для конвертации в MP3."); } // Переместить звуковые файлы if (alternative_mp3_flag) { try { // MessageBox.Show("Конвертим с задержкой MP3."); // Не успевает LAME отрабоать - заддерка нужна Thread.Sleep(5000); // 5 секунд if (File.Exists(fileName + ".mp3")) { // Удаляем старые файлы if (File.Exists(fileNameOld + ".mp3 ")) File.Delete(fileNameOld + ".mp3 "); //Переносим файлы из корня диска в папку, указанную пользователем File.Move(fileName + ".mp3 ", fileNameOld + ".mp3"); } else MessageBox.Show(fileName + ".mp3 ", "Нет MP3-файла!"); if (File.Exists(fileName + ".wav")) { //MessageBox.Show(fileName + ".wav ", "Старый файл WAV"); //MessageBox.Show(fileNameOld + ".wav ", "Новый файл WAV"); // MessageBox.Show(fileName + ".mp3 ", "Старый файл MP3"); // MessageBox.Show(fileNameOld + ".mp3 ", "Новый файл MP3"); // Удаляем старые файлы if (File.Exists(fileNameOld + ".wav ")) File.Delete(fileNameOld + ".wav "); //Переносим файлы из корня диска в папку, указанную пользователем File.Move(fileName + ".wav ", fileNameOld + ".wav"); } } catch (Exception e) { MessageBox.Show(e.ToString(), "The process move a audiofiles failed!"); } } }