Ejemplo n.º 1
0
        public override void MouseMove(int x, int y)
        {
            // keep adding or removing if we're dragging
            if (Handler.Action == ClipMouseAction.MultiSelect)
            {                
                var foundNote = Handler.Renderer.GetNoteAt(x, y);
                if (foundNote != null && isRemoving)
                {
                    Handler.Renderer.Clip.Notes.Remove(foundNote);
                    Handler.Renderer.Render();
                }
                else if (foundNote == null && isRemoving == false)
                {
                    var note = new SequencerClip.Note();
                    note.Length = 24;
                    note.Tick = MidiMath.Quantize(Handler.Renderer.GetTickAt(x), note.Length);
                    note.Pitch = Handler.Renderer.GetNoteAt(y);
                    note.Velocity = 100;
                    Handler.Renderer.Clip.Notes.Add(note);
                    Handler.Renderer.Clip.Sort();
                    Handler.Renderer.Render();
                }

            }
        }
Ejemplo n.º 2
0
        public override void MouseDown(int x, int y, Keys modifierKeys)
        {
            // action is always multiselect, to indicate we're going to
            // keep adding or removing as we go to new places
            Handler.Action = ClipMouseAction.MultiSelect;

            // delete a note if an existing on is clicked on
            var foundNote = Handler.Renderer.GetNoteAt(x, y);
            if (foundNote != null)
            {
                isRemoving = true;
                Handler.Renderer.Clip.Notes.Remove(foundNote);
            }
            else
            {
                isRemoving = false;
                // add a note if clicking outside of a note
                var note = new SequencerClip.Note();
                note.Length = 24;
                note.Tick = MidiMath.Quantize(Handler.Renderer.GetTickAt(x), note.Length);
                note.Pitch = Handler.Renderer.GetNoteAt(y);
                note.Velocity = 100;
                Handler.Renderer.Clip.Notes.Add(note);
                Handler.Renderer.Clip.Sort();
            }

            Handler.Renderer.Render();
        }
Ejemplo n.º 3
0
        public override void MouseMove(int x, int y)
        {
            Handler.MousePosition.Set(x, y);

            switch (Handler.Action)
            {
                case ClipMouseAction.MovingSingle:
                    Handler.Renderer.SelectedNote.Tick = MidiMath.Quantize(Handler.Renderer.GetTickAt(Handler.MousePosition.X), 24);
                    Handler.Renderer.SelectedNote.Pitch = Handler.Renderer.GetNoteAt(Handler.MousePosition.Y);
                    Handler.Renderer.Render();
                    break;
                case ClipMouseAction.MovingGroup:
                    // TODO: going to need to keep track of where the notes where when they started
                    foreach (var clip in Handler.Renderer.SelectedNotes)
                    {
                        SequencerClip.Note oclip;
                        if (!Handler.Original.TryGetValue(clip, out oclip)) continue;
                        clip.Tick = MidiMath.Quantize((int)(oclip.Tick + Handler.MousePosition.DeltaX / Handler.Renderer.PixelsPerTick), 24);
                        clip.Pitch = oclip.Pitch - (int)(Handler.MousePosition.DeltaY / Handler.Renderer.NoteHeight);
                    }
                    Handler.Renderer.Render();
                    break;
                case ClipMouseAction.Resize:
                    var endTick = Handler.Renderer.GetTickAt(Handler.MousePosition.X);
                    if (endTick > Handler.Renderer.SelectedNote.Tick)
                    {
                        Handler.Renderer.SelectedNote.Length = MidiMath.Quantize(endTick - Handler.Renderer.SelectedNote.Tick, 24);
                        Handler.Renderer.Render();
                    }
                    break;
                case ClipMouseAction.MultiSelect:
                    Handler.Renderer.SelectBox.Width = Handler.MousePosition.DeltaX;
                    Handler.Renderer.SelectBox.Height = Handler.MousePosition.DeltaY;
                    Handler.Renderer.Render();
                    break;
            }
        }
Ejemplo n.º 4
0
 public override void MouseMove(int x, int y)
 {
     if (Handler.Action == ClipMouseAction.MultiSelect)
     {
         var p = (float)x / (float)Handler.Renderer.Image.Width;
         Handler.ParentRenderer.Clip.LaunchPad.X = Handler.ParentRenderer.FirstTick = MidiMath.Quantize((int)(p * Handler.Renderer.WidthInTicks), 24 * 4);
         Handler.ParentRenderer.Render();
         Handler.Renderer.Render();
     }
 }
Ejemplo n.º 5
0
        public override void MouseDown(int x, int y, Keys modifierKeys)
        {
            // default action is none
            Handler.Action = ClipMouseAction.None;

            // save original mouse position
            Handler.MousePosition.SetStart(x, y);
            Handler.MousePosition.Set(x, y);

            // create a new note with control click.
            if (modifierKeys == Keys.Control)
            {
                var note = new SequencerClip.Note();
                note.Length = 24;
                note.Tick = MidiMath.Quantize(Handler.Renderer.GetTickAt(x), note.Length);
                note.Pitch = Handler.Renderer.GetNoteAt(y);
                note.Velocity = 100;
                Handler.Renderer.Clip.Notes.Add(note);
                Handler.Renderer.Clip.Sort();
                Handler.Renderer.Render();

                Handler.Renderer.SelectedNote = note;
                Handler.Renderer.SelectedNotes = null;

                Handler.Action = ClipMouseAction.Resize;
            }
            // select a single note if we click on a note
            else
            {
                // find the single note we clicked on
                Handler.Renderer.SelectedNote = Handler.Renderer.GetNoteAt(x, y);
                if (Handler.Renderer.SelectedNote == null)
                {
                    Handler.Renderer.SelectedNotes = null;
                }

                // if that note was part of an already selected group
                // then we need to move the entire group
                if (Handler.Renderer.SelectedNotes != null && Handler.Renderer.SelectedNotes.Contains(Handler.Renderer.SelectedNote))
                {
                    Handler.Action = ClipMouseAction.MovingGroup;
                }
                else if (Handler.Renderer.SelectedNote != null)
                {
                    // unselect group if not part of previous selected group
                    Handler.Renderer.SelectedNotes = null;

                    // decide action based on if we're at the start
                    // or the end of a note
                    var p = Handler.Renderer.GetPercentageThroughNoteAt(Handler.Renderer.SelectedNote, x);
                    if (p < 0.5f)
                    {
                        Handler.Action = ClipMouseAction.MovingSingle;
                    }
                    else
                    {
                        Handler.Action = ClipMouseAction.Resize;
                    }
                }
                else
                {
                    // multi select if we didn't click on anythin
                    Handler.Action = ClipMouseAction.MultiSelect;
                    Handler.Renderer.SelectBox.X = x;
                    Handler.Renderer.SelectBox.Y = y;
                    Handler.Renderer.SelectBox.Width = 1;
                    Handler.Renderer.SelectBox.Height = 1;
                    Handler.Renderer.ShowSelectBox = true;
                }
            }


            // save original values of selected notes
            if (Handler.Renderer.SelectedNotes != null)
            {
                Handler.UpdateOriginal(Handler.Renderer.SelectedNotes.ToArray());
            }
            else
            {
                Handler.UpdateOriginal(Handler.Renderer.SelectedNote);
            }

            // draw
            Handler.Renderer.Render();
        }