Skip to content

Commit

Permalink
rx_agc: New rx_agc implementation
Browse files Browse the repository at this point in the history
New stereo rx_agc
Move rx_agc to the output of demodulator
Remove audio_gain# blocks
Make audio gain slider contorl rx_agc manual gain
Move common code from nbrx/wfmrx to receiver_base
Move all agc processing into block class rx_agc_2f
Eliminate CAgc class
Remove CurrentGainDb and move processing to get_current_gain
Rename SetParameters to set_parameters
Remove ProcessData and move all processing to work
Fix tag propagation setting sample delay
Workaroung GNU Radio < 3.8 tag propagation bug
Manually calculate new tag offsets
Small cleanup
Fix initialization
Set default current gain to 1 (0 dB)
rx_agc: improve compatibility with older GNU Radio versions
rx_agc: Restore manual gain correctly
Set audio mute by disconnecting audio_snk
rx_agc: initialize all class members
And add more debug
disable agc debug prints
rx_agc: switch to using history
Prefill magnitude buffer on buffer size change in running state
Prefill magnitude buffer on enabled state change in running state
And gain up/down keyboard shortcuts
  • Loading branch information
vladisslav2011 committed Jul 28, 2023
1 parent 4ce4670 commit efa4766
Show file tree
Hide file tree
Showing 23 changed files with 1,081 additions and 1,104 deletions.
54 changes: 39 additions & 15 deletions src/applications/gqrx/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,17 @@ MainWindow::MainWindow(const QString& cfgfile, bool edit_conf, QWidget *parent)
connect(uiDockRxOpt, SIGNAL(amSyncDcrToggled(bool)), this, SLOT(setAmSyncDcr(bool)));
connect(uiDockRxOpt, SIGNAL(amSyncPllBwSelected(float)), this, SLOT(setAmSyncPllBw(float)));
connect(uiDockRxOpt, SIGNAL(agcToggled(bool)), this, SLOT(setAgcOn(bool)));
connect(uiDockRxOpt, SIGNAL(agcHangToggled(bool)), this, SLOT(setAgcHang(bool)));
connect(uiDockRxOpt, SIGNAL(agcThresholdChanged(int)), this, SLOT(setAgcThreshold(int)));
connect(uiDockRxOpt, SIGNAL(agcSlopeChanged(int)), this, SLOT(setAgcSlope(int)));
connect(uiDockRxOpt, SIGNAL(agcGainChanged(int)), this, SLOT(setAgcGain(int)));
connect(uiDockRxOpt, SIGNAL(agcTargetLevelChanged(int)), this, SLOT(setAgcTargetLevel(int)));
connect(uiDockRxOpt, SIGNAL(agcMaxGainChanged(int)), this, SLOT(setAgcMaxGain(int)));
connect(uiDockRxOpt, SIGNAL(agcAttackChanged(int)), this, SLOT(setAgcAttack(int)));
connect(uiDockRxOpt, SIGNAL(agcDecayChanged(int)), this, SLOT(setAgcDecay(int)));
connect(uiDockRxOpt, SIGNAL(agcHangChanged(int)), this, SLOT(setAgcHang(int)));
connect(uiDockRxOpt, SIGNAL(noiseBlankerChanged(int,bool,float)), this, SLOT(setNoiseBlanker(int,bool,float)));
connect(uiDockRxOpt, SIGNAL(sqlLevelChanged(double)), this, SLOT(setSqlLevel(double)));
connect(uiDockRxOpt, SIGNAL(sqlAutoClicked()), this, SLOT(setSqlLevelAuto()));
connect(uiDockAudio, SIGNAL(audioGainChanged(float)), this, SLOT(setAudioGain(float)));
connect(uiDockAudio, SIGNAL(audioGainChanged(float)), remote, SLOT(setAudioGain(float)));
connect(uiDockAudio, SIGNAL(audioMuteChanged(bool)), this, SLOT(setAudioMute(bool)));
connect(uiDockAudio, SIGNAL(audioStreamingStarted(QString,int,bool)), this, SLOT(startAudioStream(QString,int,bool)));
connect(uiDockAudio, SIGNAL(audioStreamingStopped()), this, SLOT(stopAudioStreaming()));
connect(uiDockAudio, SIGNAL(audioRecStarted(QString)), this, SLOT(startAudioRec(QString)));
Expand Down Expand Up @@ -330,7 +331,7 @@ MainWindow::MainWindow(const QString& cfgfile, bool edit_conf, QWidget *parent)
connect(remote, SIGNAL(newMode(int)), uiDockRxOpt, SLOT(setCurrentDemod(int)));
connect(remote, SIGNAL(newSquelchLevel(double)), this, SLOT(setSqlLevel(double)));
connect(remote, SIGNAL(newSquelchLevel(double)), uiDockRxOpt, SLOT(setSquelchLevel(double)));
connect(remote, SIGNAL(newAudioGain(float)), uiDockAudio, SLOT(setAudioGainDb(float)));
connect(remote, SIGNAL(newAudioGain(float)), this, SLOT(setAudioGain(float)));
connect(uiDockRxOpt, SIGNAL(sqlLevelChanged(double)), remote, SLOT(setSquelchLevel(double)));
connect(remote, SIGNAL(startAudioRecorderEvent()), uiDockAudio, SLOT(startAudioRecorder()));
connect(remote, SIGNAL(stopAudioRecorderEvent()), uiDockAudio, SLOT(stopAudioRecorder()));
Expand Down Expand Up @@ -1290,6 +1291,15 @@ void MainWindow::selectDemod(int mode_idx)
rx->set_cw_offset(cwofs);
rx->set_sql_level(uiDockRxOpt->currentSquelchLevel());

//Call wrapper to update enable/disabled state
setAgcOn(uiDockRxOpt->getAgcOn());
rx->set_agc_target_level(uiDockRxOpt->getAgcTargetLevel());
rx->set_agc_manual_gain(uiDockAudio->audioGain() / 10.0);
rx->set_agc_max_gain(uiDockRxOpt->getAgcMaxGain());
rx->set_agc_attack(uiDockRxOpt->getAgcAttack());
rx->set_agc_decay(uiDockRxOpt->getAgcDecay());
rx->set_agc_hang(uiDockRxOpt->getAgcHang());

remote->setMode(mode_idx);
remote->setPassband(flo, fhi);

Expand Down Expand Up @@ -1366,37 +1376,47 @@ void MainWindow::setAmSyncPllBw(float pll_bw)
*/
void MainWindow::setAudioGain(float value)
{
rx->set_af_gain(value);
rx->set_agc_manual_gain(value);
}

/**
* @brief Audio mute changed.
* @param mute New state.
*/
void MainWindow::setAudioMute(bool mute)
{
rx->set_mute(mute);
}

/** Set AGC ON/OFF. */
void MainWindow::setAgcOn(bool agc_on)
{
rx->set_agc_on(agc_on);
uiDockAudio->setGainEnabled(!agc_on);
}

/** AGC hang ON/OFF. */
void MainWindow::setAgcHang(bool use_hang)
void MainWindow::setAgcHang(int hang)
{
rx->set_agc_hang(use_hang);
rx->set_agc_hang(hang);
}

/** AGC threshold changed. */
void MainWindow::setAgcThreshold(int threshold)
void MainWindow::setAgcTargetLevel(int targetLevel)
{
rx->set_agc_threshold(threshold);
rx->set_agc_target_level(targetLevel);
}

/** AGC slope factor changed. */
void MainWindow::setAgcSlope(int factor)
void MainWindow::setAgcAttack(int attack)
{
rx->set_agc_slope(factor);
rx->set_agc_attack(attack);
}

/** AGC manual gain changed. */
void MainWindow::setAgcGain(int gain)
/** AGC maximum gain changed. */
void MainWindow::setAgcMaxGain(int gain)
{
rx->set_agc_manual_gain(gain);
rx->set_agc_max_gain(gain);
}

/** AGC decay changed. */
Expand Down Expand Up @@ -1452,6 +1472,10 @@ void MainWindow::meterTimeout()
level = rx->get_signal_pwr();
ui->sMeter->setLevel(level);
remote->setSignalLevel(level);
if(uiDockRxOpt->getAgcOn())
{
uiDockAudio->setAudioGain(rx->get_agc_gain() * 10.f);
}
}

/** Baseband FFT plot timeout. */
Expand Down
9 changes: 5 additions & 4 deletions src/applications/gqrx/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,16 @@ private slots:
void setAmSyncDcr(bool enabled);
void setAmSyncPllBw(float pll_bw);
void setAgcOn(bool agc_on);
void setAgcHang(bool use_hang);
void setAgcThreshold(int threshold);
void setAgcSlope(int factor);
void setAgcHang(int hang);
void setAgcTargetLevel(int targetLevel);
void setAgcAttack(int attack);
void setAgcDecay(int msec);
void setAgcGain(int gain);
void setAgcMaxGain(int gain);
void setNoiseBlanker(int nbid, bool on, float threshold);
void setSqlLevel(double level_db);
double setSqlLevelAuto();
void setAudioGain(float gain);
void setAudioMute(bool mute);
void setPassband(int bandwidth);

/* audio recording and playback */
Expand Down
Loading

0 comments on commit efa4766

Please sign in to comment.