Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
audio_inspector_window.hpp
Go to the documentation of this file.
1#pragma once
2
24
28#include <pulp/audio/buffer.hpp>
32#include <pulp/view/view.hpp>
35
36#include <cstdint>
37#include <functional>
38#include <memory>
39#include <string>
40
41namespace pulp::view {
42
47 public:
49 std::function<std::unique_ptr<WindowHost>(View& root, const WindowOptions& options)>;
50
54 static constexpr CommandID kToggleAudioInspector = 0x504C4149;
55
59 explicit AudioInspectorWindow(WindowManager* mgr = nullptr, WindowHost* parent = nullptr,
60 HostFactory host_factory = {}, std::string app_name = "Pulp");
62
65
72 return probe_;
73 }
74
78 void set_device_stats(const audio::AudioStats& device_stats);
79
85 void poll();
86
87 void show();
88 void hide();
89 void toggle();
90 bool is_visible() const;
91
100
102 const AudioInspectorPanel& panel() const {
103 return *panel_;
104 }
105
108 return mode_;
109 }
110
115
123 return window_host_.get();
124 }
125
126 private:
127 // CommandHandler (private base) — registry dispatch entry points.
128 std::vector<CommandID> commands() const override;
129 bool perform_command(CommandID id) override;
130
131 void build_ui();
132 void load_mode_preference();
133 void save_mode_preference();
134 void apply_mode(AudioInspectorMode mode, bool persist);
135 audio::AudioScopeResult build_scope_result(const audio::AudioProbeSnapshot& snap,
136 audio::Buffer<float>& capture, int frames) const;
137
138 WindowManager* manager_ = nullptr;
139 WindowHost* parent_host_ = nullptr;
140 HostFactory host_factory_;
141 CommandRegistry* registry_ = nullptr;
142 std::string app_name_;
143 std::unique_ptr<state::ApplicationProperties> app_properties_;
144 state::PropertiesFile* preferences_ = nullptr;
146 bool applying_mode_ = false;
147
148 audio::AudioProbe* probe_ = nullptr;
149 audio::AudioStats device_stats_{};
150
151 // Stale detection: the last sequence number we saw advance, and whether a
152 // probe has produced at least one snapshot since it was wired.
153 std::uint64_t last_sequence_ = 0;
154 bool ever_observed_ = false;
155
156 // Copied waveform scratch (non-RT; sized to the panel's display capacity).
157 std::vector<float> waveform_scratch_;
158 audio::Buffer<float> scope_capture_;
159
160 std::unique_ptr<View> root_;
161 AudioInspectorPanel* panel_ = nullptr;
162
163 std::unique_ptr<WindowHost> window_host_;
164 WindowId window_id_ = 0;
165};
166
167} // namespace pulp::view
The content view of the developer Audio Inspector — meters, probe-stage status, a copied fixed-capaci...
Realtime-safe audio output probe.
UI-independent acquisition and measurement helpers for Audio Scope.
Small POD counter struct for release-safe audio observability.
Realtime output-boundary probe.
Definition audio_probe.hpp:53
Owning multi-channel audio buffer with contiguous storage.
Definition buffer.hpp:119
JSON-backed persistent settings file.
Definition properties_file.hpp:16
Audio Inspector content panel.
Definition audio_inspector_panel.hpp:126
const AudioInspectorPanel & panel() const
Panel accessor — for headless state assertions.
Definition audio_inspector_window.hpp:102
WindowHost * window_host() const
The window's own WindowHost, or null until show() has created one (and after a host_factory that retu...
Definition audio_inspector_window.hpp:122
audio::AudioProbe * probe() const
Definition audio_inspector_window.hpp:71
void set_probe(audio::AudioProbe *probe)
Point the window at a probe to observe.
AudioInspectorWindow(const AudioInspectorWindow &)=delete
void poll()
Poll the probe once: read the latest snapshot, detect stale (sequence not advancing),...
void set_device_stats(const audio::AudioStats &device_stats)
Mirror device/backend counters the probe must NOT shadow (xruns, overloads).
std::function< std::unique_ptr< WindowHost >(View &root, const WindowOptions &options)> HostFactory
Definition audio_inspector_window.hpp:48
AudioInspectorMode mode() const
Definition audio_inspector_window.hpp:107
void set_preferences(state::PropertiesFile *preferences)
Optional test/embedding hook.
static constexpr CommandID kToggleAudioInspector
Command id for "Toggle Audio Inspector".
Definition audio_inspector_window.hpp:54
AudioInspectorWindow(WindowManager *mgr=nullptr, WindowHost *parent=nullptr, HostFactory host_factory={}, std::string app_name="Pulp")
AudioInspectorWindow & operator=(const AudioInspectorWindow &)=delete
void set_mode(AudioInspectorMode mode)
void register_command_handler(CommandRegistry &registry)
Register the toggle command (kToggleAudioInspector, default chord Cmd+Shift+A / Ctrl+Shift+A) with a ...
Interface implemented by any object that can perform commands.
Definition command_registry.hpp:137
virtual std::vector< CommandID > commands() const =0
Report which commands this handler can perform.
Central command dispatcher.
Definition command_registry.hpp:207
Definition view.hpp:73
Definition window_host.hpp:113
Definition window_manager.hpp:84
CommandRegistry + CommandHandler + CommandInfo + ShortcutMap — Pulp-native command dispatch and keybo...
Hover-cursor tracking for platform window hosts.
Definition fwd.hpp:27
AudioInspectorMode
Definition audio_inspector_panel.hpp:33
@ kSignal
Definition audio_inspector_panel.hpp:34
uint32_t WindowId
Definition window_manager.hpp:48
uint32_t CommandID
A unique command identifier.
Definition app_framework.hpp:20
Realtime-produced, fixed-capacity, trivially-copyable probe summary.
Definition audio_probe_snapshot.hpp:42
Definition audio_scope.hpp:62
Minimal release-safe audio counter aggregate.
Definition audio_stats.hpp:36
Definition window_host.hpp:29