Skip to content

Modified Sample and Automation Tracks so that new clips match the Snapping Size#8267

Open
AbbyBuchholz wants to merge 5 commits intoLMMS:masterfrom
AbbyBuchholz:master
Open

Modified Sample and Automation Tracks so that new clips match the Snapping Size#8267
AbbyBuchholz wants to merge 5 commits intoLMMS:masterfrom
AbbyBuchholz:master

Conversation

@AbbyBuchholz
Copy link

Worked on issue #8038, added two helper functions (autoResize, getDefaultClipLength) for sizing to Clip.cpp and modified SampleTrack.cpp and AutomationTrack.cpp's createClip functions to use it, thus allowing default snapping sized clips for both editors.

@AbbyBuchholz AbbyBuchholz changed the title Modified Sample and Automation Tracks so that new clips match the Snapping Size #8038 Modified Sample and Automation Tracks so that new clips match the Snapping Size Feb 18, 2026
Copy link
Member

@regulus79 regulus79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was super rushed, so I just wrote what I noticed/came to mind.

It appears this PR also prevents users from adding clips which start on top of other clips, which was not described in the PR description(?) (But I totally agree, that is a good feature. It is kind of weird how you can sometimes add an empty clip on another when you mean to click it or something.)


#include "AutomationEditor.h"
#include "AutomationClip.h"
#include "embed.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is "embed.h" necessary to be included here?


const tick_t snapTicks = static_cast<tick_t>(snapSize * TimePos::ticksPerBar());

return std::max(snapTicks, static_cast<tick_t>(TimePos::ticksPerBar() / 16));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the minimum clip size ticksPerBar() / 16?

return m_startTimeOffset;
}

tick_t Clip::getDefaultClipLength()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function does not depend on anything regarding clips, only the editor, would it make sense to move it to TrackContainer?

{
if (pos < existingClip->endPosition() && endPos > existingClip->startPosition())
{
return nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about returning nullptr here, since TrackContentWidget.cpp line 541 appears to call functions on the returned clip without checking if it's nullptr or not, when pasting clips.

auto p = new AutomationClip(this);
p->movePosition(pos);
return p;
const TimePos endPos = pos + TimePos(Clip::getDefaultClipLength());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Clip::getDefaultClipLength were moved to TrackContainer, I believe you could do m_trackContainer->defaultClipLength(), so you also wouldn't need to include Clip.h.

@regulus79
Copy link
Member

Getting it to work for PatternTrack should be fairly straight-forward. I don't have time right now, but if you want me to put together some sample code for it, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants