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