private void midi_Playing(object sender, MidiPlayingEventArgs e)
 {
     if (e.Finished)
     {
         Invoke(new Action(() =>
         {
             playButton.Enabled = true;
             stopButton.Enabled = false;
         }));
     }
     e.Cancel = stopPlaying;
 }
Exemple #2
0
 public void Play(Recording recording, int noteLength, byte volume)
 {
     for (int tick = 0; tick < recording.BeatCount; tick++)
     {
         Play(recording.getMidiNotes(tick), volume);
         if (MidiPlaying != null)
         {
             MidiPlayingEventArgs e = new MidiPlayingEventArgs();
             MidiPlaying(this, e);
             if (e.Cancel)
             {
                 return;
             }
         }
         Thread.Sleep(noteLength);
     }
     if (MidiPlaying != null)
     {
         MidiPlaying(this, new MidiPlayingEventArgs()
         {
             Finished = true
         });
     }
 }