예제 #1
0
파일: Main.cs 프로젝트: m1croN/subtitleedit
        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();
                }
            }
        }
예제 #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();
                }
            }
        }
예제 #3
0
파일: Main.cs 프로젝트: m1croN/subtitleedit
        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();
                    }
                }
            }
        }
예제 #4
0
파일: Main.cs 프로젝트: Elheym/subtitleedit
        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();
                    }
                }
            }
        }