Esempio n. 1
0
        internal static void LatencyTest()
        {
            var ac = Mono.Audio.AudioDevice.CreateDevice("default");

            ac.SetFormat(Mono.Audio.AudioFormat.S16_LE, 1, 48000);
            short[] sample = new short[48000];
            for (int n = 0; n < sample.Length; n++)
            {
                sample[n] = (short)(0.5 * short.MaxValue * Math.Sin((2 * Math.PI * n * 440) / 48000));
            }

            Console.WriteLine("Ready. Press key to play note");
            Console.ReadKey();
            //  ac.PlaySample(sample, 48000);
            Console.WriteLine("done");

            _dev    = ac;
            _sample = sample;

            Console.WriteLine("now try a pi button");
            var bc = new PiAndBash.ButtonCatcher();

            bc.ButtonEvent += bc_ButtonEvent3;
            bc.Start();
        }
Esempio n. 2
0
        public static void WaitForAllButtonsAsync()
        {
            // http://stackoverflow.com/questions/3390286/making-a-console-application-like-a-windows-application

            PiAndBash.Display disp = new PiAndBash.Display();
            disp.TopLine    = "Simon";
            disp.BottomLine = "< EXIT";


            notePlayer = new NotePlayer();
            notePlayer.CreateSamples(new double[] { 440, 523 });
            PiAndBash.ButtonCatcher bc = new PiAndBash.ButtonCatcher();
            bc.ButtonEvent += bc_ButtonEvent2;



            bc.Start();
        }
Esempio n. 3
0
        public GameEngine(PiAndBash.Driver PiAndBashDriver, NotePlayer NotePlayer)
        {
            pnbDriver     = PiAndBashDriver;
            pnbDisplay    = new PiAndBash.Display(pnbDriver);
            leds          = new PiAndBash.LedController(pnbDriver);
            buttonCatcher = new PiAndBash.ButtonCatcher(pnbDriver);
            notePlayer    = NotePlayer;

            // set up the Notes and associations
            notes = new Dictionary <int, Note>();
            notes.Add(1, new Note()
            {
                Color = PiAndBash.LedController.LightColor.Green, Button = PiAndBash.ButtonCatcher.ButtonType.Down, Frequency = 349
            });
            notes.Add(2, new Note()
            {
                Color = PiAndBash.LedController.LightColor.Yellow, Button = PiAndBash.ButtonCatcher.ButtonType.Enter, Frequency = 440
            });
            notes.Add(3, new Note()
            {
                Color = PiAndBash.LedController.LightColor.Red, Button = PiAndBash.ButtonCatcher.ButtonType.Up, Frequency = 523
            });
        }