public static Region combineRegions(IList <Region> regions, MetaState metaState) { List <TimedNote> notesNotSorted = new List <TimedNote>(); foreach (Region region in regions) { notesNotSorted.AddRange(region._notes); } Region retVal = new Region( notesNotSorted, metaState); return(retVal); }
public static Region Messages2Region(IMessage[] buffer, MetaState state) { List <TimedNote> notes = new List <TimedNote>(buffer.Length); Dictionary <byte, TimedNote> notesOn = new Dictionary <byte, TimedNote>(); long currentTime = 0; foreach (IMessage message in buffer) { currentTime += message.TimeDelta; if (message is NoteOnMessage noteOnMessage) { TimedNote newNote = new TimedNote( noteOnMessage.Note.Channel, noteOnMessage.Note.Pitch, noteOnMessage.Note.Velocity, currentTime, null ); notes.Add(newNote); notesOn.Add(newNote.Pitch, newNote); } else if (message is NoteOffMessage noteOffMessage) { if (notesOn.ContainsKey(noteOffMessage.Note.Pitch)) { notesOn.GetValueOrDefault(noteOffMessage.Note.Pitch) .EndTime = currentTime; } else { TimedNote newNote = new TimedNote( noteOffMessage.Note.Channel, noteOffMessage.Note.Pitch, noteOffMessage.Note.Velocity, null, currentTime ); notes.Add(newNote); } } } return(new Region(notes, state)); }
public Region(List <TimedNote> notes, MetaState state) { _notes = notes.OrderBy(o => o.StartTime).ToList(); State = state; }
public Region(MetaState state) { _notes = new List <TimedNote>(); State = state; }
public MetaMidiStream() { MetaState = new MetaState(); MidiStream = new MidiStream(); }
public MetaMidiStream(int beatsPerMeasure, int subdivision, int bpm) { MetaState = new MetaState(beatsPerMeasure, subdivision, bpm); MidiStream = new MidiStream(); Transforms = new List <ITransform>(); }