Adding features to bidirectionally control i/o gains using signals and slots

parent c4917735
......@@ -76,13 +76,11 @@ RedstartWindow::RedstartWindow( bool bFailSafeMode, bool bAutoStart, bool bSkipC
LoadConfiguration();
// Signals & slots
connect( ui->doubleSpinBox_input_gain, SIGNAL( valueChanged( double ) ), this, SLOT( CoreChangeInputSignalDecibel( double ) ) );
connect( this, SIGNAL( InputSignalChangedDecibel( double ) ), ui->doubleSpinBox_input_gain, SLOT( setValue( double ) ) );
connect( ui->dial_core_control_input_gain, SIGNAL( valueChanged( int ) ), this, SLOT( CoreChangeInputSignalDecibel( int ) ) );
connect( this, SIGNAL( InputSignalChangedDecibel( int ) ), ui->dial_core_control_input_gain, SLOT( setValue( int ) ) );
//connect( &m_qRenderTimer, SIGNAL( timeout() ), this, SLOT( Render() ) );
ConnectSignalsAndSlots();
ui->menuRun->setEnabled( false );
if( ui->checkBox_redstart_network_connect_as_client->isChecked() )
ui->groupBox_redstart_audio_iface->setEnabled( false );
......@@ -106,6 +104,28 @@ RedstartWindow::~RedstartWindow()
delete m_pVANetClient;
}
void RedstartWindow::ConnectSignalsAndSlots()
{
// Input control
connect( ui->doubleSpinBox_input_gain, SIGNAL( valueChanged( double ) ), this, SLOT( CoreChangeInputSignalDecibel( double ) ) );
connect( this, SIGNAL( InputSignalChangedDecibel( double ) ), ui->doubleSpinBox_input_gain, SLOT( setValue( double ) ) );
connect( ui->dial_core_control_input_gain, SIGNAL( valueChanged( int ) ), this, SLOT( CoreChangeInputSignalDecibel( int ) ) );
connect( this, SIGNAL( InputSignalChangedDecibel( int ) ), ui->dial_core_control_input_gain, SLOT( setValue( int ) ) );
connect( this, SIGNAL( InputIsMutedChanged( bool ) ), ui->checkBox_core_control_input_mute, SLOT( setChecked( bool ) ) );
connect( ui->checkBox_core_control_input_mute, SIGNAL( stateChanged( int ) ), this, SLOT( CoreChangeInputIsMuted( int ) ) );
// Output control
connect( ui->doubleSpinBox_output_gain, SIGNAL( valueChanged( double ) ), this, SLOT( CoreChangeOutputSignalDecibel( double ) ) );
connect( this, SIGNAL( OutputSignalChangedDecibel( double ) ), ui->doubleSpinBox_output_gain, SLOT( setValue( double ) ) );
connect( ui->dial_core_control_output_gain, SIGNAL( valueChanged( int ) ), this, SLOT( CoreChangeOutputSignalDecibel( int ) ) );
connect( this, SIGNAL( OutputSignalChangedDecibel( int ) ), ui->dial_core_control_output_gain, SLOT( setValue( int ) ) );
connect( this, SIGNAL( OutputIsMutedChanged( bool ) ), ui->checkBox_core_control_output_mute, SLOT( setChecked( bool ) ) );
connect( ui->checkBox_core_control_output_mute, SIGNAL( stateChanged( int ) ), this, SLOT( CoreChangeOutputIsMuted( int ) ) );
//connect( &m_qRenderTimer, SIGNAL( timeout() ), this, SLOT( Render() ) );
}
void RedstartWindow::LoadConfiguration()
{
RestoreWindowSize();
......@@ -258,23 +278,24 @@ void RedstartWindow::HandleVAEvent( const CVAEvent* pEvent )
break;
}
// Don't handle events that have been triggered from this interface connection
/* Don't handle events that have been triggered from this interface connection
if( pEvent->pSender == m_pVAInterface )
return;
*/
switch( pEvent->iEventType )
{
case CVAEvent::VA_EVENT_INPUT_GAIN_CHANGED:
ui->dial_core_control_input_gain->setValue( pEvent->dVolume );
emit InputSignalChangedDecibel( ratio_to_db20( pEvent->dVolume ) );
break;
case CVAEvent::VA_EVENT_OUTPUT_GAIN_CHANGED:
ui->dial_core_control_output_gain->setValue( pEvent->dVolume );
emit OutputSignalChangedDecibel( ratio_to_db20( pEvent->dVolume ) );
break;
case CVAEvent::VA_EVENT_INPUT_MUTING_CHANGED:
ui->checkBox_core_control_input_mute->setChecked( pEvent->bMuted );
emit InputIsMutedChanged( pEvent->bMuted );
break;
case CVAEvent::VA_EVENT_OUTPUT_MUTING_CHANGED:
ui->checkBox_core_control_output_mute->setChecked( pEvent->bMuted );
emit OutputIsMutedChanged( pEvent->bMuted );
break;
}
}
......@@ -874,14 +895,40 @@ void RedstartWindow::CoreChangeInputSignalDecibel( double dLevelDB )
}
}
/*
void RedstartWindow::InputSignalChangedDecibel( double dLevelDB )
void RedstartWindow::CoreChangeInputIsMuted( int iMuted )
{
ui->doubleSpinBox_input_gain->setValue( dLevelDB );
int iGain = db20_to_ratio( dLevelDB ) * ( ui->dial_core_control_input_gain->maximum() - ui->dial_core_control_input_gain->minimum() );
ui->dial_core_control_input_gain->setValue( iGain );
emit InputIsMutedChanged( ( bool ) iMuted );
if( m_pVAInterface )
m_pVAInterface->SetInputMuted( ( bool ) iMuted );
}
void RedstartWindow::CoreChangeOutputSignalDecibel( int iLevelDB )
{
emit OutputSignalChangedDecibel( iLevelDB );
emit OutputSignalChangedDecibel( ( double ) iLevelDB );
}
*/
void RedstartWindow::CoreChangeOutputSignalDecibel( double dLevelDB )
{
emit OutputSignalChangedDecibel( dLevelDB );
emit OutputSignalChangedDecibel( ( int ) dLevelDB );
if( m_pVAInterface )
{
const double dGain = db20_to_ratio( dLevelDB );
m_pVAInterface->SetOutputGain( dGain );
}
}
void RedstartWindow::CoreChangeOutputIsMuted( int iMuted )
{
emit OutputIsMutedChanged( ( bool ) iMuted );
if( m_pVAInterface )
m_pVAInterface->SetOutputMuted( ( bool ) iMuted );
}
void RedstartWindow::on_actionRunSimpleExample_triggered()
{
......
......@@ -154,21 +154,22 @@ private slots:
void CoreChangeInputSignalDecibel( int );
void CoreChangeInputSignalDecibel( double );
void CoreChangeInputIsMuted( int );
void CoreChangeOutputSignalDecibel( int );
void CoreChangeOutputSignalDecibel( double );
void CoreChangeOutputIsMuted( int );
signals:
void InputSignalChangedDecibel( int );
void InputSignalChangedDecibel( double );
void OutputSignalChangedDecibel( int );
void OutputSignalChangedDecibel( double );
void InputIsMutedChanged( bool );
void OutputIsMutedChanged( bool );
private:
void PostCoreStart();
void PostCoreStop();
void RestoreWindowSize();
void HandleVAEvent( const CVAEvent* );
private:
Ui::RedstartWindow* ui;
IVAInterface* m_pVAInterface;
IVANetClient* m_pVANetClient;
......@@ -179,15 +180,25 @@ private:
QSettings m_qSettings;
RedstartSessionListView* pSessionListModel;
void LoadConfiguration();
void StoreConfiguration();
void UpdateMeasures( const std::vector< float >& vfInputRMSs, const std::vector< float >& vfInputPeaks, const std::vector< float >& vfOutputRMSs, const std::vector< float >& vfOutputPeaks );
void RestoreWindowSize();
void ConnectSignalsAndSlots();
void PopulateAudioDevices();
void AcquireAsioDevices();
void AcquirePortaudioDevices();
RedstartSessionListView* pSessionListModel;
void PostCoreStart();
void PostCoreStop();
void HandleVAEvent( const CVAEvent* );
void UpdateMeasures( const std::vector< float >& vfInputRMSs, const std::vector< float >& vfInputPeaks, const std::vector< float >& vfOutputRMSs, const std::vector< float >& vfOutputPeaks );
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment