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(); }
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; }
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 ); } }