Example #1
0
        public void PianoKeyDown(object o, PianoEventArgs e)
        {
            int Octave = e.Key / 12;
            int Key    = e.Key % 12;

            this.nudOctave.Value       = Octave;
            this.cbPitch.SelectedIndex = Key;

            try {
                MidiOutputHandler.GetInstance().SendQuickNoteOnMessage(0, 0, 0, 4, e.Key);
            }
            catch (AccessViolationException) {
                MessageBox.Show(
                    "Memory read/write error has occured.\n\n" +
                    "You should save all your work because the application\n" +
                    "is in an unsafe state and restart the software!\n\n" +
                    "Reason: The MIDI playback subsystem has been crashed and could not be restarted.\n" +
                    "Any MIDI output interaction will crash the entire software.\n\n" +
                    "The application will not exit when you click the OK button.",
                    "Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
            }
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            this.Config.Save();

            MidiOutputHandler.GetInstance().ReinitializeDevice(this.Config.MidiOutputDeviceID);

            this.Close();
        }
Example #3
0
        public static void Initialize(int DeviceID)
        {
            if (MidiOutputHandler.Instance != null)
            {
                throw new InvalidOperationException("Only one instance is allowed of MidiOutputHandler and it is already initialized.");
            }

            MidiOutputHandler.Instance = new MidiOutputHandler(DeviceID);
        }
        public MidiPlaybackDialog(Measure m, int Tempo, IEnumerable <StyleEntry> Messages)
        {
            InitializeComponent();

            this.Player = new MidiMessagePlayer(
                Tempo,
                MidiOutputHandler.GetInstance().Device,
                Messages
                );

            pbPosition.Maximum = Player.TotalTime;
            pbBeat.Maximum     = m.Numerator;
            this.Measure       = m;
        }
Example #5
0
 public void PianoKeyUp(object o, PianoEventArgs e)
 {
     try {
         MidiOutputHandler.GetInstance().SendQuickNoteOffMessage(4, e.Key);
     }
     catch (AccessViolationException) {
         MessageBox.Show(
             "Memory read/write error has occured.\n\n" +
             "You should save all your work because the application\n" +
             "is in an unsafe state and restart the software!\n\n" +
             "Reason: The MIDI playback subsystem has been crashed.\n" +
             "Any MIDI output interaction will crash the entire software.",
             "Error",
             MessageBoxButtons.OK,
             MessageBoxIcon.Error
             );
     }
 }
Example #6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            frmStartupScreen Startup = new frmStartupScreen();

            Startup.Show();

            Startup.Status = StartupStatus.InitMidiOutDevice;
            Properties.Settings s = new Properties.Settings();
            MidiOutputHandler.Initialize(s.MidiOutputDeviceID);
            Startup.Status = StartupStatus.None;

            Thread.Sleep(2000);
            Startup.Close();

            Application.Run(new frmMainWindow());

            MidiOutputHandler.DisposeInstance();
        }