Line data Source code
1 : #pragma once
2 :
3 : #include "audio/engine/audio_engine.h"
4 : #include "gui/ui_component.h"
5 : #include <functional>
6 : #include <string>
7 : #include <vector>
8 :
9 : namespace Amplitron {
10 :
11 0 : struct AudioDeviceEntry {
12 : int index = -1;
13 : std::string name;
14 : bool is_usb = false;
15 : };
16 :
17 20 : struct SettingsProps {
18 : // Routing
19 : std::string input_device_name;
20 : std::string output_device_name;
21 : std::string device_error;
22 :
23 : // Latency
24 10 : int buffer_size = 128;
25 10 : int sample_rate = 44100;
26 10 : int suggested_buf = 128;
27 10 : float latency_ms = 0.0f;
28 10 : float cpu_load = 0.0f;
29 10 : bool auto_buf = false;
30 :
31 : // Devices
32 : std::vector<AudioDeviceEntry> input_devices;
33 : std::vector<AudioDeviceEntry> output_devices;
34 10 : int current_input = -1;
35 10 : int current_output = -1;
36 :
37 : #ifdef AMPLITRON_ANDROID_OBOE
38 : const char* oboe_mode_label = "";
39 : #endif
40 :
41 : std::function<void(int)> on_buffer_size_changed;
42 : std::function<void(int)> on_sample_rate_changed;
43 : std::function<void(bool)> on_auto_buf_changed;
44 : std::function<void()> on_clear_error;
45 : std::function<void(int)> on_input_device_changed;
46 : std::function<void(int)> on_output_device_changed;
47 : };
48 :
49 : /**
50 : * @brief Reactive Audio Settings modal component.
51 : */
52 7 : class GuiSettings : public UIComponent<SettingsProps> {
53 : public:
54 35 : GuiSettings() = default;
55 :
56 : /** @brief Render the settings window using internal show_ flag. */
57 0 : void render() override { render(show_); }
58 :
59 : /** @brief Render with an external show flag (GuiManager is authoritative). */
60 : void render(bool& show);
61 :
62 : private:
63 7 : bool show_ = true;
64 : };
65 :
66 : } // namespace Amplitron
|