Circulating sound source test is now running

parent e5887009
......@@ -38,11 +38,13 @@ RedstartRunCirculatingSourceDialog::RedstartRunCirculatingSourceDialog( QWidget
if( QDir( sLastBrowseFolder ).exists() )
m_oLastBasePath.setCurrent( sLastBrowseFolder );
m_dAzimuth = 0.0f;
m_dElevation = 0.0f;
connect( &m_qVAUpdateTimer, SIGNAL( timeout() ), this, SLOT( UpdateScene() ) );
m_qVAUpdateTimer = new QTimer( this );
connect( m_qVAUpdateTimer, SIGNAL( timeout() ), this, SLOT( UpdateScene() ) );
}
RedstartRunCirculatingSourceDialog::~RedstartRunCirculatingSourceDialog()
......@@ -50,6 +52,7 @@ RedstartRunCirculatingSourceDialog::~RedstartRunCirculatingSourceDialog()
if( m_oLastBasePath.exists() )
m_qSettings.setValue( "Redstart/last_browse_folder", m_oLastBasePath.absolutePath() );
delete ui;
delete m_qVAUpdateTimer;
}
void RedstartRunCirculatingSourceDialog::SetVAInterface( IVAInterface* pVA )
......@@ -63,10 +66,12 @@ void RedstartRunCirculatingSourceDialog::Start()
try
{
CreateScene();
StartUpdateTimer();
ui->pushButton_start->setEnabled( false );
ui->pushButton_stop->setEnabled( true );
ui->pushButton_run->setEnabled( false );
StartUpdateTimer();
}
catch( CVAException& e )
{
......@@ -80,6 +85,7 @@ void RedstartRunCirculatingSourceDialog::Start()
void RedstartRunCirculatingSourceDialog::Stop()
{
StopUpdateTimer();
ui->pushButton_start->setEnabled( true );
ui->pushButton_stop->setEnabled( false );
ui->pushButton_run->setEnabled( true );
......@@ -90,15 +96,18 @@ void RedstartRunCirculatingSourceDialog::Run()
try
{
CreateScene();
StartUpdateTimer();
}
catch( CVAException& e )
{
QString sErrorMessage = QString( "Could not run scene: %1" ).arg( QString::fromStdString( e.ToString() ) );
QString sErrorMessage = QString( "Could not create and run scene: %1" ).arg( QString::fromStdString( e.ToString() ) );
QErrorMessage oErrMsg;
oErrMsg.showMessage( sErrorMessage );
oErrMsg.exec();
return;
}
StartUpdateTimer();
}
void RedstartRunCirculatingSourceDialog::on_pushButton_run_clicked()
......@@ -140,16 +149,27 @@ void RedstartRunCirculatingSourceDialog::CreateScene()
void RedstartRunCirculatingSourceDialog::DeleteScene()
{
m_pVAInterface->SetSoundSourceSignalSource( m_iSourceID, "" );
m_pVAInterface->DeleteSoundSource( m_iSourceID );
m_pVAInterface->DeleteSoundReceiver( m_iReceiverID );
m_pVAInterface->DeleteDirectivity( m_iHRIRID );
m_pVAInterface->DeleteSignalSource( m_sSignalID.toStdString() );
}
void RedstartRunCirculatingSourceDialog::UpdateScene()
{
VAVec3 v3Pos;
v3Pos.x = -std::sin( grad2rad( m_dAzimuth ) ) * ui->doubleSpinBox_radius->value();
v3Pos.y = std::cos( grad2rad( m_dElevation ) ) * ui->doubleSpinBox_radius->value();
v3Pos.y = std::sin( grad2rad( m_dElevation ) ) * ui->doubleSpinBox_radius->value();
v3Pos.z = -std::cos( grad2rad( m_dAzimuth ) ) * ui->doubleSpinBox_radius->value();
m_pVAInterface->SetSoundSourcePosition( m_iSourceID, v3Pos );
try
{
m_pVAInterface->SetSoundSourcePosition( m_iSourceID, v3Pos );
}
catch( CVAException& e )
{
Stop();
}
m_dAzimuth += ui->doubleSpinBox_azi_inc->value();
m_dElevation += ui->doubleSpinBox_ele_inc->value();
......@@ -161,20 +181,31 @@ void RedstartRunCirculatingSourceDialog::UpdateScene()
void RedstartRunCirculatingSourceDialog::StartUpdateTimer()
{
double dTimeout = ui->doubleSpinBox_timeout->value();
m_qVAUpdateTimer.setTimerType( Qt::TimerType::PreciseTimer );
m_qVAUpdateTimer.setInterval( ceil( dTimeout * 1000.0f ) );
const double dTimeout = ui->doubleSpinBox_timeout->value();
const int iIntervalMS = ceil( dTimeout * 1000.0f );
m_qVAUpdateTimer->setInterval( iIntervalMS );
m_qVAUpdateTimer->start();
m_dRuntime = 0.0f;
}
void RedstartRunCirculatingSourceDialog::StopUpdateTimer()
{
m_qVAUpdateTimer.stop();
m_qVAUpdateTimer->stop();
m_dRuntime = 0.0f;
m_dAzimuth = 0.0f;
m_dElevation = 0.0f;
DeleteScene();
try
{
DeleteScene();
}
catch( CVAException& e )
{
QString sErrorMessage = QString( "Could not delete scene: %1" ).arg( QString::fromStdString( e.ToString() ) );
QErrorMessage oErrMsg;
oErrMsg.showMessage( sErrorMessage );
oErrMsg.exec();
}
}
void RedstartRunCirculatingSourceDialog::on_pushButton_BrowseDemoSound_clicked()
......
......@@ -56,7 +56,7 @@ private:
QString m_sFileBaseName;
QSettings m_qSettings;
IVAInterface* m_pVAInterface;
QTimer m_qVAUpdateTimer;
QTimer* m_qVAUpdateTimer;
int m_iSourceID, m_iReceiverID, m_iHRIRID;
QString m_sSignalID;
......
......@@ -155,8 +155,10 @@ void RedstartWindow::LoadConfiguration()
ui->checkBox_redstart_network_connect_as_client->setChecked( m_qSettings.value( "Redstart/network/client_mode" ).toBool() );
if( m_qSettings.contains( "Redstart/autostart" ) )
ui->checkBox_redstart_auto_start->setChecked( m_qSettings.value( "Redstart/autostart" ).toBool() );
{
bool bAutostart = m_qSettings.value( "Redstart/autostart" ).toBool();
ui->checkBox_redstart_auto_start->setChecked( bAutostart );
}
m_iPortaudioDefaultDevice = m_qSettings.value( "Redstart/audio/portaudio_default_device", -1 ).toInt();
......@@ -204,7 +206,9 @@ void RedstartWindow::StoreConfiguration()
m_qSettings.setValue( "Redstart/network/port", iPort );
m_qSettings.setValue( "Redstart/network/client_mode", ui->checkBox_redstart_network_connect_as_client->isChecked() );
m_qSettings.setValue( "Redstart/autostart", ui->checkBox_redstart_auto_start->isChecked() );
bool bAutostart = ui->checkBox_redstart_auto_start->isChecked();
m_qSettings.setValue( "Redstart/autostart", bAutostart );
m_qSettings.setValue( "Redstart/audio/portaudio_default_device", m_iPortaudioDefaultDevice );
int iLastDevice = ui->comboBox_audio_iface_device->currentIndex();
......
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