lmms
Cross-platform music production software
Loading...
Searching...
No Matches
lmms::SampleThumbnailCache Class Reference

Holds increasingly downsampled versions of an audio waveform for efficient rendering of them. More...

#include <SampleThumbnailCache.h>

Classes

class  Thumbnail
 Encapsulates a fixed-width vector of audio peak min/max values. More...

Public Member Functions

 SampleThumbnailCache ()=default
 Constructs an uninitialized, empty thumbnail cache.
 SampleThumbnailCache (const SampleBuffer &buffer)
 Constructs a cache and populates its multi-resolution levels from a sample buffer.
auto nearestThumbnailForWidth (f_cnt_t width) const -> const Thumbnail &
 Get a thumbnail of the requested width. If no thumbnail of the requested width exists, the nearest larger thumbnail is returned.
auto sampleCount () const -> f_cnt_t

Private Attributes

std::vector< Thumbnail > m_thumbnails
f_cnt_t m_sampleCount

Detailed Description

Holds increasingly downsampled versions of an audio waveform for efficient rendering of them.

Instead of reading a lot of audio samples every time the screen redraws or zooms, this class keeps a list of small, pre-calculated waveforms (known as thumbnails,

See also
Thumbnail) at different zoom levels.

Constructor & Destructor Documentation

◆ SampleThumbnailCache() [1/2]

lmms::SampleThumbnailCache::SampleThumbnailCache ( )
default

Constructs an uninitialized, empty thumbnail cache.

◆ SampleThumbnailCache() [2/2]

lmms::SampleThumbnailCache::SampleThumbnailCache ( const SampleBuffer & buffer)

Constructs a cache and populates its multi-resolution levels from a sample buffer.

Parameters
bufferThe sample buffer to downsample and analyze.

Member Function Documentation

◆ nearestThumbnailForWidth()

auto lmms::SampleThumbnailCache::nearestThumbnailForWidth ( f_cnt_t width) const -> const Thumbnail &

Get a thumbnail of the requested width. If no thumbnail of the requested width exists, the nearest larger thumbnail is returned.

Parameters
widthThe requested thumbnail width.
Precondition
width is in the range [1, N] where N is the number of frames in the original buffer.
Note
This function is not thread safe.

◆ sampleCount()

auto lmms::SampleThumbnailCache::sampleCount ( ) const -> f_cnt_t
inline
Returns
The number of samples in the original audio buffer.

Member Data Documentation

◆ m_sampleCount

f_cnt_t lmms::SampleThumbnailCache::m_sampleCount
private

◆ m_thumbnails

std::vector<Thumbnail> lmms::SampleThumbnailCache::m_thumbnails
private

The documentation for this class was generated from the following files: