Deluge Firmware 1.3.0
Build date: 2026.10.08
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 [[nodiscard]] bool allowToBeginSessionFromHorizontalMenu() override { return true; }
50
52 uint32_t getParamIndex();
53 PatchSource getPatchSource() override;
54
55 // OLED Only
56 void renderOLED() override;
57 // 7SEG only
58 void appendAdditionalDots(std::vector<uint8_t>& dotPositions) override;
59
60 void unlearnAction() final { MenuItemWithCCLearning::unlearnAction(); }
61 bool allowsLearnMode() final { return MenuItemWithCCLearning::allowsLearnMode(); }
62 void learnKnob(MIDICable* cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) final {
63 MenuItemWithCCLearning::learnKnob(cable, whichKnob, modKnobMode, midiChannel);
64 };
65
66 ModelStackWithAutoParam* getModelStackWithParam(void* memory) override;
67
70
71protected:
72 ModelStackWithAutoParam* getModelStack(void* memory, bool allowCreation = false);
73 void getNotificationValue(StringBuf& valueBuf) override { return valueBuf.appendFloat(getValue() / 100.0f, 2, 2); }
74
75private:
76 bool isInHorizontalMenu() const;
77 void setPatchCablePolarity(Polarity newPolarity);
78 void updatePolarityUI();
79 Polarity polarity_in_the_ui_;
80 // if polarity is set before the patch cable is created then we'll need to update the patch cable when it exists
81 bool patch_cable_exists_ = false;
82};
83
84} // 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:96
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:318
uint32_t getParamIndex()
Definition patch_cable_strength.cpp:296
MenuItem * selectButtonPress() final
Handle a select button press.
Definition patch_cable_strength.cpp:304
void selectEncoderAction(int32_t offset) override
Handle select encoder movement.
Definition patch_cable_strength.cpp:332
modulation::params::Kind getParamKind()
Definition patch_cable_strength.cpp:292
void learnKnob(MIDICable *cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) final
Definition patch_cable_strength.h:62
void getNotificationValue(StringBuf &valueBuf) override
Get the parameter value string to show in the popup.
Definition patch_cable_strength.h:73
void endSession() final
End an editing session with this menu item.
Definition patch_cable_strength.cpp:69
bool allowToBeginSessionFromHorizontalMenu() override
Allow entering menu session by selecting the menu item twice in Horizontal menu.
Definition patch_cable_strength.h:49
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:69
bool allowsLearnMode() final
Used by SoundEditor to determine if the current menu item can accept MIDI learning.
Definition patch_cable_strength.h:61
void readCurrentValue() final
Like readValueAgain, but does not redraw.
Definition patch_cable_strength.cpp:194
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:284
void unlearnAction() final
Unlearn the parameter controlled by this menu.
Definition patch_cable_strength.h:60
void horizontalEncoderAction(int32_t offset) override
Handle horizontal encoder movement.
Definition patch_cable_strength.cpp:350
Kind
Definition param.h:42