Deluge Firmware 1.3.0
Build date: 2026.10.08
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/transpose.h"
20#include "gui/ui/sound_editor.h"
21#include "model/clip/instrument_clip.h"
22#include "model/instrument/kit.h"
23#include "model/model_stack.h"
24#include "model/song/song.h"
25#include "processing/sound/sound.h"
26#include "processing/sound/sound_drum.h"
27
28namespace deluge::gui::menu_item {
29class MasterTranspose final : public Transpose {
30public:
31 MasterTranspose(l10n::String name, l10n::String title)
32 : Transpose(name, title, deluge::modulation::params::LOCAL_PITCH_ADJUST) {}
33
34 bool usesAffectEntire() override { return true; }
35 void readCurrentValue() override {
36 this->setValue(
37 computeCurrentValueForTranspose(soundEditor.currentSound->transpose, soundEditor.currentSound->cents));
38 }
39 void writeCurrentValue() override {
40
41 int32_t transpose, cents;
42 computeFinalValuesForTranspose(this->getValue(), &transpose, &cents);
43
44 // If affect-entire button held, do whole kit
45 if (currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR && soundEditor.editingKitRow()) {
46
47 Kit* kit = getCurrentKit();
48
49 for (Drum* thisDrum = kit->firstDrum; thisDrum != nullptr; thisDrum = thisDrum->next) {
50 if (thisDrum->type == DrumType::SOUND) {
51 auto* soundDrum = static_cast<SoundDrum*>(thisDrum);
52
53 soundDrum->transpose = transpose;
54 soundDrum->set_cents(cents);
55
56 char modelStackMemoryForSoundDrum[MODEL_STACK_MAX_SIZE];
57 ModelStackWithSoundFlags* modelStackForSoundDrum =
58 getModelStackFromSoundDrum(modelStackMemoryForSoundDrum, soundDrum)->addSoundFlags();
59 soundDrum->recalculateAllVoicePhaseIncrements(modelStackForSoundDrum);
60 }
61 }
62 }
63 // Or, the normal case of just one sound
64 else {
65 soundEditor.currentSound->transpose = transpose;
66 soundEditor.currentSound->set_cents(cents);
67
68 char modelStackMemory[MODEL_STACK_MAX_SIZE];
69 ModelStackWithSoundFlags* modelStack = soundEditor.getCurrentModelStack(modelStackMemory)->addSoundFlags();
70 soundEditor.currentSound->recalculateAllVoicePhaseIncrements(modelStack);
71 }
72 }
73 void getColumnLabel(StringBuf& label) override {
74 return label.append(l10n::get(l10n::String::STRING_FOR_TRANSPOSE));
75 }
76};
77} // namespace deluge::gui::menu_item
Definition drum.h:44
Definition kit.h:34
deluge::l10n::String title
Can get overridden by getTitle(). Actual max num chars for OLED display is 14.
Definition menu_item.h:222
const deluge::l10n::String name
Default name for use on OLED for deluge::gui::menu_item::Submenu s.
Definition menu_item.h:253
Definition model_stack.h:287
Definition sound_drum.h:28
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