HamBook – Diff between revs 54 and 56
?pathlinks?
Rev 54 | Rev 56 | |||
---|---|---|---|---|
Line 35... | Line 35... | |||
35 | public SpectrogramForm(Configuration.Configuration configuration, CancellationToken cancellationToken) : this() |
35 | public SpectrogramForm(Configuration.Configuration configuration, CancellationToken cancellationToken) : this() |
|
36 | { |
36 | { |
|
37 | Configuration = configuration; |
37 | Configuration = configuration; |
|
38 | _cancellationToken = cancellationToken; |
38 | _cancellationToken = cancellationToken; |
|
Line 39... | Line 39... | |||
39 | |
39 | |
|
40 | _spectrogramGenerator = new SpectrogramGenerator(Configuration.Visualisations.Spectrogram.SampleRate, |
40 | _spectrogramGenerator = new SpectrogramGenerator(Configuration.Visualizations.Spectrogram.SampleRate, |
|
41 | Configuration.Visualisations.Spectrogram.FftSamples, |
41 | Configuration.Visualizations.Spectrogram.FftSamples, |
|
42 | Configuration.Visualisations.Spectrogram.FftSamples / |
42 | Configuration.Visualizations.Spectrogram.FftSamples / |
|
43 | Configuration.Visualisations.Spectrogram.AudioBufferTimespan); |
43 | Configuration.Visualizations.Spectrogram.AudioBufferTimespan); |
|
Line 44... | Line 44... | |||
44 | _spectrogramGenerator.Colormap = Colormap.Viridis; |
44 | _spectrogramGenerator.Colormap = Colormap.Viridis; |
|
45 | |
45 | |
|
Line 72... | Line 72... | |||
72 | base.Dispose(disposing); |
72 | base.Dispose(disposing); |
|
73 | } |
73 | } |
|
Line 74... | Line 74... | |||
74 | |
74 | |
|
75 | private void SpectrogramForm_Load(object sender, EventArgs e) |
75 | private void SpectrogramForm_Load(object sender, EventArgs e) |
|
76 | { |
76 | { |
|
Line 77... | Line 77... | |||
77 | pinToDesktopToolStripMenuItem.Checked = Configuration.Visualisations.Spectrogram.PinToDesktop; |
77 | pinToDesktopToolStripMenuItem.Checked = Configuration.Visualizations.Spectrogram.PinToDesktop; |
|
78 | |
78 | |
|
79 | if (Configuration.Visualisations.Spectrogram.PinToDesktop) |
79 | if (Configuration.Visualizations.Spectrogram.PinToDesktop) |
|
80 | _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), |
80 | _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), |
|
81 | () => |
81 | () => |
|
82 | { |
82 | { |
|
Line 92... | Line 92... | |||
92 | var capabilities = WaveIn.GetCapabilities(deviceNumber); |
92 | var capabilities = WaveIn.GetCapabilities(deviceNumber); |
|
93 | if (!string.Equals(capabilities.ProductName, Configuration.Audio.InputDeviceFriendlyName)) continue; |
93 | if (!string.Equals(capabilities.ProductName, Configuration.Audio.InputDeviceFriendlyName)) continue; |
|
Line 94... | Line 94... | |||
94 | |
94 | |
|
95 | _waveIn = new WaveIn(); |
95 | _waveIn = new WaveIn(); |
|
96 | _waveIn.DeviceNumber = deviceNumber; |
96 | _waveIn.DeviceNumber = deviceNumber; |
|
Line 97... | Line 97... | |||
97 | _waveIn.BufferMilliseconds = Configuration.Visualisations.Spectrogram.AudioBufferTimespan; |
97 | _waveIn.BufferMilliseconds = Configuration.Visualizations.Spectrogram.AudioBufferTimespan; |
|
98 | |
98 | |
|
99 | _waveIn.DataAvailable += _waveIn_DataAvailable; |
99 | _waveIn.DataAvailable += _waveIn_DataAvailable; |
|
100 | _waveIn.StartRecording(); |
100 | _waveIn.StartRecording(); |
|
Line 126... | Line 126... | |||
126 | _spectrogramGenerator.Process(); |
126 | _spectrogramGenerator.Process(); |
|
127 | _spectrogramGenerator.SetFixedWidth(pictureBox1.Width); |
127 | _spectrogramGenerator.SetFixedWidth(pictureBox1.Width); |
|
128 | var bmpSpec = new Bitmap(_spectrogramGenerator.Width, _spectrogramGenerator.Height, |
128 | var bmpSpec = new Bitmap(_spectrogramGenerator.Width, _spectrogramGenerator.Height, |
|
129 | PixelFormat.Format32bppPArgb); |
129 | PixelFormat.Format32bppPArgb); |
|
130 | using (var bmpSpecIndexed = |
130 | using (var bmpSpecIndexed = |
|
131 | _spectrogramGenerator.GetBitmap(Configuration.Visualisations.Spectrogram.SpectrumIntensity)) |
131 | _spectrogramGenerator.GetBitmap(Configuration.Visualizations.Spectrogram.SpectrumIntensity)) |
|
132 | using (var gfx = Graphics.FromImage(bmpSpec)) |
132 | using (var gfx = Graphics.FromImage(bmpSpec)) |
|
133 | using (var pen = new Pen(Color.White)) |
133 | using (var pen = new Pen(Color.White)) |
|
134 | { |
134 | { |
|
135 | gfx.DrawImage(bmpSpecIndexed, 0, 0); |
135 | gfx.DrawImage(bmpSpecIndexed, 0, 0); |
|
136 | if (false) |
136 | if (false) |
|
Line 197... | Line 197... | |||
197 | //SetWindowPos(Handle, HWND_BOTTOM, 0, 0, Location.X, Location.Y, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); |
197 | //SetWindowPos(Handle, HWND_BOTTOM, 0, 0, Location.X, Location.Y, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); |
|
198 | } |
198 | } |
|
Line 199... | Line 199... | |||
199 | |
199 | |
|
200 | private void SpectrogramForm_MouseEnter(object sender, EventArgs e) |
200 | private void SpectrogramForm_MouseEnter(object sender, EventArgs e) |
|
201 | { |
201 | { |
|
202 | if (Configuration.Visualisations.Spectrogram.PinToDesktop) |
202 | if (Configuration.Visualizations.Spectrogram.PinToDesktop) |
|
203 | _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), |
203 | _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), |
|
204 | () => |
204 | () => |
|
205 | { |
205 | { |
|
206 | this.InvokeIfRequired(form => |
206 | this.InvokeIfRequired(form => |
|
Line 211... | Line 211... | |||
211 | }, _renderCancellationToken); |
211 | }, _renderCancellationToken); |
|
212 | } |
212 | } |
|
Line 213... | Line 213... | |||
213 | |
213 | |
|
214 | private void SpectrogramForm_MouseLeave(object sender, EventArgs e) |
214 | private void SpectrogramForm_MouseLeave(object sender, EventArgs e) |
|
215 | { |
215 | { |
|
216 | if (Configuration.Visualisations.Spectrogram.PinToDesktop) |
216 | if (Configuration.Visualizations.Spectrogram.PinToDesktop) |
|
217 | _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), |
217 | _windowZOrderScheduledContinuation.Schedule(TimeSpan.FromSeconds(1), |
|
218 | () => |
218 | () => |
|
219 | { |
219 | { |
|
220 | this.InvokeIfRequired(form => |
220 | this.InvokeIfRequired(form => |
|
Line 230... | Line 230... | |||
230 | var toolStripMenuItem = (ToolStripMenuItem)sender; |
230 | var toolStripMenuItem = (ToolStripMenuItem)sender; |
|
Line 231... | Line 231... | |||
231 | |
231 | |
|
232 | switch (toolStripMenuItem.CheckState) |
232 | switch (toolStripMenuItem.CheckState) |
|
233 | { |
233 | { |
|
234 | case CheckState.Checked: |
234 | case CheckState.Checked: |
|
235 | Configuration.Visualisations.Spectrogram.PinToDesktop = true; |
235 | Configuration.Visualizations.Spectrogram.PinToDesktop = true; |
|
236 | break; |
236 | break; |
|
237 | case CheckState.Unchecked: |
237 | case CheckState.Unchecked: |
|
238 | Configuration.Visualisations.Spectrogram.PinToDesktop = false; |
238 | Configuration.Visualizations.Spectrogram.PinToDesktop = false; |
|
239 | break; |
239 | break; |
|
240 | } |
240 | } |
|
Line 241... | Line 241... | |||
241 | } |
241 | } |