Пример #1
0
        public void UpdateScore(ref MidiPlayer midiPlayer)
        {
            if (midiPlayer == null)
                return;

            // this is a hack, we shouldn't be modifying this list in the MidiPlayer, it should be used for
            // informational purposes
            for (int i = 0; i < midiPlayer.al_CurrentPlayingChannelNotes.Count; i++) {
                try {
                    if (noteMatcher.NoteMatches(s_CurrentFingering, (int)midiPlayer.al_CurrentPlayingChannelNotes[i])) {
                        i_NumNotesScored++;
                        midiPlayer.al_CurrentPlayingChannelNotes.RemoveAt(i);
                        break;
                    }
                } catch (Exception e) {
                    //Got tired of it crashing randomly. Fix it later.
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Event handler for "Open" menu item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Open_Clicked(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "MIDI Files (*.mid)|*.mid|All Files (*.*)|*.*";
            openFileDialog.FilterIndex = 1;

            if (openFileDialog.ShowDialog().Value) {
                try {
                    midiPlayer.OnClosingOperations();
                    midiPlayer.OnClosedOperations();
                } catch (NullReferenceException ex) { }

                HideSubCanvas();
                ResetSubCanvas(true);

                HideCanvasChildren();

                b_AnimationStarted = false;
                CompositionTarget.Rendering -= MoveCanvas;
                CompositionTarget.Rendering -= CanvasNotesScheduledAdder;
                normal.Visibility = Visibility.Hidden;
                try {
                    loadingScreen.Visibility = Visibility.Hidden;
                } catch (NullReferenceException ex) { }

                listViewGrid.Visibility = Visibility.Hidden;
                loadingScreen.Visibility = Visibility.Visible;
                i_Channel = -1;

                midiPlayer = new MidiPlayer(
                    openFileDialog.FileName,
                    HandleMIDILoadProgressChanged,
                    HandleMIDILoadCompleted,
                    HandleMIDIChannelMessagePlayed,
                    HandleMIDIPlayingCompleted);
                //midiPlayerForPreview = new MidiPlayer(midiPlayer.Sequence, midiPlayer.Sequencer);

                midiPlayer.PlayOtherChannels = true;

                midiInfo.Refresh(openFileDialog.FileName, i_Channel);
                tb_listViewTitle.Text = midiInfo.Title;
            }
        }