Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
sample_marker_editor.h
1/*
2 * Copyright © 2019-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/ui/ui.h"
22#include "hid/button.h"
23#include <cstdint>
24
25class Sample;
27struct MarkerColumn;
28
29// This is just for when we're editing a Sample's loop points etc. It mostly makes use of WaveformBasicNavigator,
30// which itself makes use of WaveformRenderer. However, I've implemented this without any class inheritance
31
32class SampleMarkerEditor final : public UI {
33public:
34 SampleMarkerEditor() = default;
35
36 bool opened() override;
37 bool getGreyoutColsAndRows(uint32_t* cols, uint32_t* rows) override;
38 void selectEncoderAction(int8_t offset) override;
39 ActionResult padAction(int32_t x, int32_t y, int32_t velocity) override;
40 ActionResult buttonAction(deluge::hid::Button b, bool on, bool inCardRoutine) override;
41 ActionResult verticalEncoderAction(int32_t offset, bool inCardRoutine) override;
42 ActionResult horizontalEncoderAction(int32_t offset) override;
43 void graphicsRoutine() override;
44 ActionResult timerCallback() override;
45 bool renderMainPads(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth] = nullptr,
46 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth] = nullptr,
47 bool drawUndefinedArea = true) override;
48 bool renderSidebar(uint32_t whichRows, RGB image[][kDisplayWidth + kSideBarWidth] = nullptr,
49 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth] = nullptr) override;
50
51 // OLED
52 void renderOLED(deluge::hid::display::oled_canvas::Canvas& canvas) override;
53
54 // 7SEG
55 void displayText();
56
58 void loopUnlock();
60 void loopLock();
61
62 MarkerType markerType;
63
64 int8_t blinkPhase;
65
66 int8_t pressX;
67 int8_t pressY;
68
69 // ui
70 UIType getUIType() override { return UIType::SAMPLE_MARKER_EDITOR; }
71 bool exitUI() override;
72
73private:
74 static constexpr int32_t kInvalidColumn = -2147483648;
75 void writeValue(uint32_t value, MarkerType markerTypeNow = MarkerType::NOT_AVAILABLE);
76
77 int32_t getStartColOnScreen(int32_t unscrolledPos);
78 int32_t getEndColOnScreen(int32_t unscrolledPos);
79 int32_t getStartPosFromCol(int32_t col);
80 int32_t getEndPosFromCol(int32_t col);
81 void getColsOnScreen(MarkerColumn* cols);
82 void recordScrollAndZoom();
83 bool shouldAllowExtraScrollRight();
90 void renderColumn(int32_t xDisplay, RGB image[kDisplayHeight][kDisplayWidth + kSideBarWidth],
91 MarkerColumn cols[kNumMarkerTypes], int32_t supressMask);
93 void renderMarkerInCol(int32_t xDisplay, RGB thisImage[kDisplayHeight][kDisplayWidth + kSideBarWidth],
94 MarkerType type, int32_t yStart, int32_t yEnd, bool dimmly);
95
97 [[nodiscard]] MarkerType reverseRemap(MarkerType type) const;
98};
99
100extern SampleMarkerEditor sampleMarkerEditor;
Definition multisample_range.h:27
This class represents the colour format most used by the Deluge globally.
Definition rgb.h:14
Definition sample_marker_editor.h:32
void renderMarkerInCol(int32_t xDisplay, RGB thisImage[kDisplayHeight][kDisplayWidth+kSideBarWidth], MarkerType type, int32_t yStart, int32_t yEnd, bool dimmly)
Draw a single marker.
Definition sample_marker_editor.cpp:1071
MarkerType reverseRemap(MarkerType type) const
Swap a marker to its inverse, if the sample is currently reversed.
Definition sample_marker_editor.cpp:82
void loopLock()
Lock the loop so the start and end are always the same number of samples apart.
Definition sample_marker_editor.cpp:1244
void renderColumn(int32_t xDisplay, RGB image[kDisplayHeight][kDisplayWidth+kSideBarWidth], MarkerColumn cols[kNumMarkerTypes], int32_t supressMask)
Definition sample_marker_editor.cpp:1283
bool exitUI() override
returns whether a UI exited
Definition sample_marker_editor.cpp:692
void loopUnlock()
Unlock the loop, allowing the ends to be moved independently.
Definition sample_marker_editor.cpp:1238
Definition sample.h:50
Definition waveform_renderer.h:30