Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
master_transpose.h
1/*
2 * Copyright (c) 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#pragma once
18#include "gui/menu_item/integer.h"
19#include "gui/menu_item/menu_item_with_cc_learning.h"
20#include "gui/menu_item/patched_param.h"
21#include "gui/ui/sound_editor.h"
22#include "menu_item_with_cc_learning.h"
23#include "model/clip/instrument_clip.h"
24#include "model/instrument/kit.h"
25#include "model/model_stack.h"
26#include "model/song/song.h"
27#include "processing/sound/sound.h"
28#include "processing/sound/sound_drum.h"
29
30namespace deluge::gui::menu_item {
31class MasterTranspose final : public Integer, public PatchedParam {
32public:
33 using Integer::Integer;
34 bool usesAffectEntire() override { return true; }
35 void readCurrentValue() override { this->setValue(soundEditor.currentSound->transpose); }
36 void writeCurrentValue() override {
37
38 int16_t value = this->getValue();
39
40 // If affect-entire button held, do whole kit
41 if (currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR && soundEditor.editingKitRow()) {
42
43 Kit* kit = getCurrentKit();
44
45 for (Drum* thisDrum = kit->firstDrum; thisDrum != nullptr; thisDrum = thisDrum->next) {
46 if (thisDrum->type == DrumType::SOUND) {
47 auto* soundDrum = static_cast<SoundDrum*>(thisDrum);
48
49 soundDrum->transpose = value;
50
51 char modelStackMemoryForSoundDrum[MODEL_STACK_MAX_SIZE];
52 ModelStackWithSoundFlags* modelStackForSoundDrum =
53 getModelStackFromSoundDrum(modelStackMemoryForSoundDrum, soundDrum)->addSoundFlags();
54 soundDrum->recalculateAllVoicePhaseIncrements(modelStackForSoundDrum);
55 }
56 }
57 }
58 // Or, the normal case of just one sound
59 else {
60 soundEditor.currentSound->transpose = value;
61
62 char modelStackMemory[MODEL_STACK_MAX_SIZE];
63 ModelStackWithSoundFlags* modelStack = soundEditor.getCurrentModelStack(modelStackMemory)->addSoundFlags();
64 soundEditor.currentSound->recalculateAllVoicePhaseIncrements(modelStack);
65 }
66 }
67 MenuItem* selectButtonPress() override { return PatchedParam::selectButtonPress(); }
68 uint8_t shouldDrawDotOnName() override { return PatchedParam::shouldDrawDotOnName(); }
69 uint32_t getParamIndex() override { return deluge::modulation::params::LOCAL_PITCH_ADJUST; }
70 uint8_t getP() override { return deluge::modulation::params::LOCAL_PITCH_ADJUST; }
71 uint8_t shouldBlinkPatchingSourceShortcut(PatchSource s, uint8_t* colour) override {
72 return PatchedParam::shouldBlinkPatchingSourceShortcut(s, colour);
73 }
74 MenuItem* patchingSourceShortcutPress(PatchSource s, bool previousPressStillActive = false) override {
75 return PatchedParam::patchingSourceShortcutPress(s, previousPressStillActive);
76 }
77
78 void drawValue() override { display->setTextAsNumber(this->getValue(), shouldDrawDotOnName()); }
79
80 void unlearnAction() override { MenuItemWithCCLearning::unlearnAction(); }
81 bool allowsLearnMode() override { return MenuItemWithCCLearning::allowsLearnMode(); }
82 void learnKnob(MIDICable* cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) override {
83 MenuItemWithCCLearning::learnKnob(cable, whichKnob, modKnobMode, midiChannel);
84 };
85
86 [[nodiscard]] int32_t getMinValue() const override { return -96; }
87 [[nodiscard]] int32_t getMaxValue() const override { return 96; }
88};
89} // namespace deluge::gui::menu_item
Definition drum.h:44
Definition kit.h:34
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
Definition model_stack.h:287
Definition sound_drum.h:28
Definition integer.h:24
Definition master_transpose.h:31
bool allowsLearnMode() override
Used by SoundEditor to determine if the current menu item can accept MIDI learning.
Definition master_transpose.h:81
void learnKnob(MIDICable *cable, int32_t whichKnob, int32_t modKnobMode, int32_t midiChannel) override
Definition master_transpose.h:82
MenuItem * selectButtonPress() override
Handle a select button press.
Definition master_transpose.h:67
uint8_t shouldBlinkPatchingSourceShortcut(PatchSource s, uint8_t *colour) override
Definition master_transpose.h:71
bool usesAffectEntire() override
Claim support for Kit AFFECT_ENTIRE editing.
Definition master_transpose.h:34
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition master_transpose.h:35
MenuItem * patchingSourceShortcutPress(PatchSource s, bool previousPressStillActive=false) override
Action to take when a source shortcut is pressed.
Definition master_transpose.h:74
uint32_t getParamIndex() override
Definition master_transpose.h:69
void unlearnAction() override
Unlearn the parameter controlled by this menu.
Definition master_transpose.h:80
uint8_t shouldDrawDotOnName() override
Get the "draw dot state".
Definition master_transpose.h:68