Line data Source code
1 : #pragma once
2 :
3 : #include "audio/engine/audio_engine.h"
4 : #include "audio/effects/tuner.h"
5 : #include "gui/ui_component.h"
6 : #include <functional>
7 : #include <memory>
8 :
9 : namespace Amplitron {
10 :
11 14 : struct TunerProps {
12 14 : bool has_signal = false;
13 14 : int note_idx = -1;
14 14 : int octave = 4;
15 14 : float cents = 0.0f;
16 14 : float freq = 0.0f;
17 14 : bool mute_on = false;
18 14 : float a4_ref = 440.0f;
19 :
20 : std::function<void(bool)> on_mute_changed; // arg: new mute state
21 : std::function<void(float)> on_a4_ref_changed;
22 :
23 : // Needed to get note name string
24 : std::function<const char*(int)> note_name_fn;
25 : };
26 :
27 : /**
28 : * @brief Reactive chromatic tuner modal component.
29 : *
30 : * Receives tuner signal data through TunerProps.
31 : * Callbacks handle mute toggle and A4 reference changes.
32 : */
33 9 : class GuiTuner : public UIComponent<TunerProps> {
34 : public:
35 45 : GuiTuner() = default;
36 :
37 : /**
38 : * @brief Render the tuner modal.
39 : * Uses the internal show_ flag — call render(show) for external visibility control.
40 : */
41 0 : void render() override { render(show_); }
42 :
43 : /** @brief Render with an external show flag (GuiManager holds authoritative state). */
44 : void render(bool& show);
45 :
46 : private:
47 9 : bool show_ = true;
48 : };
49 :
50 : } // namespace Amplitron
|