예제 #1
0
파일: Region.cs 프로젝트: HLBC/uMIDI
        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);
        }
예제 #2
0
파일: Region.cs 프로젝트: HLBC/uMIDI
        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));
        }
예제 #3
0
파일: Region.cs 프로젝트: HLBC/uMIDI
 public Region(List <TimedNote> notes, MetaState state)
 {
     _notes = notes.OrderBy(o => o.StartTime).ToList();
     State  = state;
 }
예제 #4
0
파일: Region.cs 프로젝트: HLBC/uMIDI
 public Region(MetaState state)
 {
     _notes = new List <TimedNote>();
     State  = state;
 }
예제 #5
0
 public MetaMidiStream()
 {
     MetaState  = new MetaState();
     MidiStream = new MidiStream();
 }
예제 #6
0
 public MetaMidiStream(int beatsPerMeasure, int subdivision, int bpm)
 {
     MetaState  = new MetaState(beatsPerMeasure, subdivision, bpm);
     MidiStream = new MidiStream();
     Transforms = new List <ITransform>();
 }