Exemplo n.º 1
0
        /*
         * Handling of raw (massaged) FFT'ed spectrum data.
         */

        public void SendData(double[] raw, bool bassBased)
        {
            double[] normalized = Normalize(raw, bassBased);
            int      filtered   = Filter(normalized);
            // Atrocious, but real-time debug only
            // Console.WriteLine(string.Join(" Handler ", normalized));
            // Console.WriteLine("Normalized: " + filtered);

            // Send filtered column to COM
            SamplerApp samp = new SamplerApp();

            samp.COMSend(filtered);
        }
Exemplo n.º 2
0
        /*
         * 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 = Properties.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("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("Exit SoundSampler", 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.SoundSamplerOFF.GetHicon());
            systrayIcon.Text        = "SoundSampler";
            systrayIcon.Visible     = true;
        }