diff --git a/tools/chatgui/src/audiocompressor.cpp b/tools/chatgui/src/audiocompressor.cpp index 5ec0d738..906579f4 100644 --- a/tools/chatgui/src/audiocompressor.cpp +++ b/tools/chatgui/src/audiocompressor.cpp @@ -1,6 +1,6 @@ #include "audiocompressor.h" -#include +#include "../../lib/debug_config.h" #include #include #include @@ -12,10 +12,10 @@ void AudioCompressor::configure(const Config& cfg) { m_lookaheadBlocks = m_cfg.lookaheadMs / m_cfg.blockDurationMs; m_riseFactorPerBlock = powf(m_cfg.riseRatePer500ms, (float)m_cfg.blockDurationMs / 500.0f); m_maxGain = powf(10.0f, m_cfg.maxGainDb / 20.0f); - qDebug("AudioCompressor: config rate=%d ch=%d block=%dms window=%dms+%dms maxGain=%.0fdB riseRate=%.1fx/500ms target=%.0fdBFS", - m_cfg.sampleRate, m_cfg.channels, m_cfg.blockDurationMs, - m_cfg.lookbackMs, m_cfg.lookaheadMs, m_cfg.maxGainDb, - m_cfg.riseRatePer500ms, 20.0f * log10f(m_cfg.targetLevel)); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "config rate=%d ch=%d block=%dms window=%dms+%dms maxGain=%.0fdB riseRate=%.1fx/500ms target=%.0fdBFS", + m_cfg.sampleRate, m_cfg.channels, m_cfg.blockDurationMs, + m_cfg.lookbackMs, m_cfg.lookaheadMs, m_cfg.maxGainDb, + m_cfg.riseRatePer500ms, 20.0f * log10f(m_cfg.targetLevel)); } void AudioCompressor::reset() { @@ -104,8 +104,8 @@ void AudioCompressor::processPendingBlock() { float gainDb = 20.0f * log10f(m_gainSmoothed); float prevDb = 20.0f * log10f(G_prev > 0.0001f ? G_prev : 0.0001f); if (m_dbgCounter % 25 == 0 || fabsf(gainDb - prevDb) > 3.0f) { - qDebug("AudioCompressor: block %zu level=%.4f envelope=%.4f gainRaw=%.1fdB gain=%.1fdB", - idx, m_blockLevels[idx].level, envelope, 20.0f * log10f(G_raw), gainDb); + DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "block %zu level=%.4f envelope=%.4f gainRaw=%.1fdB gain=%.1fdB", + idx, m_blockLevels[idx].level, envelope, 20.0f * log10f(G_raw), gainDb); } m_dbgCounter++; @@ -138,8 +138,8 @@ void AudioCompressor::flush() { } int remain = (int)m_pending.size(); - qDebug("AudioCompressor: flush %d pending blocks (gainSmoothed=%.1fdB)", remain, - 20.0f * log10f(m_gainSmoothed)); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "flush %d pending blocks (gainSmoothed=%.1fdB)", remain, + 20.0f * log10f(m_gainSmoothed)); while (!m_pending.empty()) { processPendingBlock(); diff --git a/tools/chatgui/src/audiorecorder.cpp b/tools/chatgui/src/audiorecorder.cpp index f608abde..d23c2c77 100644 --- a/tools/chatgui/src/audiorecorder.cpp +++ b/tools/chatgui/src/audiorecorder.cpp @@ -3,11 +3,10 @@ #include "miniaudio.h" #include "sound_manager.h" -#include +#include "../../lib/debug_config.h" #include #include #include - static AudioRecorder* g_recorder = nullptr; void audioCaptureCallback(ma_device* pDevice, void* pOutput, const void* pInput, unsigned int frameCount) { @@ -74,7 +73,7 @@ bool AudioRecorder::init() { m_device = new ma_device; std::memset(m_device, 0, sizeof(*m_device)); m_initialized = true; - qDebug("AudioRecorder: initialized (sampleRate=%d, channels=%d)", m_sampleRate, m_channels); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "initialized (sampleRate=%d, channels=%d)", m_sampleRate, m_channels); return true; } @@ -87,12 +86,12 @@ void AudioRecorder::shutdown() { } if (m_device) { delete m_device; m_device = nullptr; } m_initialized = false; - qDebug("AudioRecorder: shutdown"); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "shutdown"); } void AudioRecorder::startRecording() { if (m_recording) return; - if (!m_initialized) { qWarning("AudioRecorder: not initialized"); return; } + if (!m_initialized) { DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "not initialized"); return; } m_pcmBuffer.clear(); m_waveformLevels.clear(); @@ -102,7 +101,7 @@ void AudioRecorder::startRecording() { if (m_compressor) m_compressor->reset(); ma_context* ctx = SoundManager::instance()->context(); - if (!ctx) { qWarning("AudioRecorder: no audio context"); return; } + if (!ctx) { DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "no audio context"); return; } ma_device_config config = ma_device_config_init(ma_device_type_capture); config.capture.format = ma_format_s16; @@ -118,25 +117,25 @@ void AudioRecorder::startRecording() { ma_result r = ma_context_get_devices(ctx, nullptr, nullptr, &pCaptureDevices, &captureCount); if (r == MA_SUCCESS && (ma_uint32)m_captureDeviceIndex < captureCount) { config.capture.pDeviceID = &pCaptureDevices[m_captureDeviceIndex].id; - qDebug("AudioRecorder: using capture device[%d]: %s", m_captureDeviceIndex, - pCaptureDevices[m_captureDeviceIndex].name); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "using capture device[%d]: %s", m_captureDeviceIndex, + pCaptureDevices[m_captureDeviceIndex].name); } } ma_result r = ma_device_init(ctx, &config, m_device); if (r != MA_SUCCESS) { - qWarning("AudioRecorder: device init failed (%d), trying default", r); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "device init failed (%d), trying default", r); config.capture.pDeviceID = nullptr; r = ma_device_init(ctx, &config, m_device); if (r != MA_SUCCESS) { - qWarning("AudioRecorder: default device init also failed (%d)", r); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "default device init also failed (%d)", r); return; } } r = ma_device_start(m_device); if (r != MA_SUCCESS) { - qWarning("AudioRecorder: device start failed (%d)", r); + DEBUG_WARN(DEBUG_CATEGORY_DEBUG, "device start failed (%d)", r); ma_device_uninit(m_device); return; } @@ -144,7 +143,7 @@ void AudioRecorder::startRecording() { m_recording = true; m_deviceStarted = true; m_durationTimer.start(); - qDebug("AudioRecorder: recording started"); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "recording started"); emit recordingStarted(); } @@ -163,8 +162,8 @@ void AudioRecorder::stopRecording() { int duration = m_elapsedMs; size_t bufSize = (m_compressor && m_compressorEnabled) ? m_compressor->outputBuffer().size() : m_pcmBuffer.size(); - qDebug("AudioRecorder: recording stopped, duration=%dms, pcmSamples=%zu, compressor=%d", - duration, bufSize, m_compressorEnabled ? 1 : 0); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "recording stopped, duration=%dms, pcmSamples=%zu, compressor=%d", + duration, bufSize, m_compressorEnabled ? 1 : 0); emit recordingStopped(duration); emit durationChanged(0); } @@ -187,5 +186,5 @@ const std::vector& AudioRecorder::buffer() const { void AudioRecorder::setCompressorEnabled(bool enabled) { m_compressorEnabled = enabled; if (m_compressor) m_compressor->setEnabled(enabled); - qDebug("AudioRecorder: compressor %s", enabled ? "enabled" : "disabled"); + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "compressor %s", enabled ? "enabled" : "disabled"); }