/* * Handling of raw (massaged) FFT'ed spectrum data. */ public void SendData(double[] raw, bool bassBased) { double[] normalized = Normalize(raw, bassBased); int filtered = Filter(normalized); // Real-time debug only - check FFT columns values // Console.WriteLine(string.Join(" ", normalized)); SamplerApp samp = new SamplerApp(); // Send filtered column to COM samp.COMSend(filtered); }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text)) { MessageBox.Show("Field is empty.", "No LED strip selected.", MessageBoxButtons.OK); } else { SamplerApp SamplerApp = new SamplerApp(); byte[] RGB = getColours(); int LEDNumber = int.Parse(textBox1.Text); SamplerApp.COMSetColour(RGB, LEDNumber); } }
/* * Set up the application. Configures the main app handler, creates and initializes the * systray icon and its context menu, and makes the icon visible. */ public SamplerAppContext() { // Create on exit handler and application data file handling. SamplerApp = new SamplerApp(); this.selectedPort = Settings.Default.Port; MenuItem COMList = new MenuItem("COM List"); COMlist().ForEach(COM => COMList.MenuItems.Add(new MenuItem(COM, (s, e) => SetCOMPort(s, COM.ToString(), COMList.Index)))); systrayIcon = new NotifyIcon(); systrayIcon.ContextMenu = new ContextMenu(new MenuItem[] { COMList, new MenuItem("Update Speed", new MenuItem[] { new MenuItem("Slow (30Hz)", (s, e) => UpdateSpeed_Click(s, Slow_MS, 0)), new MenuItem("Medium (60Hz)", (s, e) => UpdateSpeed_Click(s, Med_MS, 1)), new MenuItem("Fast (120Hz)", (s, e) => UpdateSpeed_Click(s, Fast_MS, 2)), new MenuItem("Full (400Hz)", (s, e) => UpdateSpeed_Click(s, Veryfast_MS, 3)), new MenuItem("Exp (1000Hz)", (s, e) => UpdateSpeed_Click(s, Exp_MS, 4)), new MenuItem("yolo (9999Hz)", (s, e) => UpdateSpeed_Click(s, yolo_MS, 5)), }), new MenuItem("Sound columns", new MenuItem[] { // No fking clue if that's a bad idea to implement a boolean here, seems to work fine. new MenuItem("Bass", (s, e) => AudioRange_Handling(s, true, 0)), new MenuItem("Octaves", (s, e) => AudioRange_Handling(s, false, 1)), }), new MenuItem("Corrector", Corrector), new MenuItem("Exit WASAPI Arduino", OnApplicationExit) });; // Default options precheck. systrayIcon.ContextMenu.MenuItems[0].MenuItems[portIndex].Checked = true; systrayIcon.ContextMenu.MenuItems[1].MenuItems[updateSpeedIndex].Checked = true; systrayIcon.ContextMenu.MenuItems[2].MenuItems[audioHandlingIndex].Checked = true; systrayIcon.MouseClick += SystrayIcon_Click; systrayIcon.Icon = Icon.FromHandle(Resources.WASAPI_ArduinoOFF.GetHicon()); systrayIcon.Text = "WASAPI Arduino"; systrayIcon.Visible = true; }
/* * Set up the application. Configures the main app handler, creates and initializes the * systray icon and its context menu, and makes the icon visible. */ public SamplerAppContext() { // Create on exit handler and application data file handling. SamplerApp = new SamplerApp(); this.selectedPort = Settings.Default.Port; MenuItem COMList = new MenuItem("COM List"); List <string> portList = COMlist(); COMlist().ForEach(COM => COMList.MenuItems.Add(new MenuItem(COM, (s, e) => GetCOMIndex(s, COM.ToString(), portList)))); systrayIcon = new NotifyIcon(); systrayIcon.ContextMenu = new ContextMenu(new MenuItem[] { new MenuItem("Sound columns", new MenuItem[] { new MenuItem("Bass", (s, e) => AudioRange_Handling(s, true, 0)), new MenuItem("Octaves", (s, e) => AudioRange_Handling(s, false, 1)), }), new MenuItem("Corrector", Corrector), new MenuItem("Change colour", new MenuItem[] { new MenuItem("Global change", Palette), new MenuItem("Multiple strips", NextLed) }), new MenuItem("Settings", new MenuItem[] { COMList, new MenuItem("Update Speed", new MenuItem[] { new MenuItem("Slow (30Hz)", (s, e) => UpdateSpeed_Click(s, Slow_MS, 0)), new MenuItem("Medium (60Hz)", (s, e) => UpdateSpeed_Click(s, Med_MS, 1)), /* Options below are redundant I guess, * * new MenuItem("Fast (120Hz)", (s, e) => UpdateSpeed_Click(s, Fast_MS, 2)), * new MenuItem("Regular LED Strip (400Hz)", (s, e) => UpdateSpeed_Click(s, regularLEDStrip_MS, 3)), * new MenuItem("Fastest LED strip (1000Hz)", (s, e) => UpdateSpeed_Click(s, fastestLEDStrip_MS, 4)), */ new MenuItem("Regular audio output (44100Hz)", (s, e) => UpdateSpeed_Click(s, regular_MS, 2)), new MenuItem("Studio audio output (88200Hz)", (s, e) => UpdateSpeed_Click(s, double_MS, 3)) }), new MenuItem("Start with Windows", SetAutostart), new MenuItem("Launch on startup", SetStartupBeh) }), new MenuItem("Help", HelpForm), new MenuItem("Exit WASAPI Arduino", OnApplicationExit) }); // Default options precheck. systrayIcon.ContextMenu.MenuItems[0].MenuItems[audioHandlingIndex].Checked = true; systrayIcon.ContextMenu.MenuItems[3].MenuItems[0].MenuItems[portIndex].Checked = true; systrayIcon.ContextMenu.MenuItems[3].MenuItems[1].MenuItems[updateSpeedIndex].Checked = true; systrayIcon.ContextMenu.MenuItems[3].MenuItems[2].Checked = Settings.Default.StartWithWin; systrayIcon.ContextMenu.MenuItems[3].MenuItems[3].Checked = Settings.Default.StartupBeh; systrayIcon.MouseClick += SystrayIcon_Click; systrayIcon.Icon = Icon.FromHandle(Resources.WASAPI_ArduinoOFF.GetHicon()); systrayIcon.Text = "WASAPI Arduino"; systrayIcon.Visible = true; if (Settings.Default.ranalready == true) { SamplerApp.COMSetColour(Settings.Default.hex); } if (Settings.Default.StartupBeh) { enabled = true; systrayIcon.Icon = Icon.FromHandle(Resources.WASAPI_ArduinoON.GetHicon()); SamplerApp.SetEnabled(enabled); } }