Class AudioManager#
Defined in File audio_manager.hpp
Inheritance Relationships#
Base Type#
public QObject
Class Documentation#
-
class AudioManager : public QObject
Coordinates all AudioRecorder instances for a recording session.
AudioManager is owned by Application and shared between RecordManager (recording lifecycle) and AudioSettingsW (device enumeration and live level display).
See also
AudioRecorder, MicrophoneParameters
- Per-microphone file naming
Files are written to
<sessionDir>/<basename>_N.wav. When only one microphone is configured the_0suffix is omitted.- RMS metering
Each recorder emits level_rms_changed() approximately 10–20 times per second. Connect to this signal from the main thread to drive a VU meter widget:
connect(audioMgr, &AudioManager::level_rms_changed, vuMeter, [vuMeter](int micIdx, float rms) { if (micIdx == 0) vuMeter->set_value(rms); });
Public Functions
-
explicit AudioManager(QObject *parent = nullptr)
-
~AudioManager() override
-
void start(const QString &sessionDir, const QString &basename, const std::vector<MicrophoneParameters> µphones)
Starts one AudioRecorder per entry in
microphones.Stops any previous monitoring session first. Recorders that fail to start are logged but do not abort the others.
- Parameters:
sessionDir – Absolute path to the session folder.
basename – File basename, e.g.
"audio".microphones – Per-microphone configuration from AppSettings.
-
void start_monitoring(const std::vector<MicrophoneParameters> µphones)
Starts level-metering recorders without writing any files.
Used to drive the live waveform display outside of a recording session. Call start() (the recording version) to replace monitoring with actual recording.
-
void stop_monitoring()
Stops monitoring-only recorders.
-
void stop()
Stops all recording recorders and flushes WAV headers.
-
bool is_recording() const
- Returns:
truewhile at least one recording recorder is active.
-
bool is_monitoring() const
- Returns:
truewhile monitoring-only recorders are running.
-
int recorder_count() const
- Returns:
The number of recorders that were successfully started.
Signals
-
void level_rms_changed(int micIndex, float rms)
Emitted from the main thread (queued from the audio capture thread).
- Parameters:
micIndex – Zero-based index into the active microphone list.
rms – Normalised RMS level in the range [0.0, 1.0].
-
void envelope_changed(int micIndex, float minSample, float maxSample)
Same cadence as level_rms_changed(), for a bipolar waveform display.
- Parameters:
micIndex – Zero-based index into the active microphone list.
minSample – Most negative sample in the buffer, normalised [-1, 0].
maxSample – Most positive sample in the buffer, normalised [0, 1].
-
void raw_pcm_ready(int micIndex, QByteArray pcm16, int sampleRate, int channels)
Forwarded from every active AudioRecorder (both start() and start_monitoring() paths) with the mic index — same treatment as envelope_changed. Emitted regardless of monitor-only vs. real recording (matches VideoManager::frame_preview’s own always-on behavior that feeds PoseWorker) — recording-time gating is done at the consumer (TranscriptWorker::set_paused()), not here.
- Parameters:
micIndex – Zero-based index into the active microphone list.
pcm16 – Interleaved 16-bit PCM, already format-normalized.
sampleRate – Actually-negotiated sample rate (see AudioRecorder::start()).
channels – Actually-negotiated channel count.
-
void recorder_error(int micIndex, QString message)
Emitted when a recorder encounters a device error.
- Parameters:
micIndex – Zero-based index of the failing recorder.
message – Human-readable error string.
Public Static Functions
-
static QList<QAudioDevice> available_inputs()
- Returns:
All available audio input devices on this system.
-
static QAudioDevice default_input()
- Returns:
The system default audio input device.