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(); }
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); }
public MusicTime(VLA song) { TimeMilli = 0; Song = song; }