Issue #100 Seperate COM1/2 output volumes

This commit is contained in:
Lars Toenning
2021-09-03 00:54:40 +02:00
committed by Mat Sutcliffe
parent 577431ae49
commit c1b75f7532
24 changed files with 270 additions and 509 deletions

View File

@@ -47,12 +47,14 @@ namespace BlackGui
ui(new Ui::CAudioDeviceVolumeSetupComponent)
{
ui->setupUi(this);
connect(ui->hs_VolumeIn, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
connect(ui->hs_VolumeOut, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
connect(ui->tb_RefreshInDevice, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onReloadDevices, Qt::QueuedConnection);
connect(ui->tb_RefreshOutDevice, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onReloadDevices, Qt::QueuedConnection);
connect(ui->tb_ResetInVolume, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeIn, Qt::QueuedConnection);
connect(ui->tb_ResetOutVolume, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeOut, Qt::QueuedConnection);
connect(ui->hs_VolumeIn, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
connect(ui->hs_VolumeOutCom1, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
connect(ui->hs_VolumeOutCom2, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged);
connect(ui->tb_RefreshInDevice, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onReloadDevices, Qt::QueuedConnection);
connect(ui->tb_RefreshOutDevice, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onReloadDevices, Qt::QueuedConnection);
connect(ui->tb_ResetInVolume, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeIn, Qt::QueuedConnection);
connect(ui->tb_ResetOutVolumeCom1, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeOutCom1, Qt::QueuedConnection);
connect(ui->tb_ResetOutVolumeCom2, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeOutCom2, Qt::QueuedConnection);
connect(ui->cb_1Tx, &QCheckBox::toggled, this, &CAudioDeviceVolumeSetupComponent::onRxTxChanged, Qt::QueuedConnection);
connect(ui->cb_2Tx, &QCheckBox::toggled, this, &CAudioDeviceVolumeSetupComponent::onRxTxChanged, Qt::QueuedConnection);
@@ -62,14 +64,18 @@ namespace BlackGui
ui->hs_VolumeIn->setMaximum(CSettings::InMax);
ui->hs_VolumeIn->setMinimum(CSettings::InMin);
ui->hs_VolumeOut->setMaximum(CSettings::OutMax);
ui->hs_VolumeOut->setMinimum(CSettings::OutMin);
ui->hs_VolumeOutCom1->setMaximum(CSettings::OutMax);
ui->hs_VolumeOutCom1->setMinimum(CSettings::OutMin);
ui->hs_VolumeOutCom2->setMaximum(CSettings::OutMax);
ui->hs_VolumeOutCom2->setMinimum(CSettings::OutMin);
const CSettings as(m_audioSettings.getThreadLocal());
const int i = this->getInValue();
const int o = this->getOutValue();
const int o1 = this->getOutValueCom1();
const int o2 = this->getOutValueCom2();
ui->hs_VolumeIn->setValue(i);
ui->hs_VolumeOut->setValue(o);
ui->hs_VolumeOutCom1->setValue(o1);
ui->hs_VolumeOutCom2->setValue(o2);
ui->cb_SetupAudioLoopback->setChecked(false);
ui->cb_DisableAudioEffects->setChecked(!as.isAudioEffectsEnabled());
@@ -183,11 +189,18 @@ namespace BlackGui
return qRound(ui->hs_VolumeIn->value() / r * tr);
}
int CAudioDeviceVolumeSetupComponent::getOutValue(int from, int to) const
int CAudioDeviceVolumeSetupComponent::getOutValueCom1(int from, int to) const
{
const double r = ui->hs_VolumeOut->maximum() - ui->hs_VolumeOut->minimum();
const double r = ui->hs_VolumeOutCom1->maximum() - ui->hs_VolumeOutCom1->minimum();
const double tr = to - from;
return qRound(ui->hs_VolumeOut->value() / r * tr);
return qRound(ui->hs_VolumeOutCom1->value() / r * tr);
}
int CAudioDeviceVolumeSetupComponent::getOutValueCom2(int from, int to) const
{
const double r = ui->hs_VolumeOutCom2->maximum() - ui->hs_VolumeOutCom2->minimum();
const double tr = to - from;
return qRound(ui->hs_VolumeOutCom2->value() / r * tr);
}
void CAudioDeviceVolumeSetupComponent::setInValue(int value, int from, int to)
@@ -199,13 +212,22 @@ namespace BlackGui
ui->hs_VolumeIn->setValue(qRound(value / tr * r));
}
void CAudioDeviceVolumeSetupComponent::setOutValue(int value, int from, int to)
void CAudioDeviceVolumeSetupComponent::setOutValueCom1(int value, int from, int to)
{
if (value > to) { value = to; }
else if (value < from) { value = from; }
const double r = ui->hs_VolumeOut->maximum() - ui->hs_VolumeOut->minimum();
const double r = ui->hs_VolumeOutCom1->maximum() - ui->hs_VolumeOutCom1->minimum();
const double tr = to - from;
ui->hs_VolumeOut->setValue(qRound(value / tr * r));
ui->hs_VolumeOutCom1->setValue(qRound(value / tr * r));
}
void CAudioDeviceVolumeSetupComponent::setOutValueCom2(int value, int from, int to)
{
if (value > to) { value = to; }
else if (value < from) { value = from; }
const double r = ui->hs_VolumeOutCom2->maximum() - ui->hs_VolumeOutCom2->minimum();
const double tr = to - from;
ui->hs_VolumeOutCom2->setValue(qRound(value / tr * r));
}
void CAudioDeviceVolumeSetupComponent::setInLevel(double value)
@@ -258,6 +280,12 @@ namespace BlackGui
const bool integrated = this->isComIntegrated();
this->setTransmitReceiveInUi(com1Tx, com1Rx, com2Tx, com2Rx, integrated);
// Set transmit volume in GUI
const int vol1 = sGui->getCContextAudioBase()->getVoiceOutputVolume(CComSystem::Com1);
const int vol2 = sGui->getCContextAudioBase()->getVoiceOutputVolume(CComSystem::Com2);
ui->hs_VolumeOutCom1->setValue(vol1);
ui->hs_VolumeOutCom2->setValue(vol2);
}
void CAudioDeviceVolumeSetupComponent::setCheckBoxesReadOnly(bool readonly)
@@ -280,7 +308,8 @@ namespace BlackGui
const CSettings as(m_audioSettings.getThreadLocal());
ui->cb_DisableAudioEffects->setChecked(!as.isAudioEffectsEnabled());
this->setInValue(as.getInVolume());
this->setOutValue(as.getOutVolume());
this->setOutValueCom1(as.getOutVolumeCom1());
this->setOutValueCom2(as.getOutVolumeCom2());
}
void CAudioDeviceVolumeSetupComponent::initAudioDeviceLists()
@@ -312,10 +341,12 @@ namespace BlackGui
{
CSettings as(m_audioSettings.getThreadLocal());
const int i = this->getInValue();
const int o = this->getOutValue();
if (as.getInVolume() == i && as.getOutVolume() == o) { return; }
const int o1 = this->getOutValueCom1();
const int o2 = this->getOutValueCom2();
if (as.getInVolume() == i && as.getOutVolumeCom1() == o1 && as.getOutVolumeCom2() == o2) { return; }
as.setInVolume(i);
as.setOutVolume(o);
as.setOutVolumeCom1(o1);
as.setOutVolumeCom2(o2);
m_audioSettings.setAndSave(as);
}
@@ -343,9 +374,14 @@ namespace BlackGui
ui->hs_VolumeIn->setValue((ui->hs_VolumeIn->maximum() - ui->hs_VolumeIn->minimum()) / 2);
}
void CAudioDeviceVolumeSetupComponent::onResetVolumeOut()
void CAudioDeviceVolumeSetupComponent::onResetVolumeOutCom1()
{
ui->hs_VolumeOut->setValue((ui->hs_VolumeOut->maximum() - ui->hs_VolumeOut->minimum()) / 2);
ui->hs_VolumeOutCom1->setValue((ui->hs_VolumeOutCom1->maximum() - ui->hs_VolumeOutCom1->minimum()) / 2);
}
void CAudioDeviceVolumeSetupComponent::onResetVolumeOutCom2()
{
ui->hs_VolumeOutCom2->setValue((ui->hs_VolumeOutCom2->maximum() - ui->hs_VolumeOutCom2->minimum()) / 2);
}
void CAudioDeviceVolumeSetupComponent::setAudioRunsWhere()