RedstartSessionExperimentalTalkthroughDialog.cpp 4.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 *  --------------------------------------------------------------------------------------------
 *
 *    VVV        VVV A           Virtual Acoustics (VA) | http://www.virtualacoustics.org
 *     VVV      VVV AAA          Licensed under the Apache License, Version 2.0
 *      VVV    VVV   AAA
 *       VVV  VVV     AAA        Copyright 2015-2017
 *        VVVVVV       AAA       Institute of Technical Acoustics (ITA)
 *         VVVV         AAA      RWTH Aachen University
 *
 *  --------------------------------------------------------------------------------------------
 */

#include "RedstartSessionExperimentalTalkthroughDialog.h"
#include <ui_RedstartSessionExperimentalTalkthroughDialog.h>

#include <QFileDialog>
#include <QSettings>

RedstartSessionExperimentalTalkthroughDialog::RedstartSessionExperimentalTalkthroughDialog( QWidget *parent )
	: QDialog( parent ),
	ui( new Ui::RedstartSessionExperimentalTalkthroughDialog )
{
	ui->setupUi( this );

	QDialog::setWindowTitle( "Experimental talkthrough session" );
27

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
	QSettings qSettings;
	QString sLastBrowseFolder = qSettings.value( "Redstart/last_browse_folder" ).toString();
	std::string s = sLastBrowseFolder.toStdString();

	if( QDir( sLastBrowseFolder ).exists() )
		m_oLastBasePath.setCurrent( sLastBrowseFolder );
}

RedstartSessionExperimentalTalkthroughDialog::~RedstartSessionExperimentalTalkthroughDialog()
{
	if( m_oLastBasePath.exists() )
		m_qSettings.setValue( "Redstart/last_browse_folder", m_oLastBasePath.absolutePath() );
	delete ui;
}

Dipl.-Ing. Jonas Stienen's avatar
Mooore    
Dipl.-Ing. Jonas Stienen committed
43
44
45
46
47
QString RedstartSessionExperimentalTalkthroughDialog::GetSessionName() const
{
	return ui->lineEdit_session_name->text();
}

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
QVariantHash RedstartSessionExperimentalTalkthroughDialog::GetCoreConfig() const
{
	QVariantHash oFinalCoreConfig;

	QVariantHash oPaths;
	if( m_oDemoSoundBasePath.exists() )
		oPaths[ "DemoSoundBasePath" ] = m_oDemoSoundBasePath.absolutePath();
	if( m_oHRIRBasePath.exists() )
		oPaths[ "DefaultHRIRBasePath" ] = m_oHRIRBasePath.absolutePath();

	oFinalCoreConfig[ "Paths" ] = oPaths;


	QString sDemoSoundMacro = ui->lineEdit_macro_DemoSound->text();
	if( ui->checkBox_folders_as_search_path->isChecked() )
	{
		QFileInfo oDemoSound( sDemoSoundMacro );
		sDemoSoundMacro = oDemoSound.fileName();
	}

	QVariantHash oMacros;
	oMacros[ "DefaultHRIR" ] = "$(DefaultHRIR)";
	oMacros[ "DemoSound" ] = sDemoSoundMacro;

	oFinalCoreConfig[ "Macros" ] = oMacros;

Dipl.-Ing. Jonas Stienen's avatar
Mooore    
Dipl.-Ing. Jonas Stienen committed
74
75
	QStringList vsDeviceChannels = ui->lineEdit_output_channels->text().split( ",", QString::SkipEmptyParts );
	QString sDeviceNames;
76

Dipl.-Ing. Jonas Stienen's avatar
Mooore    
Dipl.-Ing. Jonas Stienen committed
77
78
79
80
81
82
83
	int i = 0;
	for( QString sChannelNumber : vsDeviceChannels )
	{
		QVariantHash oDevice;
		oDevice[ "Type" ] = "LS";
		oDevice[ "Channels" ] = sChannelNumber;

84
85
		QString sID = "GenericDevice" + sChannelNumber;
		oFinalCoreConfig[ "OutputDevice:" + sID ] = oDevice;
Dipl.-Ing. Jonas Stienen's avatar
Mooore    
Dipl.-Ing. Jonas Stienen committed
86
87
88
89
90
		if( i++ == 0 )
			sDeviceNames = sID;
		else
			sDeviceNames += "," + sID;
	}
91
92

	QVariantHash oOutput;
Dipl.-Ing. Jonas Stienen's avatar
Mooore    
Dipl.-Ing. Jonas Stienen committed
93
	oOutput[ "Devices" ] = sDeviceNames;
94

Dipl.-Ing. Jonas Stienen's avatar
Mooore    
Dipl.-Ing. Jonas Stienen committed
95
	oFinalCoreConfig[ "Output:MyGenericOutput" ] = oOutput;
96
97

	QVariantHash oReproduction;
98
	oReproduction[ "Class" ] = "Talkthrough";
Dipl.-Ing. Jonas Stienen's avatar
Mooore    
Dipl.-Ing. Jonas Stienen committed
99
	oReproduction[ "Outputs" ] = "MyGenericOutput";
100

Dipl.-Ing. Jonas Stienen's avatar
Mooore    
Dipl.-Ing. Jonas Stienen committed
101
	oFinalCoreConfig[ "Reproduction:MyGenericTalkthrough" ] = oReproduction;
102
103

	QVariantHash oRenderer;
Dipl.-Ing. Jonas Stienen's avatar
Mooore    
Dipl.-Ing. Jonas Stienen committed
104
105
106
	oRenderer[ "Class" ] = "PrototypeGenericPath";
	oRenderer[ "NumChannels" ] = ui->spinBox_num_channels->value();
	oRenderer[ "Outputs" ] = "MyGenericTalkthrough";
107

Dipl.-Ing. Jonas Stienen's avatar
Mooore    
Dipl.-Ing. Jonas Stienen committed
108
	oFinalCoreConfig[ "Renderer:MyExperimentalRenderer" ] = oRenderer;
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

	return oFinalCoreConfig;
}

void RedstartSessionExperimentalTalkthroughDialog::on_pushButton_CreateSession_clicked()
{
	accept();
	close();
}

void RedstartSessionExperimentalTalkthroughDialog::on_pushButton_select_demo_sound()
{
	QFileDialog fd;
	fd.setNameFilter( "WAV files (*.wav)" );
	fd.setViewMode( QFileDialog::Detail );

	if( m_oLastBasePath.exists() )
		fd.setDirectory( m_oLastBasePath );
	else
		fd.setDirectory( QDir( QApplication::applicationDirPath() ) );

	if( fd.exec() )
	{
		QStringList lFiles = fd.selectedFiles();
		if( lFiles.empty() == false )
		{
			QString sFilePath = lFiles[ 0 ];
			QFile oFile( sFilePath );
			if( oFile.exists() )
			{
				m_oDemoSoundBasePath = fd.directory();
				m_oLastBasePath = m_oDemoSoundBasePath;
			}
			ui->lineEdit_macro_DemoSound->setText( oFile.fileName() );
		}
	}
}