Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
WaveformRenderer Class Reference

Classes

struct  PendingLoad
 A Cluster that findPeaksPerCol() enqueued and is waiting on. More...

Public Member Functions

bool renderFullScreen (Sample *sample, uint64_t xScroll, uint64_t xZoom, RGB thisImage[][kDisplayWidth+kSideBarWidth], WaveformRenderData *data, SampleRecorder *recorder=nullptr, std::optional< RGB > rgb=std::nullopt, bool reversed=false, int32_t xEnd=kDisplayWidth)
bool renderAsSingleRow (Sample *sample, int64_t xScroll, uint64_t xZoom, RGB *thisImage, WaveformRenderData *data, SampleRecorder *recorder, RGB rgb, bool reversed, int32_t xStart, int32_t xEnd)
 Renders a Sample's waveform as one row of brightness, as song row view shows it.
void renderOneCol (Sample *sample, int32_t xDisplay, RGB thisImage[][kDisplayWidth+kSideBarWidth], WaveformRenderData *data, bool reversed=false, std::optional< RGB > rgb=std::nullopt)
void renderOneColForCollapseAnimation (int32_t xDisplay, int32_t xDisplayOutput, int32_t maxPeakFromZero, int32_t progress, RGB thisImage[][kDisplayWidth+kSideBarWidth], WaveformRenderData *data, std::optional< RGB > rgb, bool reversed, int32_t valueCentrePoint, int32_t valueSpan)
void renderOneColForCollapseAnimationZoomedOut (int32_t xDisplayWaveformLeftEdge, int32_t xDisplayWaveformRightEdge, int32_t xDisplayOutput, int32_t maxPeakFromZero, int32_t progress, RGB thisImage[][kDisplayWidth+kSideBarWidth], WaveformRenderData *data, std::optional< RGB > rgb, bool reversed, int32_t valueCentrePoint, int32_t valueSpan)
bool findPeaksPerCol (Sample *sample, int64_t xScroll, uint64_t xZoom, WaveformRenderData *data, SampleRecorder *recorder=nullptr, int32_t xStart=0, int32_t xEnd=kDisplayWidth, bool wait_for_card=true)
 Fills in data's per-column min/max peaks for any columns in [xStart, xEnd) not already cached.
void releaseFinishedLoads ()
 Lets go of enqueued Clusters that have finished loading, or that never will because they're unloadable.
void releaseAllLoads ()
 Lets go of every enqueued Cluster and its Sample, loaded or not.

Public Attributes

int8_t collapseAnimationToWhichRow

Private Member Functions

void holdUntilLoaded (Sample *sample, Cluster *cluster)
 Takes over the caller's reason on an enqueued Cluster until it has loaded.
int32_t getColBrightnessForSingleRow (int32_t xDisplay, int32_t maxPeakFromZero, WaveformRenderData *data)
void getColBarPositions (int32_t xDisplay, WaveformRenderData *data, int32_t *min24, int32_t *max24, int32_t valueCentrePoint, int32_t valueSpan)
void drawColBar (int32_t xDisplay, int32_t min24, int32_t max24, RGB thisImage[][kDisplayWidth+kSideBarWidth], int32_t brightness=128, std::optional< RGB > rgb=std::nullopt)
void renderOneColForCollapseAnimationInterpolation (int32_t xDisplayOutput, int32_t min24, int32_t max24, int32_t singleSquareBrightness, int32_t progress, RGB thisImage[][kDisplayWidth+kSideBarWidth], std::optional< RGB > rgb)

Static Private Member Functions

static void release (const PendingLoad &load)
 Removes the reasons load holds. Doesn't remove it from pending_loads_.

Private Attributes

etl::vector< PendingLoad, kMaxPendingLoads > pending_loads_

Static Private Attributes

static constexpr size_t kMaxPendingLoads = 16
 Most Clusters we'll wait on at once.

Member Function Documentation

◆ findPeaksPerCol()

bool WaveformRenderer::findPeaksPerCol ( Sample * sample,
int64_t xScroll,
uint64_t xZoom,
WaveformRenderData * data,
SampleRecorder * recorder = nullptr,
int32_t xStart = 0,
int32_t xEnd = kDisplayWidth,
bool wait_for_card = true )

Fills in data's per-column min/max peaks for any columns in [xStart, xEnd) not already cached.

Cached columns are kept across calls while the waveform length stays the same. A whole-column scroll slides them across, and only the newly exposed columns are worked out. Any other scroll or zoom carries over what it can with remapColumns().

Parameters
sampleThe Sample to read.
xScrollSample position of the left edge of column 0.
xZoomSamples per column.
dataPer-column cache to fill in. Set its xScroll to -1 to force everything to be worked out again.
recorderThe SampleRecorder still writing sample, if any. Its captured length is used.
xStartFirst column to fill in.
xEndColumn after the last one to fill in.
wait_for_cardWhether to read Clusters that aren't in memory from the card now. If false, they're enqueued instead, and their columns left un-investigated or as placeholders. Must be true while recorder is set: the reason held on sample while waiting would break SampleRecorder::abort().
Returns
false if any column couldn't be worked out yet (Cluster enqueued, or couldn't load it), so the caller should try again later.

◆ holdUntilLoaded()

void WaveformRenderer::holdUntilLoaded ( Sample * sample,
Cluster * cluster )
private

Takes over the caller's reason on an enqueued Cluster until it has loaded.

If it's already held, or there's no room, the caller's reason is removed instead, so cluster may no longer exist afterwards.

Parameters
sampleThe Sample cluster belongs to.
clusterAn enqueued, not yet loaded Cluster that the caller holds one reason on.

◆ releaseAllLoads()

void WaveformRenderer::releaseAllLoads ( )

Lets go of every enqueued Cluster and its Sample, loaded or not.

Must be called before deleting Samples without checking their reasons, as AudioFileManager::deleteAnyTempRecordedSamplesFromMemory() does.

◆ releaseFinishedLoads()

void WaveformRenderer::releaseFinishedLoads ( )

Lets go of enqueued Clusters that have finished loading, or that never will because they're unloadable.

Cheap. findPeaksPerCol() calls it, and AudioFileManager::slowRoutine() does too, so Clusters are let go of even once nothing is rendering waveforms.

◆ renderAsSingleRow()

bool WaveformRenderer::renderAsSingleRow ( Sample * sample,
int64_t xScroll,
uint64_t xZoom,
RGB * thisImage,
WaveformRenderData * data,
SampleRecorder * recorder,
RGB rgb,
bool reversed,
int32_t xStart,
int32_t xEnd )

Renders a Sample's waveform as one row of brightness, as song row view shows it.

Doesn't wait on the SD card unless recorder is set: Clusters not in memory are enqueued, and until they've loaded their columns draw the estimate carried over from before the last zoom or scroll, or black if there isn't one. Everything that is available is always drawn.

Returns
false if some columns are still waiting on the card, so the caller should render the row again later.

Member Data Documentation

◆ kMaxPendingLoads

size_t WaveformRenderer::kMaxPendingLoads = 16
staticconstexprprivate

Most Clusters we'll wait on at once.

Keeps a long scroll from flooding the loading queue ahead of playback. Columns that don't fit are retried on a later render.


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