Skip to content

Audio buffer views - #7945

Merged
messmerd merged 9 commits into
LMMS:masterfrom
messmerd:audio-buffer-view
Jun 9, 2025
Merged

Audio buffer views#7945
messmerd merged 9 commits into
LMMS:masterfrom
messmerd:audio-buffer-view

Conversation

@messmerd

@messmerd messmerd commented Jun 7, 2025

Copy link
Copy Markdown
Member

Adds two non-owning views for audio buffers: InterleavedBufferView and PlanarBufferView.

The channel count can be specified at either compile-time or runtime. Specifying at compile-time provides both performance and space optimizations. The way this works is the same as std::span except this uses the new DynamicChannelCount constant rather than std::dynamic_extent.

These are not used for anything yet, but will be used in #7459 and #7858.

@messmerd
messmerd requested a review from sakertooth June 7, 2025 23:47

@sakertooth sakertooth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall nice job, the transition to use this PR in #7858 was almost seamless.

Comment thread include/AudioBufferView.h
Comment thread include/AudioBufferView.h Outdated
Comment thread include/AudioBufferView.h
@sakertooth

Copy link
Copy Markdown
Contributor

The PR is fine with me, you can merge on your own terms.

@sakertooth

Copy link
Copy Markdown
Contributor

Oh yeah, I also thought about something: Do we care for sample rate support?

@messmerd

messmerd commented Jun 9, 2025

Copy link
Copy Markdown
Member Author

Oh yeah, I also thought about something: Do we care for sample rate support?

Maybe that could be handled separately, at least for now

@messmerd
messmerd merged commit 53d30d8 into LMMS:master Jun 9, 2025
@sakertooth

Copy link
Copy Markdown
Contributor

Maybe that could be handled separately, at least for now

I am thinking of a situation where we have an audio source (e.g., Sample) writing to a buffer at a certain sample rate, and that knowledge is needed in a class that has to resample that audio to another rate. This differs from the current approach to resampling, where the resampler happens internally, so inside Sample::play, Sf2Instrument::renderFrames, etc.

If I need this for some reason though I can add it, I am just going through a couple more designs for the PR.

@messmerd

messmerd commented Jun 9, 2025

Copy link
Copy Markdown
Member Author

I think I'd prefer if the buffer views didn't store that information, since most places where I use them the sample rate isn't needed, so it would just waste space.

@sakertooth

Copy link
Copy Markdown
Contributor

I think I'd prefer if the buffer views didn't store that information, since most places where I use them the sample rate isn't needed, so it would just waste space.

Yeah I was thinking about this. Most of the time it won't be needed so it should be handled separately on a case by case basis.

@messmerd
messmerd deleted the audio-buffer-view branch June 19, 2025 15:18
sakertooth pushed a commit to sakertooth/lmms that referenced this pull request Jun 28, 2025
Adds two non-owning views for audio buffers: `InterleavedBufferView` and `PlanarBufferView`.

The channel count can be specified at either compile-time or runtime. Specifying at compile-time provides both performance and space optimizations. The way this works is the same as `std::span` except this uses the new `DynamicChannelCount` constant rather than `std::dynamic_extent`.
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