Deluge Firmware 1.3.0
Build date: 2025.06.05
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 PatchCableResolution,
50 CatchNotes,
51 DeleteUnusedKitRows,
52 AltGoldenKnobDelayParams,
53 DevSysexAllowed,
54 SyncScalingAction,
55 HighlightIncomingNotes,
56 DisplayNornsLayout,
57 ShiftIsSticky,
58 LightShiftLed,
59 EnableDX7Engine,
60 EmulatedDisplay,
61 EnableKeyboardViewSidebarMenuExit,
62 EnableLaunchEventPlayhead,
63 DisplayChordKeyboard,
64 AlternativePlaybackStartBehaviour,
65 EnableGridViewLoopPads,
66 AlternativeTapTempoBehaviour,
67 HorizontalMenus,
68 HorizontalMenusSmallFontForLabels,
69 TrimFromStartOfAudioClip,
70 MaxElement // Keep as boundary
71};
72
75 std::string_view displayName;
76 uint32_t value; // Value to be defined as typed Enum above
77};
78
81 deluge::l10n::String displayName;
82 std::string_view xmlName;
83 uint32_t value;
84 // Limited to safe memory
85 deluge::vector<RuntimeFeatureSettingOption> options;
86};
87
88class Serializer;
89class Deserializer;
90
92class RuntimeFeatureSettings {
93public:
94 RuntimeFeatureSettings();
95
96 // Traded type safety for option values for code simplicity and size, use enum from above to compare
97 inline uint32_t get(RuntimeFeatureSettingType type) { return settings[type].value; };
98 inline bool isOn(RuntimeFeatureSettingType type) { return get(type) == RuntimeFeatureStateToggle::On; }
99
105 inline void set(RuntimeFeatureSettingType type, uint32_t value) { settings[type].value = value; }
106
107 inline const char* getStartupSong() { return startupSong.get(); }
108 void init();
109 void readSettingsFromFile();
110 void writeSettingsToFile();
111
112protected:
113 std::array<RuntimeFeatureSetting, RuntimeFeatureSettingType::MaxElement> settings = {};
114 String startupSong;
115
116private:
117 ResizeableArray unknownSettings;
118
119public:
120 friend class deluge::gui::menu_item::runtime_feature::Setting;
121 friend class deluge::gui::menu_item::runtime_feature::Settings;
122 friend class deluge::gui::menu_item::runtime_feature::DevSysexSetting;
123};
124
126extern RuntimeFeatureSettings runtimeFeatureSettings;
Definition storage_manager.h:185
Encapsulating class.
Definition runtime_feature_settings.h:92
void set(RuntimeFeatureSettingType type, uint32_t value)
Definition runtime_feature_settings.h:105
Definition storage_manager.h:119
Definition for selectable options.
Definition runtime_feature_settings.h:74
Every setting keeps its metadata and value in here.
Definition runtime_feature_settings.h:80