private void AudioWaveform_Click(object sender, EventArgs e) { if (audioVisualizer.WavePeaks == null) { if (string.IsNullOrEmpty(_videoFileName)) { buttonOpenVideo_Click(sender, e); if (string.IsNullOrEmpty(_videoFileName)) return; } mediaPlayer.Pause(); using (var addWaveform = new AddWaveform()) { var peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(_videoFileName); var spectrogramFolder = Nikse.SubtitleEdit.Core.WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(_videoFileName); if (WavePeakGenerator.IsFileValidForVisualizer(_videoFileName)) { addWaveform.InitializeViaWaveFile(_videoFileName, peakWaveFileName, spectrogramFolder); } else { addWaveform.Initialize(_videoFileName, peakWaveFileName, spectrogramFolder, _videoAudioTrackNumber); } if (addWaveform.ShowDialog() == DialogResult.OK) { audioVisualizer.WavePeaks = addWaveform.Peaks; audioVisualizer.Spectrogram = addWaveform.Spectrogram; timerWaveform.Start(); } } } }
private void AudioWaveform_Click(object sender, EventArgs e) { if (this.audioVisualizer.WavePeaks == null) { if (string.IsNullOrEmpty(this.VideoFileName)) { this.buttonOpenVideo_Click(sender, e); if (string.IsNullOrEmpty(this.VideoFileName)) { return; } } this.mediaPlayer.Pause(); using (var addWaveform = new AddWaveform()) { var peakWaveFileName = GetPeakWaveFileName(this.VideoFileName); var spectrogramFolder = GetSpectrogramFolder(this.VideoFileName); addWaveform.Initialize(this.VideoFileName, spectrogramFolder, this._videoAudioTrackNumber); if (addWaveform.ShowDialog() == DialogResult.OK) { addWaveform.WavePeak.WritePeakSamples(peakWaveFileName); var audioPeakWave = new WavePeakGenerator(peakWaveFileName); audioPeakWave.GenerateAllSamples(); audioPeakWave.Close(); this.audioVisualizer.WavePeaks = audioPeakWave; if (addWaveform.SpectrogramBitmaps != null) { this.audioVisualizer.InitializeSpectrogram(addWaveform.SpectrogramBitmaps, spectrogramFolder); } this.timerWaveform.Start(); } } } }