/// <summary> /// Add a note to the sequencer. /// </summary> /// <returns>The Note object added to the seqeuncer.</returns> /// <param name="note">The MIDI note.</param> /// <param name="start">The start of the note measured in sixteenths.</param> /// <param name="end">The end of the note measured in sixteenths.</param> /// <param name="velocity">The velocity of the note (how hard the key is hit).</param> public Note AddNote(int note, float start, float end, float velocity = 1.0f) { ClampNotesInRange(note, start, end); note = Mathf.Clamp(note, 0, Utils.kMidiSize - 1); Note noteObject = new Note() { note = note, start = start, end = end, velocity = velocity, parent = this }; noteObject.TryCreate(); if (allNotes[note] == null) { allNotes[note] = new NoteRow(); } allNotes[note].notes.Add(noteObject); allNotes[note].notes.Sort(noteComparer); AddSortedNoteEvents(noteObject); return(noteObject); }
void DrawRowNotes(NoteRow row) { if (row == null || row.notes == null) { return; } foreach (Note note in row.notes) { DrawNote(note.start, note.velocity, velocityColor); } }
void CopyNoteRowToSerializedProperty(NoteRow row, SerializedProperty serializedRow) { SerializedProperty noteList = serializedRow.FindPropertyRelative("notes"); noteList.arraySize = row.notes.Count; for (int i = 0; i < row.notes.Count; ++i) { Note note = row.notes[i]; SerializedProperty serializedNote = noteList.GetArrayElementAtIndex(i); CopyNoteToSerializedProperty(note, serializedNote); } }
void DrawActiveNotes(Sequencer sequencer, float divisionLength) { if (sequencer.allNotes == null) { return; } for (int i = minKey; i <= maxKey; ++i) { NoteRow row = sequencer.allNotes[i]; if (row != null) { DrawRowNotes(row.notes, divisionLength); } } }
protected void InitNoteRows() { sortedNoteOns.Clear(); sortedNoteOffs.Clear(); for (int i = 0; i < allNotes.Length; ++i) { if (allNotes[i] == null) { allNotes[i] = new NoteRow(); } foreach (Note note in allNotes[i].notes) { AddSortedNoteEvents(note); } } }
void DrawActiveNotes(Sequencer sequencer, float divisionLength, Rect drawableArea) { if (sequencer.allNotes == null) { return; } int lastKey = GetMaxVisibleKey(); int firstKey = GetMinVisibleKey(drawableArea.height); for (int i = firstKey; i <= lastKey; ++i) { NoteRow row = sequencer.allNotes[i]; if (row != null) { DrawRowNotes(row.notes, divisionLength, drawableArea); } } }