Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
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/formatted_title.h"
19#include "gui/menu_item/source/transpose.h"
20#include "model/instrument/kit.h"
21#include "model/model_stack.h"
22#include "model/song/song.h"
23#include "processing/sound/sound.h"
24#include "processing/sound/sound_drum.h"
25
26namespace deluge::gui::menu_item::modulator {
27
28class Transpose final : public source::Transpose, public FormattedTitle {
29public:
30 Transpose(l10n::String name, l10n::String title_format_str, int32_t newP)
31 : source::Transpose(name, newP), FormattedTitle(title_format_str) {}
32
33 [[nodiscard]] std::string_view getTitle() const override { return FormattedTitle::title(); }
34
35 void readCurrentValue() override {
36 this->setValue(computeCurrentValueForTranspose(
37 soundEditor.currentSound->modulatorTranspose[soundEditor.currentSourceIndex],
38 soundEditor.currentSound->modulatorCents[soundEditor.currentSourceIndex]));
39 }
40
41 bool usesAffectEntire() override { return true; }
42 void writeCurrentValue() override {
43 int32_t transpose, cents;
44 computeFinalValuesForTranspose(this->getValue(), &transpose, &cents);
45
46 // If affect-entire button held, do whole kit
47 if (currentUIMode == UI_MODE_HOLDING_AFFECT_ENTIRE_IN_SOUND_EDITOR && soundEditor.editingKitRow()) {
48
49 Kit* kit = getCurrentKit();
50
51 for (Drum* thisDrum = kit->firstDrum; thisDrum != nullptr; thisDrum = thisDrum->next) {
52 if (thisDrum->type == DrumType::SOUND) {
53 auto* soundDrum = static_cast<SoundDrum*>(thisDrum);
54
55 // Note: we need to apply the same filtering as stated in the isRelevant() function
56 if (soundDrum->getSynthMode() == SynthMode::FM) {
57 char modelStackMemoryForSoundDrum[MODEL_STACK_MAX_SIZE];
58 ModelStackWithSoundFlags* modelStackForSoundDrum =
59 getModelStackFromSoundDrum(modelStackMemoryForSoundDrum, soundDrum)->addSoundFlags();
60
61 soundDrum->setModulatorTranspose(soundEditor.currentSourceIndex, transpose,
62 modelStackForSoundDrum);
63 soundDrum->setModulatorCents(soundEditor.currentSourceIndex, cents, modelStackForSoundDrum);
64 }
65 }
66 }
67 }
68 // Or, the normal case of just one sound
69 else {
70 char modelStackMemory[MODEL_STACK_MAX_SIZE];
71 ModelStackWithSoundFlags* modelStack = soundEditor.getCurrentModelStack(modelStackMemory)->addSoundFlags();
72
73 soundEditor.currentSound->setModulatorTranspose(soundEditor.currentSourceIndex, transpose, modelStack);
74 soundEditor.currentSound->setModulatorCents(soundEditor.currentSourceIndex, cents, modelStack);
75 }
76 }
77
78 bool isRelevant(ModControllableAudio* modControllable, int32_t whichThing) override {
79 Sound* sound = static_cast<Sound*>(modControllable);
80 return (sound->getSynthMode() == SynthMode::FM);
81 }
82};
83
84} // namespace deluge::gui::menu_item::modulator
Definition drum.h:44
Definition kit.h:34
Definition mod_controllable_audio.h:47
Definition model_stack.h:287
Definition sound_drum.h:28
Definition sound.h:71
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition transpose.h:35
bool isRelevant(ModControllableAudio *modControllable, int32_t whichThing) override
Check if this MenuItem should show up in a containing deluge::gui::menu_item::Submenu.
Definition transpose.h:78
bool usesAffectEntire() override
Claim support for Kit AFFECT_ENTIRE editing.
Definition transpose.h:41
std::string_view getTitle() const override
Get the title to be used when rendering on OLED, both as a deluge::gui::menu_item::Submenu and when d...
Definition transpose.h:33