WIP

parent 5f921c25
......@@ -21,6 +21,7 @@
#include "RedstartDefaultCoreConfig.h"
#include <VA.h>
#include <ITANumericUtils.h>
RedstartRunCirculatingSourceDialog::RedstartRunCirculatingSourceDialog( QWidget *parent )
: QDialog( parent )
......@@ -37,6 +38,11 @@ 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() ) );
}
RedstartRunCirculatingSourceDialog::~RedstartRunCirculatingSourceDialog()
......@@ -101,34 +107,74 @@ void RedstartRunCirculatingSourceDialog::on_pushButton_run_clicked()
accept();
}
void RedstartRunCirculatingSourceDialog::on_pushButton_start_clicked()
{
Start();
}
void RedstartRunCirculatingSourceDialog::on_pushButton_stop_clicked()
{
Stop();
}
void RedstartRunCirculatingSourceDialog::CreateScene()
{
if( !m_pVAInterface )
VA_EXCEPT2( MODAL_ERROR, "No connection to a VA core available" );
const std::string sSignalSourceID = m_pVAInterface->CreateSignalSourceBufferFromFile( ui->lineEdit_macro_DemoSound->text().toStdString() );
m_pVAInterface->SetSignalSourceBufferPlaybackAction( sSignalSourceID, IVAInterface::VA_PLAYBACK_ACTION_PLAY );
m_pVAInterface->SetSignalSourceBufferLooping( sSignalSourceID, true );
m_sSignalID = m_pVAInterface->CreateSignalSourceBufferFromFile( ui->lineEdit_macro_DemoSound->text().toStdString() ).c_str();
m_pVAInterface->SetSignalSourceBufferPlaybackAction( m_sSignalID.toStdString(), IVAInterface::VA_PLAYBACK_ACTION_PLAY );
m_pVAInterface->SetSignalSourceBufferLooping( m_sSignalID.toStdString(), true );
const int iSoundSourceID = m_pVAInterface->CreateSoundSource( "Redstart C++ example sound source" );
m_pVAInterface->SetSoundSourcePose( iSoundSourceID, VAVec3( 2.0f, 1.7f, 2.0f ), VAQuat( 0.0f, 0.0f, 0.0f, 1.0f ) );
m_iSourceID = m_pVAInterface->CreateSoundSource( "Redstart C++ circulating sound source" );
m_pVAInterface->SetSoundSourcePose( m_iSourceID, VAVec3( 2.0f, 1.7f, 2.0f ), VAQuat( 0.0f, 0.0f, 0.0f, 1.0f ) );
m_pVAInterface->SetSoundSourceSignalSource( iSoundSourceID, sSignalSourceID );
m_pVAInterface->SetSoundSourceSignalSource( m_iSourceID, m_sSignalID.toStdString() );
const int iHRIR = m_pVAInterface->CreateDirectivityFromFile( ui->lineEdit_macro_DefaultHRIR->text().toStdString() );
m_iHRIRID = m_pVAInterface->CreateDirectivityFromFile( ui->lineEdit_macro_DefaultHRIR->text().toStdString() );
const int iSoundReceiverID = m_pVAInterface->CreateSoundReceiver( "Redstart C++ example sound receiver" );
m_pVAInterface->SetSoundReceiverPose( iSoundReceiverID, VAVec3( 0.0f, 1.7f, 0.0f ), VAQuat( 0.0f, 0.0f, 0.0f, 1.0f ) );
m_pVAInterface->SetSoundReceiverDirectivity( iSoundReceiverID, iHRIR );
m_iReceiverID = m_pVAInterface->CreateSoundReceiver( "Redstart C++ example sound receiver" );
m_pVAInterface->SetSoundReceiverPose( m_iReceiverID, VAVec3( 0.0f, 1.7f, 0.0f ), VAQuat( 0.0f, 0.0f, 0.0f, 1.0f ) );
m_pVAInterface->SetSoundReceiverDirectivity( m_iReceiverID, m_iHRIRID );
}
void RedstartRunCirculatingSourceDialog::DeleteScene()
{
}
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.z = -std::cos( grad2rad( m_dAzimuth ) ) * ui->doubleSpinBox_radius->value();
m_pVAInterface->SetSoundSourcePosition( m_iSourceID, v3Pos );
m_dAzimuth += ui->doubleSpinBox_azi_inc->value();
m_dElevation += ui->doubleSpinBox_ele_inc->value();
m_dRuntime += ui->doubleSpinBox_timeout->value();
if( m_dRuntime > ui->doubleSpinBox_runtime->value() )
Stop();
}
void RedstartRunCirculatingSourceDialog::StartUpdateTimer()
{
ui->doubleSpinBox_timeout->value();
double dTimeout = ui->doubleSpinBox_timeout->value();
m_qVAUpdateTimer.setTimerType( Qt::TimerType::PreciseTimer );
m_qVAUpdateTimer.setInterval( ceil( dTimeout * 1000.0f ) );
m_dRuntime = 0.0f;
}
void RedstartRunCirculatingSourceDialog::StopUpdateTimer()
{
m_qVAUpdateTimer.stop();
m_dRuntime = 0.0f;
m_dAzimuth = 0.0f;
m_dElevation = 0.0f;
DeleteScene();
}
void RedstartRunCirculatingSourceDialog::on_pushButton_BrowseDemoSound_clicked()
......
......@@ -17,7 +17,7 @@
#include <QDir>
#include <QString>
#include <QSettings>
#include <QHash>
#include <QTimer>
class IVAInterface;
......@@ -43,6 +43,10 @@ private slots:
void on_pushButton_BrowseDemoSound_clicked();
void on_pushButton_BrowseHRIR_clicked();
void on_pushButton_run_clicked();
void on_pushButton_start_clicked();
void on_pushButton_stop_clicked();
void UpdateScene();
private:
Ui::RedstartRunCirculatingSourceDialog* ui;
......@@ -52,9 +56,19 @@ private:
QString m_sFileBaseName;
QSettings m_qSettings;
IVAInterface* m_pVAInterface;
void CreateScene();
QTimer m_qVAUpdateTimer;
int m_iSourceID, m_iReceiverID, m_iHRIRID;
QString m_sSignalID;
double m_dAzimuth, m_dElevation;
double m_dRuntime;
void StartUpdateTimer();
void StopUpdateTimer();
void CreateScene();
void DeleteScene();
};
#endif // IW_REDSTART_RUN_CIRCULATING_SOURCE_DIALOG
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