Deluge Firmware 1.3.0
Build date: 2025.04.16
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 TrimFromStartOfAudioClip,
69 MaxElement // Keep as boundary
70};
71
74 std::string_view displayName;
75 uint32_t value; // Value to be defined as typed Enum above
76};
77
80 deluge::l10n::String displayName;
81 std::string_view xmlName;
82 uint32_t value;
83 // Limited to safe memory
84 deluge::vector<RuntimeFeatureSettingOption> options;
85};
86
87class Serializer;
88class Deserializer;
89
91class RuntimeFeatureSettings {
92public:
93 RuntimeFeatureSettings();
94
95 // Traded type safety for option values for code simplicity and size, use enum from above to compare
96 inline uint32_t get(RuntimeFeatureSettingType type) { return settings[type].value; };
97 inline bool isOn(RuntimeFeatureSettingType type) { return get(type) == RuntimeFeatureStateToggle::On; }
98
104 inline void set(RuntimeFeatureSettingType type, uint32_t value) { settings[type].value = value; }
105
106 inline const char* getStartupSong() { return startupSong.get(); }
107 void init();
108 void readSettingsFromFile();
109 void writeSettingsToFile();
110
111protected:
112 std::array<RuntimeFeatureSetting, RuntimeFeatureSettingType::MaxElement> settings = {};
113 String startupSong;
114
115private:
116 ResizeableArray unknownSettings;
117
118public:
119 friend class deluge::gui::menu_item::runtime_feature::Setting;
120 friend class deluge::gui::menu_item::runtime_feature::Settings;
121 friend class deluge::gui::menu_item::runtime_feature::DevSysexSetting;
122};
123
125extern RuntimeFeatureSettings runtimeFeatureSettings;
Definition storage_manager.h:185
Encapsulating class.
Definition runtime_feature_settings.h:91
void set(RuntimeFeatureSettingType type, uint32_t value)
Definition runtime_feature_settings.h:104
Definition storage_manager.h:119
Definition for selectable options.
Definition runtime_feature_settings.h:73
Every setting keeps its metadata and value in here.
Definition runtime_feature_settings.h:79