public PianoRoll() { InitializeComponent(); this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); Refresh(); // TEMP TEST Clip = new Clip(); Clip.NoteEvents.Add(new Clip.NoteEvent(50, 100, 4, 8)); Clip.NoteEvents.Add(new Clip.NoteEvent(52, 100, 10, 8)); }
public void AddClip(Clip c) { clips.Add(c); c.Channel = this; }
public Clip Clone() { Clip c = new Clip(); c.Channel = Channel; c.StartTime = StartTime; c.Length = Length; foreach (Event e in ControllerEvents) { c.ControllerEvents.Add(e.Clone()); } foreach (NoteEvent e in NoteEvents) { c.NoteEvents.Add(e.Clone()); } return c; }
public void RemoveClip(Clip c) { if (clips.Remove(c)) { c.Channel = null; } }
public void ReadChunk(string id, long length, DarkInStream s) { if (id.Equals("CLIP")) { Clip c = new Clip(); c.Read(s); AddClip(c); } else if (id.Equals("PTCH")) { Patch p = new Patch(s); AddPatch(p); } }
Rectangle NoteToRect(Clip.NoteEvent note) { int i = numKeys - note.Note - 1; int y = i * keyHeight - 1; int h = keyHeight; int x = note.StartTime * pixelsPerTick; int w = note.Length * pixelsPerTick - 1; return new Rectangle(x, y, w, h); }
private void OnClipEditRequested(Clip clicked) { if (ClipEditRequested != null) { ClipEditRequested(clicked); } }
private void ChannelTimeline_MouseUp(object sender, MouseEventArgs e) { if (moving || selecting) { selectedChannel = GetChannelClosestTo(e.Y); } mousePos = e.Location; if (moving) { Point m = GetSelectedClipsMovement(); foreach(Clip clip in selectedClips) { Clip c = clip; if (copying) { c = c.Clone(); Sequencer.Song.Channels[c.Channel.Number].AddClip(c); } c.StartTime += m.X; if (m.Y != 0) { int oldChannel = c.Channel.Number; int newChannel = oldChannel + m.Y; Sequencer.Song.Channels[oldChannel].RemoveClip(c); Sequencer.Song.Channels[newChannel].AddClip(c); } } } if (creating) { UpdateCreatedClip(); createdClip.Channel.AddClip(createdClip); selectedClips.Clear(); selectedClips.Add(createdClip); createdClip = null; } moving = false; selecting = false; creating = false; Refresh(); }
private void ChannelTimeline_MouseDown(object sender, MouseEventArgs e) { Channel lastSelected = selectedChannel; selectedChannel = GetChannelClosestTo(e.Y); Clip clickedClip = GetClipAt(e.Location); if (e.Button == MouseButtons.Left) { if (!selectedClips.Contains(clickedClip)) { selectedClips.Clear(); if (clickedClip != null) { selectedClips.Add(clickedClip); } } if (clickedClip != null) { moving = true; } else if (selectedChannel == lastSelected) { creating = true; createdClip = new Clip(); createdClip.Channel = selectedChannel; int t = ConvertXToTime(e.X); createdClip.StartTime = t - t % (Sequencer.Song.TicksPerBar); createdClip.Length = Sequencer.Song.TicksPerBar; } mouseDownPos = e.Location; } mousePos = e.Location; Refresh(); }