fix: immediate compressor apply + dead code removal + qDebug→DEBUG_* conversion
This commit is contained in:
1 parent
5ec1cb78be
commit
d5b97ff104
6 files changed
+33
-14
No files matched your search
@@ -100,7 +100,6 @@ void AudioCompressor::processPendingBlock() {
|
||||
|
||||
m_gainSmoothed = std::min(m_gainSmoothed, m_maxGain);
|
||||
|
||||
static int dbgCounter = 0;
|
||||
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) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "audiorecorder.h"
|
||||
#include "audiocompressor.h"
|
||||
#include "voicemessageencoder.h"
|
||||
#include "../../lib/debug_config.h"
|
||||
#include "../db/db_manager.h"
|
||||
#include "../transport/gui_bridge.h"
|
||||
#include "../../lib/mem.h"
|
||||
@@ -17,8 +18,8 @@ extern "C" {
|
||||
#include <QDebug>
|
||||
#include <cmath>
|
||||
|
||||
AudioDeviceSettingsPage::AudioDeviceSettingsPage(DbManager* db, QWidget* parent)
|
||||
: QWidget(parent), m_db(db)
|
||||
AudioDeviceSettingsPage::AudioDeviceSettingsPage(DbManager* db, AudioRecorder* recorder, QWidget* parent)
|
||||
: QWidget(parent), m_db(db), m_recorder(recorder)
|
||||
{
|
||||
auto* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 12, 0, 0);
|
||||
@@ -232,9 +233,24 @@ void AudioDeviceSettingsPage::applyAndSave() {
|
||||
m_savedCompressorLookaheadMs = compLookahead;
|
||||
m_savedCompressorRiseRateTenths = compRiseRateTenths;
|
||||
m_savedCompressorTargetLevelDb = compTargetLevel;
|
||||
qDebug("AudioDeviceSettings: saved output=%d input=%d codec=%d compressor=%d gain=%ddB lookback=%d lookahead=%d rise=%.1fx target=%ddB",
|
||||
outIdx, inIdx, codecPreset, compEnabled, compMaxGain, compLookback, compLookahead,
|
||||
(float)compRiseRateTenths / 10.0f, compTargetLevel);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "saved output=%d input=%d codec=%d compressor=%d gain=%ddB lookback=%d lookahead=%d rise=%.1fx target=%ddB",
|
||||
outIdx, inIdx, codecPreset, compEnabled, compMaxGain, compLookback, compLookahead,
|
||||
(float)compRiseRateTenths / 10.0f, compTargetLevel);
|
||||
|
||||
if (m_recorder) {
|
||||
m_recorder->setCompressorEnabled(compEnabled != 0);
|
||||
if (m_recorder->compressor() && compEnabled) {
|
||||
AudioCompressor::Config compCfg;
|
||||
compCfg.sampleRate = 48000;
|
||||
compCfg.channels = 1;
|
||||
compCfg.maxGainDb = (float)compMaxGain;
|
||||
compCfg.lookbackMs = compLookback;
|
||||
compCfg.lookaheadMs = compLookahead;
|
||||
compCfg.riseRatePer500ms = (float)compRiseRateTenths / 10.0f;
|
||||
compCfg.targetLevel = powf(10.0f, (float)compTargetLevel / 20.0f);
|
||||
m_recorder->compressor()->configure(compCfg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioDeviceSettingsPage::onTestMicToggled() {
|
||||
|
||||
@@ -14,7 +14,7 @@ class AudioCompressor;
|
||||
class AudioDeviceSettingsPage : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AudioDeviceSettingsPage(DbManager* db, QWidget* parent = nullptr);
|
||||
explicit AudioDeviceSettingsPage(DbManager* db, AudioRecorder* recorder, QWidget* parent = nullptr);
|
||||
~AudioDeviceSettingsPage() override;
|
||||
void loadFromDb();
|
||||
void applyAndSave();
|
||||
@@ -30,6 +30,7 @@ private:
|
||||
void updateCompressorLabels();
|
||||
|
||||
DbManager* m_db;
|
||||
AudioRecorder* m_recorder = nullptr;
|
||||
AudioRecorder* m_testRecorder = nullptr;
|
||||
QComboBox* m_outputCombo;
|
||||
QComboBox* m_inputCombo;
|
||||
|
||||
@@ -222,9 +222,9 @@ void MainWindow::setupSoundFromConfig() {
|
||||
m_recorder->compressor()->configure(compCfg);
|
||||
}
|
||||
}
|
||||
qDebug("MainWindow: AudioRecorder initialized (captureDevice=%d, opusPreset=%d, compressor=%d)",
|
||||
m_recorder->captureDeviceIndex(), VoiceEncoder::preset(),
|
||||
m_recorder->isCompressorEnabled() ? 1 : 0);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "AudioRecorder initialized (captureDevice=%d, opusPreset=%d, compressor=%d)",
|
||||
m_recorder->captureDeviceIndex(), VoiceEncoder::preset(),
|
||||
m_recorder->isCompressorEnabled() ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ void MainWindow::showJoinDialog() {
|
||||
}
|
||||
|
||||
void MainWindow::showSettings() {
|
||||
SettingsDialog dlg(m_cfgPath, m_db, m_node, this);
|
||||
SettingsDialog dlg(m_cfgPath, m_db, m_node, m_recorder, this);
|
||||
dlg.exec();
|
||||
reloadChannels();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ extern "C" {
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
SettingsDialog::SettingsDialog(const QString& configPath, DbManager* db, UtunNode* node, QWidget* parent)
|
||||
SettingsDialog::SettingsDialog(const QString& configPath, DbManager* db, UtunNode* node,
|
||||
AudioRecorder* recorder, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, m_configPath(configPath)
|
||||
{
|
||||
@@ -102,7 +103,7 @@ SettingsDialog::SettingsDialog(const QString& configPath, DbManager* db, UtunNod
|
||||
m_soundPage = new SoundSettingsPage(db, m_pages);
|
||||
m_pages->addWidget(m_soundPage);
|
||||
|
||||
m_audioDevicePage = new AudioDeviceSettingsPage(db, m_pages);
|
||||
m_audioDevicePage = new AudioDeviceSettingsPage(db, recorder, m_pages);
|
||||
m_pages->addWidget(m_audioDevicePage);
|
||||
rightLayout->addWidget(m_pages, 1);
|
||||
|
||||
|
||||
@@ -17,11 +17,13 @@ class SoundSettingsPage;
|
||||
class AudioDeviceSettingsPage;
|
||||
class DbManager;
|
||||
class UtunNode;
|
||||
class AudioRecorder;
|
||||
|
||||
class SettingsDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SettingsDialog(const QString& configPath, DbManager* db, UtunNode* node, QWidget* parent = nullptr);
|
||||
explicit SettingsDialog(const QString& configPath, DbManager* db, UtunNode* node,
|
||||
AudioRecorder* recorder, QWidget* parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void onCategoryChanged(int row);
|
||||
|
||||
Reference in new issue
Block a user