Skip to content

Allow visualizing both stereo channels of sample clips - #8497

Open
Itreza2 wants to merge 5 commits into
LMMS:masterfrom
Itreza2:stereo-sample-thumbnails
Open

Allow visualizing both stereo channels of sample clips#8497
Itreza2 wants to merge 5 commits into
LMMS:masterfrom
Itreza2:stereo-sample-thumbnails

Conversation

@Itreza2

@Itreza2 Itreza2 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

one of the goals listed in #1471
This PR allow to visualize stereo channels of sample clips.

Enregistrement.d.ecran_20260803_151824.mp4

As can be seen in the clip above, the default policy is to show the stereo channels when the track's height is two times the default. This can be changed in the setup dialog thank to a new combo box.

image

Implementation:

The nested class Thumbnail of SampleThumbnail has been slightly reworked to also store the peaks of the right and left ear channels. The rendering is then quite straightforward.

Possible cons:

This should not have any impact performance-wise, but cached thumbnails would occupy 3x the memory they are currently taking, which is I think very negligible but is worth mentioning.

@Itreza2 Itreza2 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Notes for reviewers

Comment thread include/SampleThumbnail.h
Thumbnail zoomOut(float factor) const;

Peak* data() { return m_peaks.data(); }
Peak& operator[](size_t index) { return m_peaks[index]; }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These operators no longer makes a lot of sense since the class is now holding 3 different arrays. Because they were unused anyway I've chosen to remove them.

, m_left_peaks(std::move(left_peaks))
, m_samplesPerPeak(samplesPerPeak)
{
assert(m_right_peaks.size() == m_left_peaks.size() && "Stereo peaks arrays lengths don't match");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This kind of precondition is bad, but Thumbnail is private in SampleThumbnail so it is unlikely this would cause any issue in the future.

if (useOriginalBuffer && drawOriginalBuffer)
{
const auto value = m_buffer->data()->data()[i];
const auto value = (

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm unsure about this block and what its previous version was aiming for.
The conditions for it to be executed are very uncommon tho.

@sakertooth

sakertooth commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

I feel like we should have a separate option for viewing both channels at the same time, but default to the mono view (which maybe we can also add a option to set their own default), so I am thinking something like a "Show stereo view" and "Show mono view" in the context menu for sample clips to swap between the two views.

There also is other stuff I might be able to review.

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