Ejemplo n.º 1
0
        void DrawNoteVelocities(Sequencer sequencer, float start, float end, float width)
        {
            if (sequencer.allNotes == null)
            {
                return;
            }

            List <Note> notes = sequencer.GetAllNoteOnsInRange(start, end);

            foreach (Note note in notes)
            {
                float percent = (note.start - start) / (end - start);
                DrawNote(percent * width, note.velocity, velocityColor);
            }
        }
Ejemplo n.º 2
0
        void MouseDown(Rect rect, Sequencer sequencer, Vector2 mousePosition, SerializedProperty allNotes)
        {
            currentNote = null;
            float closest = 2.0f * velocityHandleGrabWidth;
            float mouseX  = mousePosition.x - rect.x - leftPadding;
            float mouseY  = mousePosition.y - rect.y;

            List <Note> noteOns = sequencer.GetAllNoteOnsInRange(startTime, endTime);

            foreach (Note note in noteOns)
            {
                float x         = sixteenthWidth * (note.start - startTime);
                float yInv      = note.velocity * (rect.height - velocityHandleWidth) + velocityHandleWidth / 2.0f;
                float y         = rect.height - yInv;
                float xDiff     = Mathf.Abs(x - mouseX);
                float yDiff     = Mathf.Abs(y - mouseY);
                float diffTotal = xDiff + yDiff;

                if (xDiff <= velocityHandleGrabWidth && yDiff <= velocityHandleGrabWidth && diffTotal < closest)
                {
                    closest     = diffTotal;
                    currentNote = note;

                    SerializedProperty serializedNoteRow  = allNotes.GetArrayElementAtIndex(currentNote.note);
                    SerializedProperty serializedNoteList = serializedNoteRow.FindPropertyRelative("notes");
                    List <Note>        noteList           = sequencer.allNotes[currentNote.note].notes;
                    int index = noteList.IndexOf(currentNote);
                    if (index >= 0)
                    {
                        currentNoteSerialized = serializedNoteList.GetArrayElementAtIndex(index);
                    }
                }
            }

            if (currentNote != null)
            {
                Undo.RegisterCompleteObjectUndo(sequencer, "Set Note Velocity");
            }
        }