private void ResetSpectrogram() { int sampleRate = audioControl1.SampleRate; int fftSize = 1 << 14; int samplesInTenMinutes = sampleRate * 60 * 10; int targetWidth = settings.targetWidth; int stepSize = samplesInTenMinutes / targetWidth; spec = new Spectrogram.Spectrogram(sampleRate, fftSize, stepSize, fixedWidth: targetWidth); spec.SetColormap(cmaps.Where(x => x.Name == settings.colormap).First()); // reset the spectrogram based on where we are in the 10 minute block ResetSpectrogramPosition(); // resize the image based on the spectrogram dimensions bmpSpectrogram = new Bitmap( width: spec.Width + verticalScaleWidth, height: spec.Height / settings.verticalReduction, format: PixelFormat.Format32bppPArgb); pictureBox1.Image = bmpSpectrogram; pictureBox1.Size = pictureBox1.Image.Size; Width = pictureBox1.Width + 33; UpdateVerticalScale(); Status($"Spectrogram reset"); }
private void cbColormap_SelectedIndexChanged(object sender, EventArgs e) { settings.colormap = cbColormap.Text; settings.Save(); spec?.SetColormap(cmaps[cbColormap.SelectedIndex]); }
//Sets up a listener for the selected microphone and initializes a spectrogram display public void StartListening() { int sampleRate = Int32.Parse(sampleRates[cbSampleRate.SelectedIndex]); int fftSize = 1 << (9 + cbFFTsize.SelectedIndex); int stepSize = fftSize - (int)(fftSize * overlap); listener?.Dispose(); listener = new Listener(cbMicInput.SelectedIndex, sampleRate); spec = new Spectrogram.Spectrogram(sampleRate, fftSize, stepSize); if (cmaps != null) { spec.SetColormap(cmaps[cbCmaps.SelectedIndex]); //todo this is a hack for this running before SpecInit } stft = new FFTs(spec.GetFFTs(), spec.SampleRate, spec.StepSize, spec.GetWindow()); }
private void cbCmaps_SelectionChanged(object sender, SelectionChangedEventArgs e) => spec.SetColormap(cmaps[cbCmaps.SelectedIndex]);