Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ITAConvolution
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Institute of Technical Acoustics (ITA)
ITAConvolution
Commits
b179addd
Commit
b179addd
authored
8 years ago
by
Jonas Stienen
Browse files
Options
Downloads
Patches
Plain Diff
Fixing some problems with ita_convoi and the ITAPA usage, streaming is now running
parent
a38eb579
Branches
Hotfix/2417-emptyMetadataValidation
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/ita_convoi/ita_convoi.cpp
+82
-43
82 additions, 43 deletions
apps/ita_convoi/ita_convoi.cpp
with
82 additions
and
43 deletions
apps/ita_convoi/ita_convoi.cpp
+
82
−
43
View file @
b179addd
...
@@ -37,8 +37,6 @@
...
@@ -37,8 +37,6 @@
#include
<VistaTools/VistaFileSystemFile.h>
#include
<VistaTools/VistaFileSystemFile.h>
using
namespace
std
;
class
ITAStreamConvolver
:
public
ITADatasourceRealizationEventHandler
,
public
DSMBCConvolver
class
ITAStreamConvolver
:
public
ITADatasourceRealizationEventHandler
,
public
DSMBCConvolver
{
{
public:
public:
...
@@ -76,24 +74,25 @@ private:
...
@@ -76,24 +74,25 @@ private:
ITADatasourceRealization
*
m_pdsOutput
;
ITADatasourceRealization
*
m_pdsOutput
;
};
};
string
ita_convoi_syntax
();
std
::
string
ita_convoi_syntax
();
string
ita_convoi_commands
();
std
::
string
ita_convoi_commands
();
void
ita_convio_exchange_channel
(
ITAStreamConvolver
*
,
const
ITASampleFrame
&
,
const
int
iChannelIndex
);
void
ita_convio_exchange_channel
(
ITAStreamConvolver
*
,
const
ITASampleFrame
&
,
const
int
iChannelIndex
);
void
ita_convio_dirac_channel
(
ITAStreamConvolver
*
);
int
main
(
int
argc
,
char
*
argv
[]
)
int
main
(
int
argc
,
char
*
argv
[]
)
{
{
if
(
argc
<
3
)
if
(
argc
<
3
)
{
{
cout
<<
ita_convoi_syntax
()
<<
endl
;
std
::
cout
<<
ita_convoi_syntax
()
<<
std
::
endl
;
return
255
;
return
255
;
}
}
// Input wav file
// Input wav file
string
sInputFilePath
=
string
(
argv
[
1
]
);
std
::
string
sInputFilePath
=
std
::
string
(
argv
[
1
]
);
VistaFileSystemFile
oInputFile
(
sInputFilePath
);
VistaFileSystemFile
oInputFile
(
sInputFilePath
);
if
(
!
oInputFile
.
Exists
()
||
!
oInputFile
.
IsFile
()
)
if
(
!
oInputFile
.
Exists
()
||
!
oInputFile
.
IsFile
()
)
{
{
cerr
<<
"Input file '"
<<
oInputFile
.
GetName
()
<<
"' not found or invalid"
<<
endl
;
std
::
cerr
<<
"Input file '"
<<
oInputFile
.
GetName
()
<<
"' not found or invalid"
<<
std
::
endl
;
return
255
;
return
255
;
}
}
...
@@ -104,7 +103,7 @@ int main( int argc, char* argv[] )
...
@@ -104,7 +103,7 @@ int main( int argc, char* argv[] )
}
}
catch
(
ITAException
&
e
)
catch
(
ITAException
&
e
)
{
{
cerr
<<
"Could not read input file: "
<<
e
<<
endl
;
std
::
cerr
<<
"Could not read input file: "
<<
e
<<
std
::
endl
;
return
255
;
return
255
;
}
}
...
@@ -112,11 +111,11 @@ int main( int argc, char* argv[] )
...
@@ -112,11 +111,11 @@ int main( int argc, char* argv[] )
delete
pSample
;
delete
pSample
;
// IR filter file
// IR filter file
string
sIRFilePath
=
string
(
argv
[
2
]
);
std
::
string
sIRFilePath
=
std
::
string
(
argv
[
2
]
);
VistaFileSystemFile
oIRFile
(
sIRFilePath
);
VistaFileSystemFile
oIRFile
(
sIRFilePath
);
if
(
!
oIRFile
.
Exists
()
||
!
oIRFile
.
IsFile
()
)
if
(
!
oIRFile
.
Exists
()
||
!
oIRFile
.
IsFile
()
)
{
{
cerr
<<
"IR filter file '"
<<
oIRFile
.
GetName
()
<<
"' not found or invalid"
<<
endl
;
std
::
cerr
<<
"IR filter file '"
<<
oIRFile
.
GetName
()
<<
"' not found or invalid"
<<
std
::
endl
;
return
255
;
return
255
;
}
}
...
@@ -127,7 +126,7 @@ int main( int argc, char* argv[] )
...
@@ -127,7 +126,7 @@ int main( int argc, char* argv[] )
}
}
catch
(
ITAException
&
e
)
catch
(
ITAException
&
e
)
{
{
cerr
<<
"Could not read IR filter file: "
<<
e
<<
endl
;
std
::
cerr
<<
"Could not read IR filter file: "
<<
e
<<
std
::
endl
;
return
255
;
return
255
;
}
}
double
dSamplingRateFilter
=
pIRAudioFile
->
getSamplerate
();
double
dSamplingRateFilter
=
pIRAudioFile
->
getSamplerate
();
...
@@ -138,7 +137,7 @@ int main( int argc, char* argv[] )
...
@@ -138,7 +137,7 @@ int main( int argc, char* argv[] )
// Require matching sampling rates
// Require matching sampling rates
if
(
dSamplingRate
!=
dSamplingRateFilter
)
if
(
dSamplingRate
!=
dSamplingRateFilter
)
{
{
cerr
<<
"Sampling rate of input file ("
<<
dSamplingRate
<<
") and IR filter ("
<<
dSamplingRateFilter
<<
") does not match"
<<
endl
;
std
::
cerr
<<
"Sampling rate of input file ("
<<
dSamplingRate
<<
") and IR filter ("
<<
dSamplingRateFilter
<<
") does not match"
<<
std
::
endl
;
return
255
;
return
255
;
}
}
...
@@ -149,25 +148,25 @@ int main( int argc, char* argv[] )
...
@@ -149,25 +148,25 @@ int main( int argc, char* argv[] )
}
}
// Start audio streaming
// Start audio streaming
ITAPortaudioInterface
::
ITA_PA_ERRORCODE
iError
;
ITAPortaudioInterface
oITAPA
(
dSamplingRate
,
iBlockLength
);
ITAPortaudioInterface
oITAPA
(
dSamplingRate
,
iBlockLength
);
int
iPortaudioDeviceID
=
oITAPA
.
GetDefaultOutputDevice
();
int
iPortaudioDeviceID
=
oITAPA
.
GetDefaultOutputDevice
();
if
(
argc
>
4
)
if
(
argc
>
4
)
iPortaudioDeviceID
=
int
(
*
argv
[
4
]
);
iPortaudioDeviceID
=
int
(
*
argv
[
4
]
);
ITAPortaudioInterface
::
ITA_PA_ERRORCODE
iError
;
if
(
(
iError
=
oITAPA
.
Initialize
(
iPortaudioDeviceID
)
)
!=
ITAPortaudioInterface
::
ITA_PA_NO_ERROR
)
if
(
(
iError
=
oITAPA
.
Initialize
(
iPortaudioDeviceID
)
)
!=
ITAPortaudioInterface
::
ITA_PA_NO_ERROR
)
{
{
cerr
<<
"Could not initialize Portaudio, encountered error: "
<<
ITAPortaudioInterface
::
GetErrorCodeString
(
iError
)
<<
endl
;
std
::
cerr
<<
"Could not initialize Portaudio, encountered error: "
<<
ITAPortaudioInterface
::
GetErrorCodeString
(
iError
)
<<
std
::
endl
;
return
255
;
return
255
;
}
}
// Streaming chaing
// Streaming chaing
ITAStreamConvolver
oConvolver
(
dSamplingRate
,
iBlockLength
,
iFilterLength
);
ITAStreamConvolver
oConvolver
(
dSamplingRate
,
iBlockLength
,
iFilterLength
);
ITAFileDatasource
oSample
(
oInputFile
.
GetName
(),
iBlockLength
,
true
);
ITAFileDatasource
oSample
(
oInputFile
.
GetName
(),
iBlockLength
,
true
);
if
(
oSample
.
GetNumberOfChannels
()
!=
1
)
if
(
oSample
.
GetNumberOfChannels
()
!=
1
)
{
{
cout
<<
"Warning ... input file has multiple channels, mixing to mono."
<<
endl
;
std
::
cout
<<
"Warning ... input file has multiple channels, mixing to mono."
<<
std
::
endl
;
}
}
ITAStreamPatchbay
oPatchBay
(
dSamplingRate
,
iBlockLength
);
ITAStreamPatchbay
oPatchBay
(
dSamplingRate
,
iBlockLength
);
...
@@ -179,16 +178,32 @@ int main( int argc, char* argv[] )
...
@@ -179,16 +178,32 @@ int main( int argc, char* argv[] )
oPatchBay
.
ConnectChannels
(
iInputID
,
n
,
iOutputID
,
0
);
oPatchBay
.
ConnectChannels
(
iInputID
,
n
,
iOutputID
,
0
);
ITAStreamMultiplier1N
oMultiplier
(
oConvolver
.
GetOutputDataSource
(),
oITAPA
.
GetNumOutputChannels
(
iPortaudioDeviceID
)
);
ITAStreamMultiplier1N
oMultiplier
(
oConvolver
.
GetOutputDataSource
(),
oITAPA
.
GetNumOutputChannels
(
iPortaudioDeviceID
)
);
oITAPA
.
SetPlaybackDatasource
(
&
oMultiplier
);
if
(
(
iError
=
oITAPA
.
SetPlaybackDatasource
(
&
oMultiplier
)
)
!=
ITAPortaudioInterface
::
ITA_PA_NO_ERROR
)
{
std
::
cerr
<<
"Could not set streaming playback for Portaudio, encountered error: "
<<
ITAPortaudioInterface
::
GetErrorCodeString
(
iError
)
<<
std
::
endl
;
return
255
;
}
oITAPA
.
Start
();
if
(
(
iError
=
oITAPA
.
Open
()
)
!=
ITAPortaudioInterface
::
ITA_PA_NO_ERROR
)
{
std
::
cerr
<<
"Could not open streaming over Portaudio, encountered error: "
<<
ITAPortaudioInterface
::
GetErrorCodeString
(
iError
)
<<
std
::
endl
;
return
255
;
}
if
(
(
iError
=
oITAPA
.
Start
()
)
!=
ITAPortaudioInterface
::
ITA_PA_NO_ERROR
)
{
std
::
cerr
<<
"Could not start streaming, encountered error: "
<<
ITAPortaudioInterface
::
GetErrorCodeString
(
iError
)
<<
std
::
endl
;
return
255
;
}
int
iCurrentIRChannelIndex
=
0
;
int
iCurrentIRChannelIndex
=
0
;
ITASampleFrame
sfIR
(
oIRFile
.
GetName
()
);
ITASampleFrame
sfIR
(
oIRFile
.
GetName
()
);
ita_convio_exchange_channel
(
&
oConvolver
,
sfIR
,
iCurrentIRChannelIndex
);
ita_convio_exchange_channel
(
&
oConvolver
,
sfIR
,
iCurrentIRChannelIndex
);
// Start user interaction
// Start user interaction
cout
<<
ita_convoi_commands
()
<<
endl
;
std
::
cout
<<
ita_convoi_commands
()
<<
std
::
endl
;
int
iKey
;
int
iKey
;
while
(
(
iKey
=
_getch
()
)
!=
'q'
)
while
(
(
iKey
=
_getch
()
)
!=
'q'
)
{
{
...
@@ -198,6 +213,10 @@ int main( int argc, char* argv[] )
...
@@ -198,6 +213,10 @@ int main( int argc, char* argv[] )
{
{
// Toggle
// Toggle
oPatchBay
.
SetOutputMuted
(
iOutputID
,
!
oPatchBay
.
IsOutputMuted
(
iOutputID
)
);
oPatchBay
.
SetOutputMuted
(
iOutputID
,
!
oPatchBay
.
IsOutputMuted
(
iOutputID
)
);
if
(
oPatchBay
.
IsOutputMuted
(
iOutputID
)
)
std
::
cout
<<
"Output is now muted"
<<
std
::
endl
;
else
std
::
cout
<<
"Output is loud"
<<
std
::
endl
;
break
;
break
;
}
}
case
(
'n'
)
:
case
(
'n'
)
:
...
@@ -210,61 +229,70 @@ int main( int argc, char* argv[] )
...
@@ -210,61 +229,70 @@ int main( int argc, char* argv[] )
}
}
else
else
{
{
cout
<<
"Only one channel available, doing nothing."
<<
endl
;
std
::
cout
<<
"Only one channel available, doing nothing."
<<
std
::
endl
;
}
}
break
;
break
;
}
}
case
(
1
)
:
case
(
'd'
)
:
case
(
2
)
:
{
case
(
3
)
:
ita_convio_dirac_channel
(
&
oConvolver
);
case
(
4
)
:
break
;
case
(
5
)
:
}
case
(
6
)
:
case
(
48
+
1
)
:
case
(
7
)
:
case
(
48
+
2
)
:
case
(
8
)
:
case
(
48
+
3
)
:
case
(
9
)
:
case
(
48
+
4
)
:
case
(
48
+
5
)
:
case
(
48
+
6
)
:
case
(
48
+
7
)
:
case
(
48
+
8
)
:
case
(
48
+
9
)
:
{
{
// Switch to next channel
// Switch to next channel
if
(
iFilterChannels
<=
iKey
)
int
iRequestedChannelIndex
=
iKey
-
1
-
48
;
if
(
iFilterChannels
>
iRequestedChannelIndex
)
{
{
iCurrentIRChannelIndex
=
i
Key
-
1
;
iCurrentIRChannelIndex
=
i
RequestedChannelIndex
;
ita_convio_exchange_channel
(
&
oConvolver
,
sfIR
,
iCurrentIRChannelIndex
);
ita_convio_exchange_channel
(
&
oConvolver
,
sfIR
,
iCurrentIRChannelIndex
);
}
}
else
else
{
{
cerr
<<
"Requested channel is out of range, maximum IR channel number is "
<<
iFilterChannels
<<
endl
;
std
::
cerr
<<
"Requested channel is out of range, maximum IR channel number is "
<<
iFilterChannels
<<
std
::
endl
;
}
}
break
;
break
;
}
}
default
:
default
:
{
{
cerr
<<
"Unrecognized key command '"
<<
char
(
iKey
)
<<
"'"
<<
endl
;
std
::
cerr
<<
"Unrecognized key command '"
<<
char
(
iKey
)
<<
"'"
<<
std
::
endl
;
cout
<<
ita_convoi_commands
()
<<
endl
;
std
::
cout
<<
ita_convoi_commands
()
<<
std
::
endl
;
break
;
break
;
}
}
}
}
}
}
oITAPA
.
Stop
();
oITAPA
.
Stop
();
oITAPA
.
Close
();
oITAPA
.
Finalize
();
return
0
;
return
0
;
}
}
string
ita_convoi_syntax
()
std
::
string
ita_convoi_syntax
()
{
{
stringstream
ss
;
std
::
stringstream
ss
;
ss
<<
"Syntax: ita_convoi SAMPLE_INPUT_WAV_MONO IR_FILTER_WAV_MULTICHANNEL [BLOCKLENGTH] [PORTAUDIO_DEVICE]"
<<
endl
;
ss
<<
"Syntax: ita_convoi SAMPLE_INPUT_WAV_MONO IR_FILTER_WAV_MULTICHANNEL [BLOCKLENGTH] [PORTAUDIO_DEVICE]"
<<
std
::
endl
;
return
ss
.
str
();
return
ss
.
str
();
}
}
string
ita_convoi_commands
()
std
::
string
ita_convoi_commands
()
{
{
stringstream
ss
;
std
::
stringstream
ss
;
ss
<<
"Commands:
\t
'q' quit"
<<
endl
;
ss
<<
"Commands:
\t
'q' quit"
<<
std
::
endl
;
ss
<<
"
\t\t\t
'm' toggle mute"
<<
endl
;
ss
<<
"
\t\t
'm' toggle mute"
<<
std
::
endl
;
ss
<<
"
\t\t
'n' switch to next IR channel"
<<
endl
;
ss
<<
"
\t\t
'n' switch to next IR channel"
<<
std
::
endl
;
ss
<<
"
\t\t
1-9 exchange IR filter to given channel, if available"
<<
endl
;
ss
<<
"
\t\t
'd' exchange a Dirac filter"
<<
std
::
endl
;
ss
<<
"
\t\t
1-9 exchange IR filter to given channel, if available"
<<
std
::
endl
;
return
ss
.
str
();
return
ss
.
str
();
}
}
...
@@ -275,4 +303,15 @@ void ita_convio_exchange_channel( ITAStreamConvolver* pSC, const ITASampleFrame&
...
@@ -275,4 +303,15 @@ void ita_convio_exchange_channel( ITAStreamConvolver* pSC, const ITASampleFrame&
pFilter
->
load
(
sfIR
[
iChannelIndex
].
GetData
(),
sfIR
.
GetLength
()
);
pFilter
->
load
(
sfIR
[
iChannelIndex
].
GetData
(),
sfIR
.
GetLength
()
);
pSC
->
exchangeFilter
(
pFilter
);
pSC
->
exchangeFilter
(
pFilter
);
pSC
->
releaseFilter
(
pFilter
);
pSC
->
releaseFilter
(
pFilter
);
std
::
cout
<<
"Exchanged filter, now streaming channel "
<<
iChannelIndex
+
1
<<
std
::
endl
;
}
void
ita_convio_dirac_channel
(
ITAStreamConvolver
*
pSC
)
{
DSMBCFilter
*
pFilter
=
pSC
->
requestFilter
();
pFilter
->
identity
();
pSC
->
exchangeFilter
(
pFilter
);
pSC
->
releaseFilter
(
pFilter
);
std
::
cout
<<
"Exchanged Dirac filter"
<<
std
::
endl
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment