Esempio n. 1
0
        public void PlaySong(VLA song)
        {
            Timer       timer        = new Timer();
            MidiOut     midi         = new MidiOut(0);
            List <Note> playingNotes = DumpNotesFromChannel(song, 1);
            int         songTime     = 0;
            //Just gets the last note to end song
            int songLength = playingNotes.Max(t => t.milliIntoSongEnd);

            //NEVER, EVER EVER DO THIS. THIS IS GROSS, AND THIS IS WRONG
            timer.Elapsed += (sender, e) => { PlayNote(midi, playingNotes, ref songTime, ref timer, songLength); };
            //Every 16 milliseconds, we check which notes are to be played
            timer.Interval = 5;
            timer.Start();
        }
Esempio n. 2
0
        private List <Note> DumpNotesFromChannel(VLA song, int channelID)
        {
            List <Note> Notes         = new List <Note>();
            Channel     dumpedChannel = song.GetChannel(channelID);

            foreach (Bar b in dumpedChannel.Bars)
            {
                //Time taken for whole note to play
                int barTimeIntoSong = b.BarNo * 400;
                int timeIntoBar     = 0;
                foreach (List <Note> noteList in b.notes)
                {
                    foreach (Note n in noteList)
                    {
                        n.milliIntoSongStart = barTimeIntoSong + timeIntoBar;
                        n.milliIntoSongEnd   = n.milliIntoSongStart + Convert.ToInt32(n.Length * 400);
                        Notes.Add(n);
                    }
                    timeIntoBar += Convert.ToInt32(noteList[0].Length * 400);
                }
            }

            return(Notes);
        }
Esempio n. 3
0
 public MusicTime(VLA song)
 {
     TimeMilli = 0;
     Song      = song;
 }