public static Bitmap SpectrumPaint(int stream, int width, int height) { Bitmap Spectrum = new Bitmap(1, 1); Visuals SpectrumCreater = new Visuals(); switch (SpectrumType) { case 0: Spectrum = SpectrumCreater.CreateSpectrum(stream, width, height, SpectrumColor1, SpectrumColor2, Color.Transparent, false, false, true); break; case 1: Spectrum = SpectrumCreater.CreateSpectrumDot(stream, width, height, SpectrumColor1, SpectrumColor2, Color.Transparent, 2, 2, false, false, true); break; case 2: Spectrum = SpectrumCreater.CreateSpectrumBean(stream, width, height, SpectrumColor1, SpectrumColor2, Color.Transparent, 1, false, false, true); break; case 3: Spectrum = SpectrumCreater.CreateSpectrumEllipse(stream, width, height, SpectrumColor1, SpectrumColor2, Color.Transparent, 1, 1, false, false, true); break; case 4: Spectrum = SpectrumCreater.CreateSpectrumLine(stream, width, height, SpectrumColor1, SpectrumColor2, Color.Transparent, 2, 2, false, false, true); break; case 5: Spectrum = SpectrumCreater.CreateSpectrumLinePeak(stream, width, height, SpectrumColor1, SpectrumColor2, SpectrumColor3, Color.Transparent, 3, 3, 2, 3, false, false, true); break; case 6: Spectrum = SpectrumCreater.CreateSpectrumWave(stream, width, height, SpectrumColor1, SpectrumColor2, Color.Transparent, 2, false, false, true); break; } return(Spectrum); }
void _timer_Tick(object sender, EventArgs e) { int stream = Stream; int width = (int)Width; int height = (int)Height; DISPLAY display = Display; if (stream != 0) { System.Drawing.Bitmap bmp = null; switch (display) { case DISPLAY.SPECTRUM_LINE: bmp = vis.CreateSpectrumLine(stream, width, height, _color, _color2, System.Drawing.Color.Transparent, 5, 3, false, false, false); break; case DISPLAY.WAVE_FORM: bmp = vis.CreateSpectrumWave(stream, width, height, _color, _color2, System.Drawing.Color.Transparent, 1, false, false, false); break; } if (bmp != null) { using (MemoryStream ms = new MemoryStream()) { bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png); System.Windows.Media.Imaging.BitmapImage bImg = new System.Windows.Media.Imaging.BitmapImage(); bImg.BeginInit(); bImg.StreamSource = new MemoryStream(ms.ToArray()); bImg.EndInit(); this.Source = bImg; } } } else { this.Source = null; } }
private void ShowVisuals() { picVisuals.Visible = VisualsShown && BassPlayer.PlayState == PlayState.Playing; if (!VisualsShown) { return; } if (BassPlayer.PlayState == PlayState.Playing) { if (!_firstVisualShown) { for (var i = 0; i < 5; i++) { Thread.Sleep(50); Application.DoEvents(); } } //lock (BassPlayer.ExternalMixerLock) { picVisuals.Image = _bassVisuals.CreateSpectrumLine(BassPlayer.SpeakerOutput.ChannelId, picVisuals.Width, picVisuals.Height, _volumeColor1, _volumeColor2, Color.Transparent, 10, 1, false, true, false); Thread.Sleep(1); _firstVisualShown = true; } } else { _firstVisualShown = false; } }
private void timer_Tick(object sender, EventArgs e) { int peakL = 0; int peakR = 0; GetLevel(MainForm.stream, out peakL, out peakR); int progL = (int)peakL; int progR = (int)peakR; // convert the level to dB double dBlevelL = Utils.LevelToDB(peakL, 65535); double dBlevelR = Utils.LevelToDB(peakR, 65535); lbldBL.Text = dBlevelL.ToString("00.#dB"); lbldBR.Text = dBlevelR.ToString("00.#dB"); prgL.Value = progL; prgR.Value = progR; switch (selectedVis) { case VIS_SPECTRUM: pbVis.Image = vis.CreateSpectrum(MainForm.stream, pbVis.Width, pbVis.Height, Color.Lime, Color.Red, Color.Black, false, false, false); break; case VIS_SPECTRUMLINE: pbVis.Image = vis.CreateSpectrumLine(MainForm.stream, pbVis.Width, pbVis.Height, Color.Lime, Color.Red, Color.Black, 3, 3, false, false, false); break; case VIS_SPECTRUMWAVE: pbVis.Image = vis.CreateSpectrumWave(MainForm.stream, pbVis.Width, pbVis.Height, Color.Lime, Color.Red, Color.Black, 1, false, false, false); break; } }
public Bitmap DrawSpectrumLine(int width, int height, bool highQuality, bool fullSpectrum) { return(_visuals.CreateSpectrumLine(_stream, width, height, _visColor1, _visColor2, _visBackColor, 3, 2, false, fullSpectrum, highQuality)); }
private void drawSpectrum() { switch (spectId) { case 0: pictureBoxSpectrum.Image = vis.CreateSpectrum(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.Lime, Color.Red, Color.Black, false, false, false); break; case 1: pictureBoxSpectrum.Image = vis.CreateSpectrum(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.SteelBlue, Color.Pink, Color.Black, false, true, true); break; case 2: pictureBoxSpectrum.Image = vis.CreateSpectrumLine(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.Lime, Color.Red, Color.Black, 2, 2, false, false, false); break; case 3: pictureBoxSpectrum.Image = vis.CreateSpectrumLine(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.SteelBlue, Color.Pink, Color.Black, 16, 4, false, true, true); break; case 4: pictureBoxSpectrum.Image = vis.CreateSpectrumEllipse(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.Lime, Color.Red, Color.Black, 1, 2, false, false, false); break; case 5: pictureBoxSpectrum.Image = vis.CreateSpectrumEllipse(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.SteelBlue, Color.Pink, Color.Black, 2, 4, false, true, true); break; case 6: pictureBoxSpectrum.Image = vis.CreateSpectrumDot(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.Lime, Color.Red, Color.Black, 1, 0, false, false, false); break; case 7: pictureBoxSpectrum.Image = vis.CreateSpectrumDot(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.SteelBlue, Color.Pink, Color.Black, 2, 1, false, false, true); break; case 8: pictureBoxSpectrum.Image = vis.CreateSpectrumLinePeak(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.SeaGreen, Color.LightGreen, Color.Orange, Color.Black, 2, 1, 2, 10, false, false, false); break; case 9: pictureBoxSpectrum.Image = vis.CreateSpectrumLinePeak(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.GreenYellow, Color.RoyalBlue, Color.DarkOrange, Color.Black, 23, 5, 3, 5, false, true, true); break; case 10: pictureBoxSpectrum.Image = vis.CreateSpectrumWave(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.Yellow, Color.Orange, Color.Black, 1, false, false, false); break; case 11: pictureBoxSpectrum.Image = vis.CreateSpectrumBean(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.Chocolate, Color.DarkGoldenrod, Color.Black, 4, false, false, true); break; case 12: pictureBoxSpectrum.Image = vis.CreateSpectrumText(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.White, Color.Tomato, Color.Black, "BASS .NET IS GREAT PIECE! UN4SEEN ROCKS...", false, false, true); break; case 13: float amp = vis.DetectFrequency(stream, 10, 500, true); if (amp > 0.3) { this.pictureBoxSpectrum.BackColor = Color.Red; } else { this.pictureBoxSpectrum.BackColor = Color.Black; } break; case 14: Graphics g = Graphics.FromHwnd(this.pictureBoxSpectrum.Handle); g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; vis.CreateSpectrum3DVoicePrint(stream, g, new Rectangle(0, 0, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height), Color.Black, Color.White, voicePrintId, false, false); g.Dispose(); voicePrintId++; if (voicePrintId > this.pictureBoxSpectrum.Width - 1) { voicePrintId = 0; } break; case 15: pictureBoxSpectrum.Image = vis.CreateWaveForm(stream, this.pictureBoxSpectrum.Width, this.pictureBoxSpectrum.Height, Color.Green, Color.Red, Color.Gray, Color.Black, 1, true, false, true); break; } }
private void DrawSpectrum() { switch (_specIdx) { // normal spectrum (width = resolution) case 0: pictureBoxSpectrum.Image = _vis.CreateSpectrum(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.Lime, Color.Red, Color.Black, false, false, false); break; // normal spectrum (full resolution) case 1: pictureBoxSpectrum.Image = _vis.CreateSpectrum(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.SteelBlue, Color.Pink, Color.Black, false, true, true); break; // line spectrum (width = resolution) case 2: pictureBoxSpectrum.Image = _vis.CreateSpectrumLine(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.Lime, Color.Red, Color.Black, 2, 2, false, false, false); break; // line spectrum (full resolution) case 3: pictureBoxSpectrum.Image = _vis.CreateSpectrumLine(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.SteelBlue, Color.Pink, Color.Black, 16, 4, false, true, true); break; // ellipse spectrum (width = resolution) case 4: pictureBoxSpectrum.Image = _vis.CreateSpectrumEllipse(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.Lime, Color.Red, Color.Black, 1, 2, false, false, false); break; // ellipse spectrum (full resolution) case 5: pictureBoxSpectrum.Image = _vis.CreateSpectrumEllipse(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.SteelBlue, Color.Pink, Color.Black, 2, 4, false, true, true); break; // dot spectrum (width = resolution) case 6: pictureBoxSpectrum.Image = _vis.CreateSpectrumDot(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.Lime, Color.Red, Color.Black, 1, 0, false, false, false); break; // dot spectrum (full resolution) case 7: pictureBoxSpectrum.Image = _vis.CreateSpectrumDot(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.SteelBlue, Color.Pink, Color.Black, 2, 1, false, false, true); break; // peak spectrum (width = resolution) case 8: pictureBoxSpectrum.Image = _vis.CreateSpectrumLinePeak(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.SeaGreen, Color.LightGreen, Color.Orange, Color.Black, 2, 1, 2, 10, false, false, false); break; // peak spectrum (full resolution) case 9: pictureBoxSpectrum.Image = _vis.CreateSpectrumLinePeak(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.GreenYellow, Color.RoyalBlue, Color.DarkOrange, Color.Black, 23, 5, 3, 5, false, true, true); break; // wave spectrum (width = resolution) case 10: pictureBoxSpectrum.Image = _vis.CreateSpectrumWave(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.Yellow, Color.Orange, Color.Black, 1, false, false, false); break; // dancing beans spectrum (width = resolution) case 11: pictureBoxSpectrum.Image = _vis.CreateSpectrumBean(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.Chocolate, Color.DarkGoldenrod, Color.Black, 4, false, false, true); break; // dancing text spectrum (width = resolution) case 12: pictureBoxSpectrum.Image = _vis.CreateSpectrumText(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.White, Color.Tomato, Color.Black, "MPTagThat is Great", false, false, true); break; // frequency detection case 13: float amp = _vis.DetectFrequency(_stream, 10, 500, true); if (amp > 0.3) { pictureBoxSpectrum.BackColor = Color.Red; } else { pictureBoxSpectrum.BackColor = Color.Black; } break; // 3D voice print case 14: // we need to draw directly directly on the picture box... // normally you would encapsulate this in your own custom control Graphics g = Graphics.FromHwnd(pictureBoxSpectrum.Handle); g.SmoothingMode = SmoothingMode.AntiAlias; _vis.CreateSpectrum3DVoicePrint(_stream, g, new Rectangle(0, 0, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height), Color.Black, Color.White, _voicePrintIdx, false, false); g.Dispose(); // next call will be at the next pos _voicePrintIdx++; if (_voicePrintIdx > pictureBoxSpectrum.Width - 1) { _voicePrintIdx = 0; } break; // WaveForm case 15: pictureBoxSpectrum.Image = _vis.CreateWaveForm(_stream, pictureBoxSpectrum.Width, pictureBoxSpectrum.Height, Color.Green, Color.Red, Color.Gray, Color.Black, 1, true, false, true); break; } }
private void UpdateSpectrum() { Bitmap imgSpectrum = null; switch (specIdx) { // normal spectrum (width = resolution) case 0: imgSpectrum = _vis.CreateSpectrum(_stream, this.spectrumWidth, this.spectrumHeight, Color.Lime, Color.Red, Color.Black, false, false, false); break; // normal spectrum (full resolution) case 1: imgSpectrum = _vis.CreateSpectrum(_stream, this.spectrumWidth, this.spectrumHeight, Color.SteelBlue, Color.Pink, Color.Black, false, true, true); break; // line spectrum (width = resolution) case 2: imgSpectrum = _vis.CreateSpectrumLine(_stream, this.spectrumWidth, this.spectrumHeight, Color.Lime, Color.Red, Color.Black, 5, 2, false, false, false); break; // line spectrum (full resolution) case 3: imgSpectrum = _vis.CreateSpectrumLine(_stream, this.spectrumWidth, this.spectrumHeight, Color.SteelBlue, Color.Pink, Color.Black, 16, 4, false, true, true); break; // ellipse spectrum (width = resolution) case 4: imgSpectrum = _vis.CreateSpectrumEllipse(_stream, this.spectrumWidth, this.spectrumHeight, Color.Lime, Color.Red, Color.Black, 1, 2, false, false, false); break; // ellipse spectrum (full resolution) case 5: imgSpectrum = _vis.CreateSpectrumEllipse(_stream, this.spectrumWidth, this.spectrumHeight, Color.SteelBlue, Color.Pink, Color.Black, 2, 4, false, true, true); break; // dot spectrum (width = resolution) case 6: imgSpectrum = _vis.CreateSpectrumDot(_stream, this.spectrumWidth, this.spectrumHeight, Color.Lime, Color.Red, Color.Black, 1, 0, false, false, false); break; // dot spectrum (full resolution) case 7: imgSpectrum = _vis.CreateSpectrumDot(_stream, this.spectrumWidth, this.spectrumHeight, Color.SteelBlue, Color.Pink, Color.Black, 2, 1, false, false, true); break; // peak spectrum (width = resolution) case 8: imgSpectrum = _vis.CreateSpectrumLinePeak(_stream, this.spectrumWidth, this.spectrumHeight, Color.SeaGreen, Color.LightGreen, Color.Orange, Color.Black, 2, 1, 2, 10, false, false, false); break; // peak spectrum (full resolution) case 9: imgSpectrum = _vis.CreateSpectrumLinePeak(_stream, this.spectrumWidth, this.spectrumHeight, Color.GreenYellow, Color.RoyalBlue, Color.DarkOrange, Color.Black, 23, 5, 3, 5, false, true, true); break; // wave spectrum (width = resolution) case 10: imgSpectrum = _vis.CreateSpectrumWave(_stream, this.spectrumWidth, this.spectrumHeight, Color.Yellow, Color.Orange, Color.Black, 1, false, false, false); break; // dancing beans spectrum (width = resolution) case 11: imgSpectrum = _vis.CreateSpectrumBean(_stream, this.spectrumWidth, this.spectrumHeight, Color.Chocolate, Color.DarkGoldenrod, Color.Black, 4, false, false, true); break; // dancing text spectrum (width = resolution) case 12: imgSpectrum = _vis.CreateSpectrumText(_stream, this.spectrumWidth, this.spectrumHeight, Color.White, Color.Tomato, Color.Black, "BASS .NET IS GREAT PIECE! UN4SEEN ROCKS...", false, false, true); break; } SpectrumUpdate?.Invoke(imgSpectrum); }