Simple PTT feature: implemented vox. Issue #1002

This commit is contained in:
f4exb 2022-01-03 19:07:43 +01:00
parent 79ac722e79
commit afc106b51f
8 changed files with 58 additions and 14 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

BIN
doc/img/SimplePTT_vox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
doc/img/SimplePTT_vox.xcf Normal file

Binary file not shown.

View File

@ -6,7 +6,7 @@ This plugin controls switchover between a Rx (Device source) and Tx (Device sink
<h2>Interface</h2>
![File source channel plugin GUI](../../../doc/img/SimplePTT_plugin.png)
![PTT feature plugin GUI](../../../doc/img/SimplePTT_plugin.png)
<h3>1: Start/Stop plugin</h3>
@ -24,22 +24,52 @@ This LED type display shows the current PTT status:
- **Red**: Tx runs
- **Grey**: None active (transient)
<h3>4: Refresh list of devices</h3>
<h3>4: Vox control</h3>
![PTT feature vox control](../../../doc/img/SimplePTT_vox.png)
<h4>4.1: Activate vox system</h4>
Toggle this switch to activate or de-activate vox control. When activated the audio input level is monitored and appears in (4.5) and if the level exceeds the level set by (4.3) and displayed in (4.4) then the vox button turns green until vox goes off after the hold period (4.6). The vox system controls the PTT only if the vox PTT enable checkbox is checked (4.2). Thus you can set the appropriate level (4.3) before engaging PTT control.
Right click on this button to open the audio input device selection dialog.
<h4>4.2: Enable PTT control</h4>
Check this box to enable PTT control by the vox system.
<h4>4.3: Vox threshold level</h4>
Use this button to adjust the vox threshold level in power dB (0 dB = full range)
<h4>4.4: Vox threshold display</h4>
This is the value set by (4.3) in dB.
<h4>4.5: Audio input level</h4>
This is the audio input level in dB displayed when the vox system is active (4.1)
<h4>4.6: Vox hold period</h4>
The vox is held active for this amount of time in milliseconds after the audio input power goes below the threshold level (4.3)
<h3>5: Refresh list of devices</h3>
Use this button to refresh the list of devices (5) and (6)
<h3>5: Select Rx device set</h3>
<h3>6: Select Rx device set</h3>
Use this combo to select which Rx device is controlled
<h3>6: Select Tx device set</h3>
<h3>7: Select Tx device set</h3>
Use this combo to select which Tx device is controlled
<h3>7: Transistion delay from Rx to Tx</h3>
<h3>8: Transistion delay from Rx to Tx</h3>
Value in milliseconds between Rx stop and Tx start
<h3>8: Transistion delay from Tx to Rx</h3>
<h3>9: Transistion delay from Tx to Rx</h3>
Value in milliseconds between Tx stop and Rx start

View File

@ -99,9 +99,9 @@ bool SimplePTTGUI::handleMessage(const Message& message)
const SimplePTTReport::MsgVox& cfg = (const SimplePTTReport::MsgVox&) message;
if (cfg.getVox()) {
ui->voxLevelText->setStyleSheet("QLabel { background-color : green; }");
ui->voxLevel->setStyleSheet("QDial { background-color : green; }");
} else {
ui->voxLevelText->setStyleSheet("QLabel { background:rgb(79,79,79); }");
ui->voxLevel->setStyleSheet("QDial { background:rgb(79,79,79); }");
}
return true;
@ -331,6 +331,13 @@ void SimplePTTGUI::on_startStop_toggled(bool checked)
{
if (m_doApplySettings)
{
if (checked)
{
updateDeviceSetLists();
displaySettings();
applySettings();
}
SimplePTT::MsgStartStop *message = SimplePTT::MsgStartStop::create(checked);
m_simplePTT->getInputMessageQueue()->push(message);
}
@ -393,7 +400,7 @@ void SimplePTTGUI::on_voxEnable_clicked(bool checked)
void SimplePTTGUI::on_voxLevel_valueChanged(int value)
{
m_settings.m_voxLevel = value;
ui->voxLevelText->setText(tr("%1dB").arg(m_settings.m_voxLevel));
ui->voxLevelText->setText(tr("%1").arg(m_settings.m_voxLevel));
applySettings();
}
@ -453,6 +460,7 @@ void SimplePTTGUI::applyPTT(bool tx)
{
if (m_doApplySettings)
{
qDebug("SimplePTTGUI::applyPTT: %s", tx ? "tx" : "rx");
SimplePTT::MsgPTT* message = SimplePTT::MsgPTT::create(tx);
m_simplePTT->getInputMessageQueue()->push(message);
}

View File

@ -243,10 +243,10 @@
<string>Vox delay (ms)</string>
</property>
<property name="minimum">
<number>200</number>
<number>500</number>
</property>
<property name="maximum">
<number>2000</number>
<number>5000</number>
</property>
<property name="singleStep">
<number>100</number>

View File

@ -106,7 +106,7 @@ bool SimplePTTWorker::handleMessage(const Message& cmd)
else if (MsgPTT::match(cmd))
{
MsgPTT& cfg = (MsgPTT&) cmd;
qDebug() << "SimplePTTWorker::handleMessage: MsgPTT";
qDebug() << "SimplePTTWorker::handleMessage: MsgPTT tx:" << cfg.getTx();
sendPTT(cfg.getTx());
@ -142,6 +142,8 @@ void SimplePTTWorker::applySettings(const SimplePTTSettings& settings, bool forc
audioDeviceManager->removeAudioSource(&m_audioFifo);
audioDeviceManager->addAudioSource(&m_audioFifo, getInputMessageQueue(), audioDeviceIndex);
m_audioSampleRate = audioDeviceManager->getInputSampleRate(audioDeviceIndex);
m_voxHoldCount = 0;
m_voxState = false;
}
if ((settings.m_vox != m_settings.m_vox) || force)
@ -174,6 +176,7 @@ void SimplePTTWorker::applySettings(const SimplePTTSettings& settings, bool forc
void SimplePTTWorker::sendPTT(bool tx)
{
qDebug("SimplePTTWorker::sendPTT: %s", tx ? "tx" : "rx");
if (!m_updateTimer.isActive())
{
bool switchedOff = false;
@ -218,6 +221,7 @@ void SimplePTTWorker::sendPTT(bool tx)
void SimplePTTWorker::updateHardware()
{
qDebug("SimplePTTWorker::updateHardware: m_tx: %s", m_tx ? "on" : "off");
SWGSDRangel::SWGSuccessResponse response;
SWGSDRangel::SWGErrorResponse error;
m_updateTimer.stop();
@ -240,6 +244,7 @@ void SimplePTTWorker::updateHardware()
bool SimplePTTWorker::turnDevice(bool on)
{
qDebug("SimplePTTWorker::turnDevice %s: %s", m_tx ? "tx" : "rx", on ? "on" : "off");
SWGSDRangel::SWGDeviceState response;
SWGSDRangel::SWGErrorResponse error;
int httpCode;
@ -254,6 +259,7 @@ bool SimplePTTWorker::turnDevice(bool on)
if (httpCode/100 == 2)
{
qDebug("SimplePTTWorker::turnDevice: %s success", on ? "on" : "off");
return true;
}
else
@ -278,9 +284,9 @@ void SimplePTTWorker::handleAudio()
{
bool voxState = m_voxState;
for (const auto &it : m_audioReadBuffer)
for (unsigned int i = 0; i < m_audioReadBufferFill; i++)
{
std::complex<float> za{it.l / 32768.0f, it.r / 32768.0f};
std::complex<float> za{m_audioReadBuffer[i].l / 46334.0f, m_audioReadBuffer[i].r / 46334.0f};
float magSq = std::norm(za);
if (magSq > m_audioMagsqPeak) {