Deluge Firmware 1.3.0
Build date: 2025.07.08
Loading...
Searching...
No Matches
runtime_feature_settings.h
1/*
2 * Copyright © 2015-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
18#pragma once
19
20#include "gui/l10n/strings.h"
21#include "util/container/array/resizeable_array.h"
22#include "util/containers.h"
23#include "util/d_string.h"
24#include <array>
25#include <cstdint>
26#include <string_view>
27#include <vector>
28
29namespace deluge::gui::menu_item::runtime_feature {
30class Setting;
31class Settings;
32class DevSysexSetting;
33
34} // namespace deluge::gui::menu_item::runtime_feature
35
36// State declarations
37enum RuntimeFeatureStateToggle : uint32_t { Off = 0, On = 1 };
38
39// Declare additional enums for specific multi state settings (e.g. like RuntimeFeatureStateTrackLaunchStyle)
40enum RuntimeFeatureStateSyncScalingAction : uint32_t { SyncScaling = 0, Fill = 1 };
41
42enum RuntimeFeatureStateEmulatedDisplay : uint32_t { Hardware = 0, Toggle = 1, OnBoot = 2 };
43
45enum RuntimeFeatureSettingType : uint32_t {
46 DrumRandomizer,
47 Quantize,
48 FineTempoKnob,
49 CatchNotes,
50 DeleteUnusedKitRows,
51 AltGoldenKnobDelayParams,
52 DevSysexAllowed,
53 SyncScalingAction,
54 HighlightIncomingNotes,
55 DisplayNornsLayout,
56 ShiftIsSticky,
57 LightShiftLed,
58 EnableDX7Engine,
59 EmulatedDisplay,
60 EnableKeyboardViewSidebarMenuExit,
61 EnableLaunchEventPlayhead,
62 DisplayChordKeyboard,
63 AlternativePlaybackStartBehaviour,
64 EnableGridViewLoopPads,
65 AlternativeTapTempoBehaviour,
66 HorizontalMenus,
67 TrimFromStartOfAudioClip,
68 MaxElement // Keep as boundary
69};
70
73 std::string_view displayName;
74 uint32_t value; // Value to be defined as typed Enum above
75};
76
79 deluge::l10n::String displayName;
80 std::string_view xmlName;
81 uint32_t value;
82 // Limited to safe memory
83 deluge::vector<RuntimeFeatureSettingOption> options;
84};
85
86class Serializer;
87class Deserializer;
88
90class RuntimeFeatureSettings {
91public:
92 RuntimeFeatureSettings();
93
94 // Traded type safety for option values for code simplicity and size, use enum from above to compare
95 inline uint32_t get(RuntimeFeatureSettingType type) { return settings[type].value; };
96 inline bool isOn(RuntimeFeatureSettingType type) { return get(type) == RuntimeFeatureStateToggle::On; }
97
103 inline void set(RuntimeFeatureSettingType type, uint32_t value) { settings[type].value = value; }
104
105 inline const char* getStartupSong() { return startupSong.get(); }
106 void init();
107 void readSettingsFromFile();
108 void writeSettingsToFile();
109
110protected:
111 std::array<RuntimeFeatureSetting, RuntimeFeatureSettingType::MaxElement> settings = {};
112 String startupSong;
113
114private:
115 ResizeableArray unknownSettings;
116
117public:
118 friend class deluge::gui::menu_item::runtime_feature::Setting;
119 friend class deluge::gui::menu_item::runtime_feature::Settings;
120 friend class deluge::gui::menu_item::runtime_feature::DevSysexSetting;
121};
122
124extern RuntimeFeatureSettings runtimeFeatureSettings;
Definition storage_manager.h:185
Encapsulating class.
Definition runtime_feature_settings.h:90
void set(RuntimeFeatureSettingType type, uint32_t value)
Definition runtime_feature_settings.h:103
Definition storage_manager.h:119
Definition for selectable options.
Definition runtime_feature_settings.h:72
Every setting keeps its metadata and value in here.
Definition runtime_feature_settings.h:78