예제 #1
0
        public void LoadMIDI(string path)
        {
            try
            {
                using (System.IO.Stream inputStream = System.IO.File.OpenRead(path))
                {
                    sequence = MidiSequence.Open(inputStream);
                }

                var lbl = (Label)GetNode("SC/Label");
                lbl.Text = (string)sequence.ToString();

                Stop(); //Stop the player and clear the channels.

                //Set the MIDI sequence for the player.
                player.sequence = sequence;
                Clock.Reset(sequence.Tracks.Count); //RESET THE CLOCK.  This properly sets the number of tracks for the clock to check.

                AudioStreamGenerator streamGenerator = (AudioStreamGenerator)player.Stream;
                player.parser.ParseSequence(sequence, streamGenerator.MixRate);
            } catch (MidiParser.MidiParserException e) {
                GD.Print("WARNING:  Encountered a problem parsing MIDI.\n", e.ToString());
            }
        }