Beispiel #1
0
        void AlertIfNoteOverflows(NoteList noteList, IEnumerable <NotePair> pairs)
        {
            var overflowedNoteCount = noteList.Count() - pairs.Count();

            if (overflowedNoteCount > 0)
            {
                EditorUtility.DisplayDialog(overflowedNoteCount + " notes overflowed", overflowedNoteCount + " notes overflowed. Create more NoteViews.", "OK");
            }
        }
Beispiel #2
0
        public NoteList Read(string path)
        {
            var smf = MidiFileLoader.Load(File.ReadAllBytes(path));

            var conductorTrack = smf.tracks[0];
            var noteTrack      = smf.tracks[1];

            var tempoMap         = new TempoMap(smf.division);
            var timeSignatureMap = new TimeSignatureMap(smf.division);

            ParseConductorTrack(conductorTrack, tempoMap, timeSignatureMap);

            var noteList = new NoteList(tempoMap, timeSignatureMap);

            ParseNoteTrack(smf, noteTrack, noteList);

            return(noteList);
        }
Beispiel #3
0
        void ParseNoteTrack(MidiFileContainer smf, MidiTrack noteTrack, NoteList noteList)
        {
            var ticks = 0;

            foreach (var ev in noteTrack)
            {
                ticks += ev.delta;
                if (!ev.midiEvent.HasValue)
                {
                    continue;
                }
                if (ev.midiEvent.Value.statusType != MidiEvent.StatusType.NOTE_ON)
                {
                    continue;
                }

                noteList.Add(ticks);
            }
        }