Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
 public void AddClip(Clip c)
 {
     clips.Add(c);
     c.Channel = this;
 }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 public void RemoveClip(Clip c)
 {
     if (clips.Remove(c))
     {
         c.Channel = null;
     }
 }
Ejemplo n.º 5
0
 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);
     }
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 7
0
 private void OnClipEditRequested(Clip clicked)
 {
     if (ClipEditRequested != null)
     {
         ClipEditRequested(clicked);
     }
 }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        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();
        }