Example #1
0
        private void AudioWaveformDragDrop(object sender, DragEventArgs e)
        {
            var files = (string[])e.Data.GetData(DataFormats.FileDrop);
            if (files.Length != 1)
            {
                MessageBox.Show(_language.DropOnlyOneFile);
                return;
            }

            string fileName = files[0];
            string ext = Path.GetExtension(fileName).ToLowerInvariant();
            if (ext != ".wav" || !WavePeakGenerator.IsFileValidForVisualizer(fileName))
            {
                if (audioVisualizer.WavePeaks == null && (Utilities.GetMovieFileExtensions().Contains(ext) || ext == ".wav" || ext == ".mp3" || ext == ".mka" || ext == ".m4a" || ext == ".wma"))
                {
                    _videoFileName = fileName;
                    AudioWaveform_Click(null, null);
                    OpenVideo(_videoFileName);
                    return;
                }
                try
                {
                    var fi = new FileInfo(fileName);
                    if (fi.Length < 1024 * 500)
                    {
                        var lines = new List<string>(File.ReadAllLines(fileName));
                        foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats)
                        {
                            if (format.IsMine(lines, fileName))
                            {
                                OpenSubtitle(fileName, null);
                                return;
                            }
                        }
                    }
                }
                catch
                {
                }
            }

            if (ext != ".wav")
            {
                MessageBox.Show(".wav only!");
                return;
            }

            if (_videoFileName == null)
            {
                OpenVideo(fileName);
                return;
            }

            using (var addWaveform = new AddWaveform())
            {
                string peakWaveFileName = WavePeakGenerator.GetPeakWaveFileName(_videoFileName);
                string spectrogramFolder = Nikse.SubtitleEdit.Core.WavePeakGenerator.SpectrogramDrawer.GetSpectrogramFolder(_videoFileName);
                addWaveform.InitializeViaWaveFile(fileName, peakWaveFileName, spectrogramFolder);
                if (addWaveform.ShowDialog() == DialogResult.OK)
                {
                    audioVisualizer.WavePeaks = addWaveform.Peaks;
                    audioVisualizer.Spectrogram = addWaveform.Spectrogram;
                    timerWaveform.Start();
                }
            }
        }
Example #2
0
        private void AudioWaveformDragDrop(object sender, DragEventArgs e)
        {
            var files = (string[])e.Data.GetData(DataFormats.FileDrop);
            if (files.Length != 1)
            {
                MessageBox.Show(this._language.DropOnlyOneFile);
                return;
            }

            string fileName = files[0];
            string ext = Path.GetExtension(fileName).ToLowerInvariant();
            if (ext != ".wav")
            {
                if (this.audioVisualizer.WavePeaks == null && (Utilities.GetMovieFileExtensions().Contains(ext) || ext == ".mp3"))
                {
                    this.VideoFileName = fileName;
                    this.AudioWaveform_Click(null, null);
                    this.OpenVideo(this.VideoFileName);
                    return;
                }

                try
                {
                    var fi = new FileInfo(fileName);
                    if (fi.Length < 1024 * 500)
                    {
                        var lines = new List<string>(File.ReadAllLines(fileName));
                        foreach (SubtitleFormat format in SubtitleFormat.AllSubtitleFormats)
                        {
                            if (format.IsMine(lines, fileName))
                            {
                                this.OpenSubtitle(fileName, null);
                                return;
                            }
                        }
                    }
                }
                catch
                {
                }
            }

            if (string.IsNullOrEmpty(this.VideoFileName))
            {
                this.buttonOpenVideo_Click(null, null);
            }

            if (this.VideoFileName == null)
            {
                return;
            }

            if (ext != ".wav")
            {
                MessageBox.Show(".wav only!");
                return;
            }

            using (var addWaveform = new AddWaveform())
            {
                string spectrogramFolder = GetSpectrogramFolder(this.VideoFileName);
                addWaveform.InitializeViaWaveFile(fileName, spectrogramFolder);
                if (addWaveform.ShowDialog() == DialogResult.OK)
                {
                    string peakWaveFileName = GetPeakWaveFileName(this.VideoFileName);
                    addWaveform.WavePeak.WritePeakSamples(peakWaveFileName);
                    var audioPeakWave = new WavePeakGenerator(peakWaveFileName);
                    audioPeakWave.GenerateAllSamples();
                    this.audioVisualizer.WavePeaks = audioPeakWave;
                    this.timerWaveform.Start();
                }
            }
        }
Example #3
0
        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();
                    }
                }
            }
        }
Example #4
0
        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 = GetPeakWaveFileName(_videoFileName);
                    var spectrogramFolder = GetSpectrogramFolder(_videoFileName);

                    if (IsFileValidForVisualizer(_videoFileName))
                    {
                        addWaveform.InitializeViaWaveFile(_videoFileName, spectrogramFolder);
                    }
                    else
                    {
                        addWaveform.Initialize(_videoFileName, spectrogramFolder, _videoAudioTrackNumber);
                    }
                    if (addWaveform.ShowDialog() == DialogResult.OK)
                    {
                        addWaveform.WavePeak.WritePeakSamples(peakWaveFileName);
                        var audioPeakWave = new WavePeakGenerator(peakWaveFileName);
                        audioPeakWave.GenerateAllSamples();
                        audioPeakWave.Close();
                        audioVisualizer.WavePeaks = audioPeakWave;
                        if (addWaveform.SpectrogramBitmaps != null)
                            audioVisualizer.InitializeSpectrogram(addWaveform.SpectrogramBitmaps, spectrogramFolder);
                        timerWaveform.Start();
                    }
                }
            }
        }