Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
pulse_width.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 "definitions_cxx.hpp"
19#include "gui/menu_item/formatted_title.h"
20#include "gui/menu_item/source/patched_param.h"
21#include "modulation/params/param_set.h"
22#include "processing/sound/sound.h"
23
24namespace deluge::gui::menu_item::osc {
25class PulseWidth final : public menu_item::source::PatchedParam, public FormattedTitle {
26public:
27 PulseWidth(l10n::String name, l10n::String title_format_str, int32_t newP)
28 : source::PatchedParam(name, newP), FormattedTitle(title_format_str) {}
29
30 [[nodiscard]] std::string_view getTitle() const override { return FormattedTitle::title(); }
31
32 int32_t getFinalValue() override { return computeFinalValueForHalfPrecisionMenuItem(this->getValue()); }
33
34 void readCurrentValue() override {
35 this->setValue(computeCurrentValueForHalfPrecisionMenuItem(
36 soundEditor.currentParamManager->getPatchedParamSet()->getValue(getP())));
37 }
38
39 bool isRelevant(ModControllableAudio* modControllable, int32_t whichThing) override {
40 Sound* sound = static_cast<Sound*>(modControllable);
41 if (sound->getSynthMode() == SynthMode::FM) {
42 return false;
43 }
44 OscType oscType = sound->sources[whichThing].oscType;
45 return (oscType != OscType::SAMPLE && oscType != OscType::INPUT_L && oscType != OscType::INPUT_R
46 && oscType != OscType::INPUT_STEREO);
47 }
48};
49
50} // namespace deluge::gui::menu_item::osc
Definition mod_controllable_audio.h:47
Definition sound.h:71
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition pulse_width.h:34
bool isRelevant(ModControllableAudio *modControllable, int32_t whichThing) override
Check if this MenuItem should show up in a containing deluge::gui::menu_item::Submenu.
Definition pulse_width.h:39
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 pulse_width.h:30