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