private void Start_Clicked(object sender, RoutedEventArgs e)
{
Instrument_Clicked(instrument);
try {
if (midiPlayer.IsPlaying) {
MessageBox.Show("The file is currently being played, please have it finish first.");
return;
}
if (i_Channel < 0) {
MessageBox.Show("Please select a channel to play first.");
return;
}
if (!midiPlayer.IsFinishedLoading) {
MessageBox.Show("Please wait for the MIDI file to finish loading");
return;
}
Stop.IsEnabled = true;
Stop.Width = Double.NaN;
Instruments.IsEnabled = false;
Instruments.Width = 0;
midiPlayer.PersistentChannel = i_Channel;
score.ResetScore();
InitializeCanvas();
Background.Visibility = Visibility.Visible;
ShowSubCanvas();
muteSelectedChannel.Visibility = Visibility.Visible;
muteSelectedChannel.IsChecked = !midiPlayer.PlayPersistentChannel;
pause.Visibility = Visibility.Visible;
pause.Header = "PAUSE";
playDuration.Restart();
CompositionTarget.Rendering += MoveCanvas;
CompositionTarget.Rendering += CanvasNotesScheduledAdder;
b_AnimationStarted = true;
midiPlayer.StartPlaying();
startTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
} catch (NullReferenceException ex) {
MessageBox.Show(
"Please load a MIDI file first! (or some other weird error occured, so read the proceeding message)");
MessageBox.Show(ex.ToString());
}
}