lmms
lmms copied to clipboard
Add splitting to all types of clips
Makes the knife tool work for all types of clips, not just SampleClip
s.
Changes
Most of the code is copied from SampleClipView.cpp
's splitClip()
function, and then modified for each clip type.
- A couple changes had to be made to
ClipView.cpp
to allow splitting more than justSampleClip
s, and to hold off on dragging clips that cannot be resized (MidiClip
s) when knife mode is enabled. - Splitting
PatternClip
s was trivial. - Splitting
AutomationClip
s andMidiClip
s was more involved, as becausesetStartTimeOffset()
appears to do nothing, it required copying the correct nodes over and offsetting them back by the length of the left clip. However, the original clip still had all the notes, which meant that if the user changed some of them, its length would snap back to full. I had difficulty finding a good way to delete certain notes via a loop, so I decided to instead spawn two new clips, one left and one right, populate them with notes, and delete the original clip.
Notes
- In
AutomationClipView.cpp
, for some reason when splitting an automation clip, the new clips sometimes sets themselves to record mode. I added a temporary fix for this by setting the recording mode to the mode of the original clip. - ~~Because
MidiClip
s are only drawn in multiples of 1 bar, splitting them between bars led to buggy graphics. Because of this, I forced the split position to be a multiple of a bar.~~ - I am not an expert in how to have objects properly remove themselves without memory issues. I called ~~
remove()
~~close()
at the end ofspltiClip()
forAutomationClipView.cpp
andMidiClipView.cpp
, so I hope that takes care of everything.