Deluge Firmware 1.3.0
Build date: 2026.11.28
Loading...
Searching...
No Matches
waveform_renderer.h
1/*
2 * Copyright © 2018-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include "gui/colour/colour.h"
22#include <cstdint>
23#include <etl/vector.h>
24#include <optional>
25
26class Cluster;
27class Sample;
29class SampleRecorder;
31
33 int32_t pos; // Unscrolled
34 int32_t colOnScreen;
35};
36
37// This class provides low-level rendering functions for the waveform only
38
39class WaveformRenderer {
40public:
41 WaveformRenderer();
42
43 bool renderFullScreen(Sample* sample, uint64_t xScroll, uint64_t xZoom,
44 RGB thisImage[][kDisplayWidth + kSideBarWidth], WaveformRenderData* data,
45 SampleRecorder* recorder = nullptr, std::optional<RGB> rgb = std::nullopt,
46 bool reversed = false, int32_t xEnd = kDisplayWidth);
54 bool renderAsSingleRow(Sample* sample, int64_t xScroll, uint64_t xZoom, RGB* thisImage, WaveformRenderData* data,
55 SampleRecorder* recorder, RGB rgb, bool reversed, int32_t xStart, int32_t xEnd);
56 void renderOneCol(Sample* sample, int32_t xDisplay, RGB thisImage[][kDisplayWidth + kSideBarWidth],
57 WaveformRenderData* data, bool reversed = false, std::optional<RGB> rgb = std::nullopt);
58 void renderOneColForCollapseAnimation(int32_t xDisplay, int32_t xDisplayOutput, int32_t maxPeakFromZero,
59 int32_t progress, RGB thisImage[][kDisplayWidth + kSideBarWidth],
60 WaveformRenderData* data, std::optional<RGB> rgb, bool reversed,
61 int32_t valueCentrePoint, int32_t valueSpan);
62 void renderOneColForCollapseAnimationZoomedOut(int32_t xDisplayWaveformLeftEdge, int32_t xDisplayWaveformRightEdge,
63 int32_t xDisplayOutput, int32_t maxPeakFromZero, int32_t progress,
64 RGB thisImage[][kDisplayWidth + kSideBarWidth],
65 WaveformRenderData* data, std::optional<RGB> rgb, bool reversed,
66 int32_t valueCentrePoint, int32_t valueSpan);
85 bool findPeaksPerCol(Sample* sample, int64_t xScroll, uint64_t xZoom, WaveformRenderData* data,
86 SampleRecorder* recorder = nullptr, int32_t xStart = 0, int32_t xEnd = kDisplayWidth,
87 bool wait_for_card = true);
88
94
99 void releaseAllLoads();
100
101 int8_t collapseAnimationToWhichRow;
102
103private:
112
117 static constexpr size_t kMaxPendingLoads = 16;
118 etl::vector<PendingLoad, kMaxPendingLoads> pending_loads_;
119
127 void holdUntilLoaded(Sample* sample, Cluster* cluster);
128
130 static void release(const PendingLoad& load);
131
132 int32_t getColBrightnessForSingleRow(int32_t xDisplay, int32_t maxPeakFromZero, WaveformRenderData* data);
133 void getColBarPositions(int32_t xDisplay, WaveformRenderData* data, int32_t* min24, int32_t* max24,
134 int32_t valueCentrePoint, int32_t valueSpan);
135 void drawColBar(int32_t xDisplay, int32_t min24, int32_t max24, RGB thisImage[][kDisplayWidth + kSideBarWidth],
136 int32_t brightness = 128, std::optional<RGB> rgb = std::nullopt);
137 void renderOneColForCollapseAnimationInterpolation(int32_t xDisplayOutput, int32_t min24, int32_t max24,
138 int32_t singleSquareBrightness, int32_t progress,
139 RGB thisImage[][kDisplayWidth + kSideBarWidth],
140 std::optional<RGB> rgb);
141};
142
143extern WaveformRenderer waveformRenderer;
Definition cluster.h:34
Definition multisample_range.h:27
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:14
Definition sample_recorder.h:53
Definition sample.h:50
Definition waveform_renderer.h:39
void releaseFinishedLoads()
Lets go of enqueued Clusters that have finished loading, or that never will because they're unloadabl...
Definition waveform_renderer.cpp:657
void releaseAllLoads()
Lets go of every enqueued Cluster and its Sample, loaded or not.
Definition waveform_renderer.cpp:677
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.
Definition waveform_renderer.cpp:276
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.
Definition waveform_renderer.cpp:113
static void release(const PendingLoad &load)
Removes the reasons load holds. Doesn't remove it from pending_loads_.
Definition waveform_renderer.cpp:652
static constexpr size_t kMaxPendingLoads
Most Clusters we'll wait on at once.
Definition waveform_renderer.h:117
void holdUntilLoaded(Sample *sample, Cluster *cluster)
Takes over the caller's reason on an enqueued Cluster until it has loaded.
Definition waveform_renderer.cpp:639
Definition waveform_renderer.h:32
Definition waveform_render_data.h:33
A Cluster that findPeaksPerCol() enqueued and is waiting on.
Definition waveform_renderer.h:108
Sample * sample
The Sample it belongs to.
Definition waveform_renderer.h:110
Cluster * cluster
The enqueued Cluster.
Definition waveform_renderer.h:109