コード例 #1
0
        public MidiPlayer(Beeper beeper, string fileName)
        {
            midiFile = new MidiFile(fileName);
            this.beeper = beeper;

            frequency = new MidiFrequency();
        }
コード例 #2
0
        public PlayForm()
        {
            InitializeComponent();

            keyMapping.Add(Keys.A, Note.C);
            keyMapping.Add(Keys.S, Note.D);
            keyMapping.Add(Keys.D, Note.E);
            keyMapping.Add(Keys.F, Note.F);
            keyMapping.Add(Keys.G, Note.G);
            keyMapping.Add(Keys.H, Note.A);
            keyMapping.Add(Keys.J, Note.B);

            comboBox1.Items.AddRange(SerialPort.GetPortNames());

            beeper = new Beeper();
            // a = () => beeper.Play((uint)random.Next(100, 1000));
        }
コード例 #3
0
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new PlayForm());

            Beeper beeper = new Beeper();
            beeper.SerialPort = new SerialPort("COM6", 9600);
            beeper.SerialPort.Open();
            Console.WriteLine("opened!");

            beeper.Handshake();
            Console.WriteLine("handsheked: speakers " + beeper.SpeakerCount);

            MidiPlayer player = new MidiPlayer(beeper, "imperial.mid");
            player.Play();

            while (true) {
                Thread.Yield();
            }

            // RunTests();
        }