Deluge Firmware 1.3.0
Build date: 2025.09.14
Loading...
Searching...
No Matches
interpolation.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/audio_interpolation.h"
19#include "gui/menu_item/formatted_title.h"
20#include "model/sample/sample_controls.h"
21#include "processing/sound/sound.h"
22#include "utils.h"
23
24namespace deluge::gui::menu_item::sample {
25class Interpolation final : public AudioInterpolation, public FormattedTitle {
26public:
27 Interpolation(l10n::String name, l10n::String title_format_str, uint8_t source_id)
28 : AudioInterpolation(name), FormattedTitle(title_format_str, source_id + 1), source_id_{source_id} {}
29
30 [[nodiscard]] std::string_view getTitle() const override { return FormattedTitle::title(); }
31
32 void readCurrentValue() override {
33 const auto& sampleControls = getCurrentSampleControls(source_id_);
34 setValue(sampleControls.interpolationMode);
35 }
36
37 void writeCurrentValue() override {
38 const auto current_value = getValue<InterpolationMode>();
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 const 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 // Note: we need to apply the same filtering as stated in the isRelevant() function
49 Source* source = &soundDrum->sources[source_id_];
50 source->sampleControls.interpolationMode = current_value;
51 }
52 }
53 }
54 // Or, the normal case of just one sound
55 else {
56 auto& sampleControls = getCurrentSampleControls(source_id_);
57 sampleControls.interpolationMode = current_value;
58 }
59 }
60
61 bool isRelevant(ModControllableAudio* modControllable, int32_t) override {
62 if (getCurrentAudioClip() != nullptr) {
63 return true;
64 }
65 const auto sound = static_cast<Sound*>(modControllable);
66 Source& source = sound->sources[source_id_];
67 return sound->getSynthMode() == ::SynthMode::SUBTRACTIVE
68 && ((source.oscType == OscType::SAMPLE && source.hasAtLeastOneAudioFileLoaded())
69 || source.oscType == OscType::INPUT_L || source.oscType == OscType::INPUT_R
70 || source.oscType == OscType::INPUT_STEREO);
71 }
72
73 void getColumnLabel(StringBuf& label) override {
74 label.append(l10n::get(l10n::String::STRING_FOR_INTERPOLATION_SHORT));
75 }
76
77private:
78 uint8_t source_id_;
79};
80} // namespace deluge::gui::menu_item::sample
Definition drum.h:44
Definition kit.h:34
Definition mod_controllable_audio.h:47
Definition sound_drum.h:28
Definition sound.h:71
Definition source.h:31
Definition d_stringbuf.h:16
Definition audio_interpolation.h:10
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 interpolation.h:30
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition interpolation.h:32
bool isRelevant(ModControllableAudio *modControllable, int32_t) override
Check if this MenuItem should show up in a containing deluge::gui::menu_item::Submenu.
Definition interpolation.h:61