RedstartSessionExperimentalTalkthroughDialog.cpp 4.38 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 *  --------------------------------------------------------------------------------------------
 *
 *    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" );
	
	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;
}

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;


	QVariantHash oSetup;

	QVariantHash oDevice;
	oDevice[ "Type" ] = "LSS";
	oDevice[ "Channels" ] = ui->lineEdit_output_channels->text();

	oSetup[ "OutputDevice:MyHP" ] = oDevice;

	QVariantHash oOutput;
	oOutput[ "Devices" ] = "MyHP";

	oSetup[ "Output:MyDesktopHP" ] = oOutput;

	QVariantHash oReproduction;
	oReproduction[ "Class" ] = "Talktrough";
	oReproduction[ "Outputs" ] = "MyDesktopHP";

	oFinalCoreConfig[ "Reproduction:MyTalkthroughHeadphones" ] = oReproduction;

	QVariantHash oRenderer;
	oRenderer[ "Class" ] = "BinauralFreeField";
	oRenderer[ "Outputs" ] = "MyTalkthroughHeadphones";

	oFinalCoreConfig[ QString( "Renderer:" + ui->lineEdit_session_name->text() ) ] = oRenderer;

	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() );
		}
	}
}

/*
void RedstartSessionBinauralHeadphonesDialog::on_pushButton_BrowseHRIR_clicked()
{
	QFileDialog fd;
	fd.setNameFilter( "DAFF files (*.daff)" );
	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_oHRIRBasePath = fd.directory();
				m_oLastBasePath = m_oHRIRBasePath;

			}

			ui->lineEdit_macro_DefaultHRIR->setText( sFilePath );
		}
	}
}
*/