Exemplo n.º 1
0
        private void ReadWaveFile(string targetFile, int delayInMilliseconds)
        {
            labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingPeakFile;
            Refresh();

            var waveFile = new WavePeakGenerator(targetFile);

            int sampleRate = Configuration.Settings.VideoControls.WaveformMinimumSampleRate; // Normally 128

            while (waveFile.Header.SampleRate % sampleRate != 0 && sampleRate < 5000)
            {
                sampleRate++;                                              // old sample-rate / new sample-rate must have rest = 0
            }
            waveFile.GeneratePeakSamples(sampleRate, delayInMilliseconds); // samples per second - SampleRate

            if (Configuration.Settings.VideoControls.GenerateSpectrogram)
            {
                labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingSpectrogram;
                Refresh();
                Directory.CreateDirectory(_spectrogramDirectory);
                SpectrogramBitmaps = waveFile.GenerateFourierData(256, _spectrogramDirectory, delayInMilliseconds); // image height = nfft / 2
            }
            WavePeak = waveFile;
            waveFile.Close();

            labelPleaseWait.Visible = false;
        }
Exemplo n.º 2
0
        private void MakeWaveformAndSpectrogram(string videoFileName, string targetFile, int delayInMilliseconds)
        {
            var waveFile = new WavePeakGenerator(targetFile);

            int sampleRate = Configuration.Settings.VideoControls.WaveformMinimumSampleRate; // Normally 128

            while (waveFile.Header.SampleRate % sampleRate != 0 && sampleRate < 5000)
            {
                sampleRate++;                                              // old sample-rate / new sample-rate must have rest = 0
            }
            waveFile.GeneratePeakSamples(sampleRate, delayInMilliseconds); // samples per second - SampleRate

            //if (Configuration.Settings.VideoControls.GenerateSpectrogram)
            //{
            //    //Directory.CreateDirectory(_spectrogramDirectory);
            //    //SpectrogramBitmaps = waveFile.GenerateFourierData(256, _spectrogramDirectory, delayInMilliseconds); // image height = nfft / 2
            //}
            waveFile.WritePeakSamples(Main.GetPeakWaveFileName(videoFileName));
            waveFile.Close();
        }
Exemplo n.º 3
0
        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();
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void ReadWaveFile(string targetFile, int delayInMilliseconds)
        {
            labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingPeakFile;
            Refresh();

            var waveFile = new WavePeakGenerator(targetFile);

            int sampleRate = Configuration.Settings.VideoControls.WaveformMinimumSampleRate; // Normally 128
            while (waveFile.Header.SampleRate % sampleRate != 0 && sampleRate < 5000)
                sampleRate++; // old sample-rate / new sample-rate must have rest = 0

            waveFile.GeneratePeakSamples(sampleRate, delayInMilliseconds); // samples per second - SampleRate

            if (Configuration.Settings.VideoControls.GenerateSpectrogram)
            {
                labelProgress.Text = Configuration.Settings.Language.AddWaveform.GeneratingSpectrogram;
                Refresh();
                Directory.CreateDirectory(_spectrogramDirectory);
                SpectrogramBitmaps = waveFile.GenerateFourierData(256, _spectrogramDirectory, delayInMilliseconds); // image height = nfft / 2
            }
            WavePeak = waveFile;
            waveFile.Close();

            labelPleaseWait.Visible = false;
        }
        private void MakeWaveformAndSpectrogram(string videoFileName, string targetFile, int delayInMilliseconds)
        {
            var waveFile = new WavePeakGenerator(targetFile);

            int sampleRate = Configuration.Settings.VideoControls.WaveformMinimumSampleRate; // Normally 128
            while (waveFile.Header.SampleRate % sampleRate != 0 && sampleRate < 5000)
                sampleRate++; // old sample-rate / new sample-rate must have rest = 0

            waveFile.GeneratePeakSamples(sampleRate, delayInMilliseconds); // samples per second - SampleRate

            //if (Configuration.Settings.VideoControls.GenerateSpectrogram)
            //{
            //    //Directory.CreateDirectory(_spectrogramDirectory);
            //    //SpectrogramBitmaps = waveFile.GenerateFourierData(256, _spectrogramDirectory, delayInMilliseconds); // image height = nfft / 2
            //}
            waveFile.WritePeakSamples(Main.GetPeakWaveFileName(videoFileName));
            waveFile.Close();
        }