Commit 26dbb412 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Merge branch 'master' of https://git.rwth-aachen.de/ita/Redstart

parents 8df117ae 7083582e
......@@ -75,22 +75,23 @@ QVariantHash RedstartSessionBinauralHeadphonesDialog::GetCoreConfig() const
oFinalCoreConfig[ "Macros" ] = oMacros;
QVariantHash oSetup;
// @todo switch between talkthrough and headphone reproduction with equalization
QVariantHash oDevice;
oDevice[ "Type" ] = "HP";
oDevice[ "Channels" ] = ui->lineEdit_headphone_channels->text();
oSetup[ "OutputDevice:MyHP" ] = oDevice;
oFinalCoreConfig[ "OutputDevice:MyHP" ] = oDevice;
QVariantHash oOutput;
oOutput[ "Devices" ] = "MyHP";
oSetup[ "Output:MyDesktopHP" ] = oOutput;
oFinalCoreConfig[ "Output:MyDesktopHP" ] = oOutput;
QVariantHash oReproduction;
oReproduction[ "Class" ] = "Talktrough";
oReproduction[ "Class" ] = "Talkthrough";
oReproduction[ "Outputs" ] = "MyDesktopHP";
oFinalCoreConfig[ "Reproduction:MyTalkthroughHeadphones" ] = oReproduction;
......@@ -99,11 +100,16 @@ QVariantHash RedstartSessionBinauralHeadphonesDialog::GetCoreConfig() const
oRenderer[ "Class" ] = "BinauralFreeField";
oRenderer[ "Outputs" ] = "MyTalkthroughHeadphones";
oFinalCoreConfig[ QString( "Renderer:" + ui->lineEdit_session_name->text() ) ] = oRenderer;
oFinalCoreConfig[ "Renderer:MyBinauralRenderer" ] = oRenderer;
return oFinalCoreConfig;
}
QString RedstartSessionBinauralHeadphonesDialog::GetSessionName() const
{
return ui->lineEdit_session_name->text();
}
void RedstartSessionBinauralHeadphonesDialog::on_pushButton_CreateSession_clicked()
{
accept();
......
......@@ -32,6 +32,7 @@ public:
explicit RedstartSessionBinauralHeadphonesDialog( QWidget *parent );
~RedstartSessionBinauralHeadphonesDialog();
QVariantHash GetCoreConfig() const;
QString GetSessionName() const;
private slots:
void on_pushButton_CreateSession_clicked();
......
......@@ -15,6 +15,12 @@
#include <QListView>
#include <QStringListModel>
#include <QSettings>
#include <VAException.h>
#include <VAStruct.h>
#include "RedstartUtils.h"
class RedstartSessionListModel : public QStringListModel
{};
......@@ -31,20 +37,111 @@ public:
m_pModel = new RedstartSessionListModel();
this->setModel( m_pModel );
// Initilizes session container in settings, if not present
if( !m_qSettings.contains( "Redstart/Sessions" ) )
m_qSettings.setValue( "Redstart/Sessions", QMap< QString, QVariant>() );
UpdateSessionList();
QStringList List;
List << "MyBinauralHeadphonesSession" << "MyExperimentalHeadphonesSession";
QString sLastSessionName = m_qSettings.value( "Redstart/last_session" ).toString();
SetCurrentSession( sLastSessionName );
m_pModel->setStringList( List );
setEditTriggers( QAbstractItemView::NoEditTriggers );
setSelectionMode( QAbstractItemView::SingleSelection );
};
inline ~RedstartSessionListView()
{
QString sCurrentSessionName = m_pModel->data( currentIndex() ).toString();
m_qSettings.setValue( "Redstart/last_session", sCurrentSessionName );
};
inline void SetCurrentSession( const QString& sID )
{
QStringList list;
QMap< QString, QVariant > sessions = m_qSettings.value( "Redstart/Sessions" ).toMap();
QMap< QString, QVariant>::const_iterator cit = sessions.constBegin();
int i = -1;
while( cit != sessions.constEnd() )
{
i++;
if( cit++.key() == sID && i < m_pModel->rowCount() )
{
setCurrentIndex( m_pModel->index( i, 0 ) );
return;
}
}
if( m_pModel->rowCount() > 0 )
m_pModel->index( 0, 0 );
};
inline void UpdateSessionList()
{
QMap< QString, QVariant > sessions = m_qSettings.value( "Redstart/Sessions" ).toMap();
if( sessions.count() == 0 )
return;
QStringList list;
QMap< QString, QVariant>::const_iterator cit = sessions.constBegin();
while( cit != sessions.constEnd() )
list.push_back( cit++.key() );
m_pModel->setStringList( list );
};
QString GetCurrentSessionID() const
{
QModelIndex index = currentIndex();
if( m_pModel->rowCount() == 0 || !index.isValid() )
return QString();
QString sSessionName = m_pModel->data( index ).toString();
return sSessionName;
};
inline void AddSession( const QString& sID, const QVariantHash& oCoreConfig, const bool bMakeCurrent = true )
{
QMap< QString, QVariant > sessions = m_qSettings.value( "Redstart/Sessions" ).toMap();
sessions[ sID ] = oCoreConfig;
m_qSettings.setValue( "Redstart/Sessions", sessions );
UpdateSessionList();
if( bMakeCurrent )
SetCurrentSession( sID );
};
inline CVAStruct GetCurrentConfig()
{
if( m_pModel->rowCount() == 0 )
VA_EXCEPT2( INVALID_PARAMETER, "No session vailable, please create one first." );
QMap< QString, QVariant > sessions = m_qSettings.value( "Redstart/Sessions" ).toMap();
QString sSessionName = GetCurrentSessionID();
CVAStruct oCoreConfig;
if( sessions.contains( sSessionName ) )
oCoreConfig = ConvertQHashToVAStruct( sessions[ sSessionName ].toHash() );
else
VA_EXCEPT2( INVALID_PARAMETER, "Could not find Redstart session with identifier '" + sSessionName.toStdString() + "' in session list" );
if( !oCoreConfig.HasKey( "Macros" ) )
oCoreConfig[ "Macros" ] = CVAStruct();
CVAStruct& oMacros( oCoreConfig[ "Macros" ] );
if( !oMacros.HasKey( "ProjectName" ) )
oMacros[ "ProjectName" ] = "Redstart";
return oCoreConfig;
};
public slots :
private:
RedstartSessionListModel* m_pModel;
RedstartSessionListModel* m_pModel;
QSettings m_qSettings;
};
......
......@@ -76,6 +76,8 @@ inline CVAStruct ConvertQHashToVAStruct( const QVariantHash& oHash )
const QVariant& oValue( cit.value() );
++cit;
std::string sKey2 = sKey.toStdString();
bool bOK = true;
switch( oValue.type() )
{
......@@ -105,6 +107,7 @@ inline CVAStruct ConvertQHashToVAStruct( const QVariantHash& oHash )
break;
}
case QVariant::Map:
case QVariant::Hash:
oStruct[ sKey.toStdString() ] = ConvertQHashToVAStruct( oValue.toHash() );
break;
}
......
......@@ -55,10 +55,10 @@ RedstartWindow::RedstartWindow( bool bFailSafeMode, bool bAutoStart, bool bSkipC
ui->comboBox_audio_iface_buffer_size->addItem( "AUTO", AudioBufferSize::AUTO );
m_iPortaudioDefaultDevice = -1;
if( !bSkipConfig )
LoadConfiguration();
if( ui->checkBox_redstart_network_connect_as_client->isChecked() )
ui->groupBox_redstart_audio_iface->setEnabled( false );
......@@ -92,7 +92,7 @@ void RedstartWindow::LoadConfiguration()
if( !bValOK )
iAudioBackend = AudioBackend::ASIO;
ui->comboBox_audio_driver->setCurrentIndex( iAudioBackend );
const int iBufferSizeIndex = m_qSettings.value( "Redstart/audio/buffersize_idx" ).toInt( &bValOK );
if( bValOK && iBufferSizeIndex < ui->comboBox_audio_iface_buffer_size->count() )
ui->comboBox_audio_iface_buffer_size->setCurrentIndex( iBufferSizeIndex );
......@@ -114,7 +114,7 @@ void RedstartWindow::LoadConfiguration()
m_iPortaudioDefaultDevice = m_qSettings.value( "Redstart/audio/portaudio_default_device", -1 ).toInt();
ui->checkBox_portaudio_default_device->setChecked( m_qSettings.value( "Redstart/audio/portaudio_use_default_device", true ).toBool() );
QVariantList voAudioDevices;
voAudioDevices = m_qSettings.value( "Redstart/audio/devicelist" ).toList();
......@@ -388,9 +388,7 @@ void RedstartWindow::on_pushButton_start_stop_clicked()
}
else
{
// @todo get config from session
CVAStruct oVAConfigArgs = VACore::GetCoreConfigFromFile( "../VACore/conf/VACore.ini" );
CVAStruct oVAConfigArgs = ui->listView_redstart_session_list->GetCurrentConfig();
// Override configs
std::string sBackend, sDevice;
......@@ -417,7 +415,10 @@ void RedstartWindow::on_pushButton_start_stop_clicked()
oVAConfigArgs[ "Audio driver" ][ "Driver" ] = sBackend;
oVAConfigArgs[ "Audio driver" ][ "Device" ] = sDevice;
oVAConfigArgs[ "Paths" ][ "redstart_data" ] = "../VACore/data";
if( !oVAConfigArgs.HasKey( "Paths" ) )
oVAConfigArgs[ "Paths" ] = CVAStruct();
oVAConfigArgs[ "Paths" ][ "redstart_data" ] = "data";
oVAConfigArgs[ "Paths" ][ "redstart_data_dev" ] = "../VACore/data";
m_pVAInterface = VACore::CreateCoreInstance( oVAConfigArgs );
m_pVAInterface->Initialize();
......@@ -437,7 +438,7 @@ void RedstartWindow::on_pushButton_start_stop_clicked()
if( m_pVAInterface->GetState() == IVAInterface::VA_CORESTATE_READY && iStatus == IVANetServer::VA_NO_ERROR )
{
ui->statusBar->showMessage( "VA core successfully initialized and network server started." );
ui->statusBar->showMessage( "VA core successfully initialized and network server started. Running session " + ui->listView_redstart_session_list->GetCurrentSessionID() + "." );
PostCoreStart();
}
......@@ -554,11 +555,13 @@ void RedstartWindow::on_checkBox_portaudio_default_device_clicked()
ui->comboBox_audio_iface_device->setEnabled( true );
}
void RedstartWindow::on_listView_redstart_session_list_clicked(const QModelIndex &index)
void RedstartWindow::on_listView_redstart_session_list_clicked( const QModelIndex &index )
{
std::string sSessionName = ui->listView_redstart_session_list->model()->data( index ).toString().toStdString();
ui->listView_redstart_session_list;
return;
}
......@@ -566,11 +569,7 @@ void RedstartWindow::on_actionBinauralHeadphones_triggered()
{
RedstartSessionBinauralHeadphonesDialog d( this );
if( d.exec() )
{
QVariantHash oCoreConfig = d.GetCoreConfig();
// add session
return;
}
ui->listView_redstart_session_list->AddSession( d.GetSessionName(), d.GetCoreConfig() );
}
void RedstartWindow::on_actionDefault_experimental_session_triggered()
......
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