Deluge Firmware 1.3.0
Build date: 2025.09.14
Loading...
Searching...
No Matches
patch_cable_strength.h
1/*
2 * Copyright © 2014-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#include "decimal.h"
20#include "gui/menu_item/automation/automation.h"
21#include "menu_item_with_cc_learning.h"
22
23#include <gui/ui/sound_editor.h>
24#include <modulation/patch/patch_cable.h>
25class MultiRange;
26
27namespace deluge::gui::menu_item {
28
29class PatchCableStrength : public Decimal, public MenuItemWithCCLearning, public Automation {
30public:
31 using Decimal::Decimal;
32 void beginSession(MenuItem* navigatedBackwardFrom) final;
33 void endSession() final;
34 void readCurrentValue() final;
35 void writeCurrentValue() override;
36 [[nodiscard]] int32_t getMinValue() const final { return kMinMenuPatchCableValue; }
37 [[nodiscard]] int32_t getMaxValue() const final { return kMaxMenuPatchCableValue; }
38 [[nodiscard]] int32_t getNumDecimalPlaces() const final { return 2; }
39 virtual int32_t getDefaultEditPos() { return 2; }
40 MenuPermission checkPermissionToBeginSession(ModControllableAudio* modControllable, int32_t whichThing,
41 MultiRange** currentRange) override;
42 virtual ParamDescriptor getDestinationDescriptor() = 0;
43 virtual PatchSource getS() = 0;
44 uint8_t getIndexOfPatchedParamToBlink() final;
45 MenuItem* selectButtonPress() final;
46 ActionResult buttonAction(hid::Button b, bool on, bool inCardRoutine) override;
47 void selectEncoderAction(int32_t offset) override;
48 void horizontalEncoderAction(int32_t offset) override;
49
51 uint32_t getParamIndex();
52 PatchSource getPatchSource() override;
53
54 // OLED Only
55 void renderOLED() override;
56 // 7SEG only
57 void appendAdditionalDots(std::vector<uint8_t>& dotPositions) override;
58
59 void unlearnAction() final { MenuItemWithCCLearning::unlearnAction(); }
60 bool allowsLearnMode() final { return MenuItemWithCCLearning::allowsLearnMode(); }
61 void learnKnob(MIDICable* cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) final {
62 MenuItemWithCCLearning::learnKnob(cable, whichKnob, modKnobMode, midiChannel);
63 };
64
65 ModelStackWithAutoParam* getModelStackWithParam(void* memory) override;
66
67 void updateAutomationViewParameter() override;
68
71
72protected:
73 ModelStackWithAutoParam* getModelStack(void* memory, bool allowCreation = false);
74 void getNotificationValue(StringBuf& valueBuf) override { return valueBuf.appendFloat(getValue() / 100.0f, 2, 2); }
75
76private:
77 bool isInHorizontalMenu() const;
78 void setPatchCablePolarity(Polarity newPolarity);
79 void updatePolarityUI();
80 Polarity polarityInTheUI_;
81 // if polarity is set before the patch cable is created then we'll need to update the patch cable when it exists
82 bool patchCableExists_ = false;
83};
84
85} // namespace deluge::gui::menu_item
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
Definition mod_controllable_audio.h:47
Definition model_stack.h:269
Definition multi_range.h:23
Definition param_descriptor.h:27
Definition d_stringbuf.h:16
Definition automation.h:29
Definition decimal.h:24
Definition multi_range.h:24
Definition patch_cable_strength.h:29
ActionResult buttonAction(hid::Button b, bool on, bool inCardRoutine) override
Handle an arbitrary button.
Definition patch_cable_strength.cpp:316
uint32_t getParamIndex()
Definition patch_cable_strength.cpp:294
MenuItem * selectButtonPress() final
Handle a select button press.
Definition patch_cable_strength.cpp:302
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition patch_cable_strength.cpp:330
modulation::params::Kind getParamKind()
Definition patch_cable_strength.cpp:290
void learnKnob(MIDICable *cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) final
Definition patch_cable_strength.h:61
void getNotificationValue(StringBuf &valueBuf) override
Get the parameter value string to show in the popup.
Definition patch_cable_strength.h:74
void endSession() final
End an editing session with this menu item.
Definition patch_cable_strength.cpp:69
void renderOLED() override
Root rendering routine for OLED.
Definition patch_cable_strength.cpp:76
uint32_t delayHorizontalScrollUntil
Used when scrolling horizontally to briefly catch on min / max decimal number edit position.
Definition patch_cable_strength.h:70
bool allowsLearnMode() final
Used by SoundEditor to determine if the current menu item can accept MIDI learning.
Definition patch_cable_strength.h:60
void updateAutomationViewParameter() override
Definition patch_cable_strength.cpp:382
void readCurrentValue() final
Like readValueAgain, but does not redraw.
Definition patch_cable_strength.cpp:193
void beginSession(MenuItem *navigatedBackwardFrom) final
Begin an editing session with this menu item.
Definition patch_cable_strength.cpp:45
uint8_t getIndexOfPatchedParamToBlink() final
Definition patch_cable_strength.cpp:282
void unlearnAction() final
Unlearn the parameter controlled by this menu.
Definition patch_cable_strength.h:59
void horizontalEncoderAction(int32_t offset) override
Handle horizontal encoder movement.
Definition patch_cable_strength.cpp:353
Kind
Definition param.h:42