private void OpenKernelSoundButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog { CheckPathExists = true, CheckFileExists = true, Filter = "Wave Sound Files (*.wav)|*.wav" }; bool? result = dialog.ShowDialog(); if (result == true) { try { mKernelSound = Sound.GetSoundFromWav(dialog.FileName); } catch (Exception exception) { MessageBox.Show("Error occured during opening: " + exception.Message); ConvolveButton.IsEnabled = false; return; } KernelSeries.DataContext = mKernelSound.ToKeyValuePairs(0); MessageBox.Show("Successfully opened " + dialog.FileName, "Sound Open", MessageBoxButton.OK); if (mConvolveBaseSound != null) { if (CheckSound(mKernelSound, mConvolveBaseSound)) { ConvolveButton.IsEnabled = true; ConvolutionStatusBlock.Foreground=Brushes.Green; ConvolutionStatusBlock.Text = "Everything is OK. You can start convolution."; } else { ConvolveButton.IsEnabled = false; ConvolutionStatusBlock.Foreground = Brushes.Red; ConvolutionStatusBlock.Text = "Chosen sound and impulse response should have same sound parameters"; } } KernelSoundBlock.Text = dialog.SafeFileName; } }
private void SoundOpenMenuItem_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog {CheckPathExists = true, CheckFileExists = true, Filter = "Wave Sound Files (*.wav)|*.wav"}; bool? result = dialog.ShowDialog(); if (result == true) { try { mBaseSound = Sound.GetSoundFromWav(dialog.FileName); } catch (Exception exception) { MessageBox.Show("Error occured during opening: " + exception.Message); return; } RecordButton.IsEnabled = true; MessageBox.Show("Successfully opened " + dialog.FileName,"Sound Open",MessageBoxButton.OK); foreach (SoundPoint source in mRoom.Sources) { source.Sound = mBaseSound; } FileNameBlock.Text = "Source: "+dialog.SafeFileName; SoundSeries.DataContext = mBaseSound.ToKeyValuePairs(0); // Timeline.Visibility = Visibility.Visible; DrawRoom(); } }