//main logic private static void TimerTick(object sender, EventArgs e) { //initialize after elements have loaded if (!m_HasInit) { //init spectrogram int spectrogramWidth = (int)Instance.SpectrogramPanel.ActualWidth * 2; int spectrogramHeight = (int)Instance.SpectrogramGrid.ActualHeight * 2; m_Spectrogram = new Spectrogram(spectrogramWidth, spectrogramHeight, m_SpectrogramMultiplier); int waveformWidth = (int)Instance.WaveformPanel.ActualWidth * 2; int waveformHeight = (int)Instance.WaveformPanel.ActualHeight * 2; m_Waveform = new Waveform(waveformWidth, waveformHeight, m_WaveformMultiplier); Mixer.SetUnusedChannels(); m_HasInit = true; } Analyzer.ProcessBarValues(); Mixer.ProcessLevels(); Instance.SpectrogramBitmap.Fill = m_Spectrogram.CreateBitmap(); Instance.WaveformBitmap.Fill = m_Waveform.CreateBitmap(); }
public void Test_SFF_Linear2() { // test creating SFF file from 16-bit 48kHz mono WAV file // read the wav file (int sampleRate, double[] audio) = WavFile.ReadMono("../../../../../data/03-02-03-01-02-01-19.wav"); Assert.AreEqual(48000, sampleRate); // save the SFF int fftSize = 1 << 12; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 300, maxFreq: 2000); spec.Add(audio); spec.SaveData("testDoor.sff"); // load the SFF and verify all the values are the same var spec2 = new SFF("testDoor.sff"); Assert.AreEqual(spec.SampleRate, spec2.SampleRate); Assert.AreEqual(spec.StepSize, spec2.StepSize); Assert.AreEqual(spec.Width, spec2.Width); Assert.AreEqual(spec.FftSize, spec2.FftSize); Assert.AreEqual(spec.NextColumnIndex, spec2.FftFirstIndex); Assert.AreEqual(spec.Height, spec2.Height); Assert.AreEqual(spec.OffsetHz, spec2.OffsetHz); Assert.AreEqual("SFF 701x170", spec2.ToString()); }
public Spectrograph() { InitializeComponent(); _soundIn = new WasapiLoopbackCapture(); _soundIn.Initialize(); var soundInSource = new SoundInSource(_soundIn); var singleBlockNotificationStream = new SingleBlockNotificationStream(soundInSource); _source = singleBlockNotificationStream.ToWaveSource(); if (!Directory.Exists(_loopbackDir)) { Directory.CreateDirectory(_loopbackDir); } _writer = new WaveWriter(_loopbackDir + "/loopback.wav", _source.WaveFormat); byte[] buffer = new byte[_source.WaveFormat.BytesPerSecond / 2]; soundInSource.DataAvailable += (s, e) => { int read; while ((read = _source.Read(buffer, 0, buffer.Length)) > 0) { _writer.Write(buffer, 0, read); } }; _lineSpectrumProvider = new BasicSpectrumProvider(_source.WaveFormat.Channels, _source.WaveFormat.SampleRate, fftSize); _spectrogramProvider = new BasicSpectrumProvider(_source.WaveFormat.Channels, _source.WaveFormat.SampleRate, fftSize); singleBlockNotificationStream.SingleBlockRead += SingleBlockNotificationStream_SingleBlockRead; _soundIn.Start(); _lineSpectrum = new LineSpectrum(fftSize) { SpectrumProvider = _lineSpectrumProvider, UseAverage = true, BarCount = 22, BarSpacing = 1, IsXLogScale = true, ScalingStrategy = ScalingStrategy.Sqrt }; _oscilloscope = new Oscilloscope(); _spectrogram = new Spectrogram(fftSize) { SpectrumProvider = _spectrogramProvider, UseAverage = true, BarCount = (int)fftSize, BarSpacing = 0, IsXLogScale = true, ScalingStrategy = ScalingStrategy.Sqrt }; _keyboardVisualizer = new KeyboardVisualizer(); UpdateTimer.Start(); }
public void Test_SaveEmpty_Throws() { (int sampleRate, double[] audio) = WavFile.ReadMono("../../../../../data/cant-do-that-44100.wav"); int fftSize = 4096; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 500); //spec.Add(audio); Assert.Throws <InvalidOperationException>(() => { spec.SaveImage("empty.png"); }); }
public void DisplaySpectrogram(string filePath) { // analyser = new ShortTimeFourierTransform(filePath, double.Parse(fResolutionTxt.Text), double.Parse(timeStepTxt.Text)); analyser = new ShortTimeFourierTransform(filePath, int.Parse(fftSizeTxt.Text), double.Parse(timeStepTxt.Text)); spectrogram = new RainbowSpectrogram(analyser, int.Parse(textBox1.Text)); analyser.Ended += OnEnded; OriginalBitmap = spectrogram.Generate(); pictureBox1.Image = (Bitmap)OriginalBitmap.Bitmap.Clone(); }
private void cmb_sensor_SelectedIndexChanged(object sender, EventArgs e) { var field = new string[] { "AccX", "AccY", "AccZ" }; if (cmb_sensor.Text.Contains("GYR")) { field = new string[] { "GyrX", "GyrY", "GyrZ" }; } List <(double timeus, double[] value)> allfftdata; double[] freqt; var img1 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[0]); var img2 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[1]); var img3 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[2]); var mintime = allfftdata.Min(a => a.timeus) / 1000000.0; var maxtime = allfftdata.Max(a => a.timeus) / 1000000.0; var tdelta = (maxtime - mintime); zedGraphControl1.MasterPane[0].GraphObjList.Clear(); zedGraphControl1.MasterPane[0].GraphObjList.Add(new ImageObj(img1.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[0].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[0].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[0].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[0].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.MasterPane[1].GraphObjList.Clear(); zedGraphControl1.MasterPane[1].GraphObjList.Add(new ImageObj(img2.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[1].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[1].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[1].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[1].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.MasterPane[2].GraphObjList.Clear(); zedGraphControl1.MasterPane[2].GraphObjList.Add(new ImageObj(img3.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[2].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[2].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[2].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[2].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); }
public void Test_Quickstart_Hal() { (int sampleRate, double[] audio) = WavFile.ReadMono("../../../../../data/cant-do-that-44100.wav"); int fftSize = 4096; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 500, maxFreq: 3000); spec.Add(audio); spec.SaveImage("../../../../../dev/graphics/hal.png", intensity: .2); Console.WriteLine(spec); }
public void Test_AGC_off() { string wavFilePath = "../../../../../data/qrss-10min.wav"; (int sampleRate, double[] L) = WavFile.ReadMono(wavFilePath); int fftSize = 8192; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 2000, maxFreq: 3000); spec.Add(L); spec.SaveImage("qrss-agc-off.png", intensity: 3); }
public void Test_SFF_LinearBigMaxFreq() { // test creating SFF file from 16-bit 48kHz mono WAV file (int sampleRate, double[] audio) = WavFile.ReadMono("../../../../../data/03-02-03-01-02-01-19.wav"); Assert.AreEqual(48000, sampleRate); int fftSize = 1 << 12; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 300, maxFreq: 7999); spec.Add(audio); spec.SaveData("testDoorBig.sff"); }
public void Test_Mel_Spectrogram() { (int sampleRate, double[] audio) = WavFile.ReadMono("../../../../../data/cant-do-that-44100.wav"); int fftSize = 4096; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 500); spec.Add(audio); spec.SaveImage("halNotMel.png", 4, true); Bitmap bmp = spec.GetBitmapMel(250, 4, true); bmp.Save("../../../../../dev/graphics/halMel.png", ImageFormat.Png); }
private void StartListening() { int sampleRate = 6000; int fftSize = 1 << (9 + cbFftSize.SelectedIndex); int stepSize = fftSize / 20; pbSpectrogram.Image?.Dispose(); pbSpectrogram.Image = null; listener?.Dispose(); listener = new Listener(cbDevice.SelectedIndex, sampleRate); spec = new Spectrogram(sampleRate, fftSize, stepSize); //spec.SetWindow(FftSharp.Window.Rectangular(fftSize)); pbSpectrogram.Height = spec.Height; pbScaleVert.Image?.Dispose(); pbScaleVert.Image = spec.GetVerticalScale(pbScaleVert.Width); pbScaleVert.Height = spec.Height; }
public Spectrograms(int mn, int mx, int widthofmax) { minres = mn; maxres = mx; // The number of resolutions, n, we may obtain depends directly on our choice of L and N: // n = log2 (N/L) + 1 // N = number of points in each DFT // L = time advance of the analysis window n = Log2(maxres / minres) + 1; spectrograms = new Spectrogram[n]; int r = mn; for (int i = 0; i < n; ++i) { spectrograms[i] = new Spectrogram(r, widthofmax * (mx / r)); r = r * 2; } }
public void Test_SFF_Linear() { (int sampleRate, double[] audio) = WavFile.ReadMono("../../../../../data/cant-do-that-44100.wav"); int fftSize = 1 << 12; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 700, maxFreq: 2000); spec.SetWindow(FftSharp.Window.Hanning(fftSize / 3)); // sharper window than typical spec.Add(audio); spec.SaveData("../../../../../dev/sff/hal.sff"); var spec2 = new SFF("../../../../../dev/sff/hal.sff"); Assert.AreEqual(spec.SampleRate, spec2.SampleRate); Assert.AreEqual(spec.StepSize, spec2.StepSize); Assert.AreEqual(spec.Width, spec2.Width); Assert.AreEqual(spec.FftSize, spec2.FftSize); Assert.AreEqual(spec.NextColumnIndex, spec2.FftFirstIndex); Assert.AreEqual(spec.Height, spec2.Height); Assert.AreEqual(spec.OffsetHz, spec2.OffsetHz); }
public void sample_test() { string basePath = NUnit.Framework.TestContext.CurrentContext.TestDirectory; string pathWhereTheDatasetShouldBeStored = Path.Combine(basePath, "mfcc"); #region doc_example1 // Let's say we would like to analyse an audio sample. To give an example that // could be reproduced by anyone without having to give a specific sound file // that would need to have been downloaded by every user trying to run this example, // we will use obtain an example from the Free Spoken Digits Dataset instead: var fsdd = new FreeSpokenDigitsDataset(path: pathWhereTheDatasetShouldBeStored); // Let's obtain one of the audio signals: Signal a = fsdd.GetSignal(0, "jackson", 10); int sampleRate = a.SampleRate; // 8000 // Note: if you would like to load a signal from the // disk, you could use the following method directly: // Signal a = Signal.FromFile(fileName); // Create a low-pass filter to keep only frequencies below 100 Hz var filter = new LowPassFilter(frequency: 100, sampleRate: sampleRate); // Apply the filter to the signal Signal result = filter.Apply(a); // Create a spectrogram for the original var sourceSpectrum = new Spectrogram(a); // Create a spectrogram for the filtered signal: var resultSpectrum = new Spectrogram(result); // Get the count for a high frequency before and after the low-pass filter: double before = sourceSpectrum.GetFrequencyCount(windowIndex: 0, frequency: 1000); // 0.00028203820434203334 double after = resultSpectrum.GetFrequencyCount(windowIndex: 0, frequency: 1000); // 2.9116651158267508E-05 #endregion Assert.AreEqual(0.00028203820434203334, before, 1e-8); Assert.AreEqual(2.9116651158267508E-05, after, 1e-8); }
public void Test_AGC_normWindow() { // strategy here is to create a weighted moving window mean and normalize to that string wavFilePath = "../../../../../data/qrss-10min.wav"; (int sampleRate, double[] L) = WavFile.ReadMono(wavFilePath); int fftSize = 8192; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 2000, maxFreq: 3000); spec.Add(L); var ffts = spec.GetFFTs(); for (int i = 0; i < ffts.Count; i++) { ffts[i] = SubtractMovingWindowFloor(ffts[i]); } spec.SaveImage("qrss-agc-norm-window.png", intensity: 3); }
public void Test_Make_CommonColormaps() { (int sampleRate, double[] audio) = WavFile.ReadMono("../../../../../data/cant-do-that-44100.wav"); int fftSize = 1 << 12; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 700, maxFreq: 2000); spec.SetWindow(FftSharp.Window.Hanning(fftSize / 3)); // sharper window than typical spec.Add(audio); // delete old colormap files foreach (var filePath in System.IO.Directory.GetFiles("../../../../../dev/graphics/", "hal-*.png")) { System.IO.File.Delete(filePath); } foreach (var cmap in Colormap.GetColormaps()) { spec.SetColormap(cmap); spec.SaveImage($"../../../../../dev/graphics/hal-{cmap.Name}.png", intensity: .5); Debug.WriteLine($"![](dev/graphics/hal-{cmap.Name}.png)"); } }
public void Test_Quickstart_Handel() { double[] audio = Mp3.Read("../../../../../data/Handel - Air and Variations.mp3"); int sampleRate = 44100; int fftSize = 16384; int targetWidthPx = 3000; int stepSize = audio.Length / targetWidthPx; var spec = new Spectrogram(sampleRate, fftSize, stepSize, maxFreq: 2200); spec.Add(audio); spec.SaveImage("../../../../../dev/spectrogram-song.jpg", intensity: 5, dB: true); Console.WriteLine(spec); /* * Spectrogram (2993, 817) * Vertical (817 px): 0 - 2,199 Hz, FFT size: 16,384 samples, 2.69 Hz/px * Horizontal (2993 px): 2.96 min, window: 0.37 sec, step: 0.06 sec, overlap: 84% */ }
public void Test_AGC_normToNoiseFloor() { // strategy here is to normalize to the magnitude of the quietest 20% of frequencies string wavFilePath = "../../../../../data/qrss-10min.wav"; (int sampleRate, double[] L) = WavFile.ReadMono(wavFilePath); int fftSize = 8192; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 2000, maxFreq: 3000); spec.Add(L); var ffts = spec.GetFFTs(); double normalIntensity = 2; for (int i = 0; i < ffts.Count; i++) { double[] sorted = new double[ffts[i].Length]; ffts[i].CopyTo(sorted, 0); Array.Sort(sorted); double percentile = 0.25; int percentileIndex = (int)(percentile * ffts[0].Length); double floorValue = sorted[percentileIndex]; for (int y = 0; y < ffts[i].Length; y++) { ffts[i][y] = ffts[i][y] / floorValue * normalIntensity; } Console.WriteLine(floorValue); } spec.SaveImage("qrss-agc-norm-floor.png", intensity: 3); }
public void Test_SFF_Mel() { (int sampleRate, double[] audio) = WavFile.ReadMono("../../../../../data/cant-do-that-44100.wav"); int fftSize = 1 << 12; var spec = new Spectrogram(sampleRate, fftSize, stepSize: 700); spec.SetWindow(FftSharp.Window.Hanning(fftSize / 3)); // sharper window than typical spec.Add(audio); Bitmap bmp = spec.GetBitmapMel(250, 3, true); bmp.Save("../../../../../dev/sff/halMel.png", System.Drawing.Imaging.ImageFormat.Png); spec.SaveData("../../../../../dev/sff/halMel.sff", melBinCount: 250); var spec2 = new SFF("../../../../../dev/sff/halMel.sff"); Assert.AreEqual(spec.SampleRate, spec2.SampleRate); Assert.AreEqual(spec.StepSize, spec2.StepSize); Assert.AreEqual(spec.Width, spec2.Width); Assert.AreEqual(spec.FftSize, spec2.FftSize); Assert.AreEqual(spec.NextColumnIndex, spec2.FftFirstIndex); Assert.AreEqual(spec.Height, spec2.Height); Assert.AreEqual(spec.OffsetHz, spec2.OffsetHz); }
protected static double Cost(Spectrogram s, int x, int y) { return(XLogX(s.data[x][y])); }
protected static double Value(Spectrogram s, int x, int y) { return(s.data[x][y]); }
// recursively cut the spectrogram into small pieces protected Cutting Cut(Spectrograms s, int res, int x, int y, int h) { #if DEBUGVERBOSE Console.WriteLine("res = {0}, x = {1}, y = {2}, h = {3}", res, x, y, h); #endif var cutting = new Cutting(); if (h > 1 && res > s.minres) { if (!IsResolutionWanted(s, res)) { var left = new Cutting(); var right = new Cutting(); //GetSubCuts(s, res, x, y, h, null, null, ref left, ref right); double hcost = left.cost + right.cost; double henergy = left.value + right.value; hcost = Normalize(hcost, henergy); cutting.cut = Cutting.Cut.Horizontal; cutting.first = left; cutting.second = right; cutting.cost = hcost; cutting.value = left.value + right.value; } else if (h == 2 && !IsResolutionWanted(s, res / 2)) { var top = new Cutting(); var bottom = new Cutting(); //GetSubCuts(s, res, x, y, h, ref top, ref bottom, null, null); double vcost = top.cost + bottom.cost; double venergy = top.value + bottom.value; vcost = Normalize(vcost, venergy); cutting.cut = Cutting.Cut.Vertical; cutting.first = top; cutting.second = bottom; cutting.cost = vcost; cutting.value = top.value + bottom.value; } else { var top = new Cutting(); var bottom = new Cutting(); var left = new Cutting(); var right = new Cutting(); GetSubCuts(s, res, x, y, h, ref top, ref bottom, ref left, ref right); double vcost = top.cost + bottom.cost; double venergy = top.value + bottom.value; vcost = Normalize(vcost, venergy); double hcost = left.cost + right.cost; double henergy = left.value + right.value; hcost = Normalize(hcost, henergy); if (vcost > hcost) { cutting.cut = Cutting.Cut.Horizontal; cutting.first = left; cutting.second = right; cutting.cost = hcost; cutting.value = left.value + right.value; top.Erase(); bottom.Erase(); return(cutting); } else { cutting.cut = Cutting.Cut.Vertical; cutting.first = top; cutting.second = bottom; cutting.cost = vcost; cutting.value = top.value + bottom.value; left.Erase(); right.Erase(); return(cutting); } } } else { // no cuts possible from this level cutting.cut = Cutting.Cut.Finished; cutting.first = null; cutting.second = null; int n = 0; for (int r = res; r > s.minres; r >>= 1) { ++n; } Spectrogram spectrogram = s.spectrograms[n]; cutting.cost = Cost(spectrogram, x, y); cutting.value = Value(spectrogram, x, y); } return(cutting); }
public void AddChannel(Channel channel) { if (channelNames.Contains(channel.Name)) { return; } channelNames.Add(channel.Name); var border = new Border(); border.BorderThickness = new Thickness(1); border.BorderBrush = Brushes.Black; var channelPanel = new StackPanel(); border.Child = channelPanel; var sp = new Spectrogram(channel) { Begin = begin, End = end, Palette = curPalette, CoeffN = CoeffSlider.Value, BoostCoeff = BrightnessSlider.Value, SpectrogramHeight = this.spectrogramHeight, ShowCurrentXY = true, ContextMenu = new ContextMenu() }; channelPanel.Children.Add(sp); spectrograms.Add(sp); var bottomGrid = new Grid(); bottomGrid.ColumnDefinitions.Add(new ColumnDefinition()); var cd1 = new ColumnDefinition(); cd1.Width = new GridLength(sp.RightOffset); bottomGrid.ColumnDefinitions.Add(cd1); var chart = new ChartLine(channel); chart.Height = 45; chart.Margin = new Thickness(sp.LeftOffset, 2, 2, 2); chart.Segment.SetLeftRight(this.begin, this.end); chart.DisplayTitle = false; chart.GridDraw = true; chart.DisplayVAxisInfo = false; chart.DisplayHAxisInfo = true; chart.HAxisAlligment = ChartLine.HAxisAlligmentEnum.Bottom; chart.MappingXAxis = (idx, chartLine) => { var t = chartLine.Channel.StartDateTime + TimeSpan.FromSeconds(chartLine.Channel.DeltaTime * idx); return(t.ToString("dd-MM-yyyy \n HH\\:mm\\:ss")); }; charts.Add(chart); var item = new MenuItem(); item.Header = "Закрыть канал"; item.Click += (sender, args) => { channelNames.Remove(channel.Name); spectrograms.Remove(sp); charts.Remove(chart); Spectrograms.Children.Remove(border); }; sp.ContextMenu.Items.Add(item); bottomGrid.Children.Add(chart); channelPanel.Children.Add(bottomGrid); Spectrograms.Children.Add(border); }
private void cmb_sensor_SelectedIndexChanged(object sender, EventArgs e) { var field = new string[] { "AccX", "AccY", "AccZ" }; if (cmb_sensor.Text.Contains("GYR")) { field = new string[] { "GyrX", "GyrY", "GyrZ" }; } List <(double timeus, double[] value)> allfftdata; double[] freqt; // create X Y Z var img1 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[0], min: (int)num_min.Value, max: (int)num_max.Value); var img2 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[1], min: (int)num_min.Value, max: (int)num_max.Value); var img3 = Spectrogram.GenerateImage(file, out freqt, out allfftdata, cmb_sensor.Text, field[2], min: (int)num_min.Value, max: (int)num_max.Value); var mintime = allfftdata.Min(a => a.timeus) / 1000000.0; var maxtime = allfftdata.Max(a => a.timeus) / 1000000.0; var tdelta = (maxtime - mintime); zedGraphControl1.MasterPane[0].GraphObjList.Clear(); zedGraphControl1.MasterPane[0].GraphObjList.Add(new ImageObj(img1.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[0].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[0].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[0].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[0].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.MasterPane[1].GraphObjList.Clear(); zedGraphControl1.MasterPane[1].GraphObjList.Add(new ImageObj(img2.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[1].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[1].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[1].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[1].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.MasterPane[2].GraphObjList.Clear(); zedGraphControl1.MasterPane[2].GraphObjList.Add(new ImageObj(img3.ToBitmap(), mintime, freqt.Max(), tdelta, freqt.Max()) { ZOrder = ZOrder.F_BehindGrid }); zedGraphControl1.MasterPane[2].XAxis.Scale.Min = mintime; zedGraphControl1.MasterPane[2].XAxis.Scale.Max = maxtime; zedGraphControl1.MasterPane[2].YAxis.Scale.Min = 0; zedGraphControl1.MasterPane[2].YAxis.Scale.Max = freqt.Max(); zedGraphControl1.MasterPane[0].YAxis.Scale.MajorStep = 20; zedGraphControl1.MasterPane[0].YAxis.MajorGrid.IsVisible = true; zedGraphControl1.MasterPane[1].YAxis.Scale.MajorStep = 20; zedGraphControl1.MasterPane[1].YAxis.MajorGrid.IsVisible = true; zedGraphControl1.MasterPane[2].YAxis.Scale.MajorStep = 20; zedGraphControl1.MasterPane[2].YAxis.MajorGrid.IsVisible = true; Bitmap bitmap = new Bitmap(10, 10); Graphics g = Graphics.FromImage(bitmap); zedGraphControl1.MasterPane.DoLayout(g); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); }