Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
ITAConvolution
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Institute of Technical Acoustics (ITA)
ITAConvolution
Commits
b179addd
Commit
b179addd
authored
Apr 19, 2017
by
Jonas Stienen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing some problems with ita_convoi and the ITAPA usage, streaming is now running
parent
a38eb579
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
43 deletions
+82
-43
apps/ita_convoi/ita_convoi.cpp
apps/ita_convoi/ita_convoi.cpp
+82
-43
No files found.
apps/ita_convoi/ita_convoi.cpp
View file @
b179addd
...
...
@@ -37,8 +37,6 @@
#include <VistaTools/VistaFileSystemFile.h>
using
namespace
std
;
class
ITAStreamConvolver
:
public
ITADatasourceRealizationEventHandler
,
public
DSMBCConvolver
{
public:
...
...
@@ -76,24 +74,25 @@ private:
ITADatasourceRealization
*
m_pdsOutput
;
};
string
ita_convoi_syntax
();
string
ita_convoi_commands
();
st
d
::
st
ring
ita_convoi_syntax
();
st
d
::
st
ring
ita_convoi_commands
();
void
ita_convio_exchange_channel
(
ITAStreamConvolver
*
,
const
ITASampleFrame
&
,
const
int
iChannelIndex
);
void
ita_convio_dirac_channel
(
ITAStreamConvolver
*
);
int
main
(
int
argc
,
char
*
argv
[]
)
{
if
(
argc
<
3
)
{
cout
<<
ita_convoi_syntax
()
<<
endl
;
std
::
cout
<<
ita_convoi_syntax
()
<<
std
::
endl
;
return
255
;
}
// Input wav file
st
ring
sInputFilePath
=
string
(
argv
[
1
]
);
st
d
::
string
sInputFilePath
=
std
::
string
(
argv
[
1
]
);
VistaFileSystemFile
oInputFile
(
sInputFilePath
);
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
;
}
...
...
@@ -104,7 +103,7 @@ int main( int argc, char* argv[] )
}
catch
(
ITAException
&
e
)
{
cerr
<<
"Could not read input file: "
<<
e
<<
endl
;
std
::
cerr
<<
"Could not read input file: "
<<
e
<<
std
::
endl
;
return
255
;
}
...
...
@@ -112,11 +111,11 @@ int main( int argc, char* argv[] )
delete
pSample
;
// IR filter file
st
ring
sIRFilePath
=
string
(
argv
[
2
]
);
st
d
::
string
sIRFilePath
=
std
::
string
(
argv
[
2
]
);
VistaFileSystemFile
oIRFile
(
sIRFilePath
);
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
;
}
...
...
@@ -127,7 +126,7 @@ int main( int argc, char* argv[] )
}
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
;
}
double
dSamplingRateFilter
=
pIRAudioFile
->
getSamplerate
();
...
...
@@ -138,7 +137,7 @@ int main( int argc, char* argv[] )
// Require matching sampling rates
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
;
}
...
...
@@ -149,25 +148,25 @@ int main( int argc, char* argv[] )
}
// Start audio streaming
ITAPortaudioInterface
::
ITA_PA_ERRORCODE
iError
;
ITAPortaudioInterface
oITAPA
(
dSamplingRate
,
iBlockLength
);
int
iPortaudioDeviceID
=
oITAPA
.
GetDefaultOutputDevice
();
if
(
argc
>
4
)
iPortaudioDeviceID
=
int
(
*
argv
[
4
]
);
ITAPortaudioInterface
::
ITA_PA_ERRORCODE
iError
;
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
;
}
// Streaming chaing
ITAStreamConvolver
oConvolver
(
dSamplingRate
,
iBlockLength
,
iFilterLength
);
ITAFileDatasource
oSample
(
oInputFile
.
GetName
(),
iBlockLength
,
true
);
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
);
...
...
@@ -179,16 +178,32 @@ int main( int argc, char* argv[] )
oPatchBay
.
ConnectChannels
(
iInputID
,
n
,
iOutputID
,
0
);
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
;
ITASampleFrame
sfIR
(
oIRFile
.
GetName
()
);
ita_convio_exchange_channel
(
&
oConvolver
,
sfIR
,
iCurrentIRChannelIndex
);
// Start user interaction
cout
<<
ita_convoi_commands
()
<<
endl
;
std
::
cout
<<
ita_convoi_commands
()
<<
std
::
endl
;
int
iKey
;
while
(
(
iKey
=
_getch
()
)
!=
'q'
)
{
...
...
@@ -198,6 +213,10 @@ int main( int argc, char* argv[] )
{
// Toggle
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
;
}
case
(
'n'
)
:
...
...
@@ -210,61 +229,70 @@ int main( int argc, char* argv[] )
}
else
{
cout
<<
"Only one channel available, doing nothing."
<<
endl
;
std
::
cout
<<
"Only one channel available, doing nothing."
<<
std
::
endl
;
}
break
;
}
case
(
1
)
:
case
(
2
)
:
case
(
3
)
:
case
(
4
)
:
case
(
5
)
:
case
(
6
)
:
case
(
7
)
:
case
(
8
)
:
case
(
9
)
:
case
(
'd'
)
:
{
ita_convio_dirac_channel
(
&
oConvolver
);
break
;
}
case
(
48
+
1
)
:
case
(
48
+
2
)
:
case
(
48
+
3
)
:
case
(
48
+
4
)
:
case
(
48
+
5
)
:
case
(
48
+
6
)
:
case
(
48
+
7
)
:
case
(
48
+
8
)
:
case
(
48
+
9
)
:
{
// 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
);
}
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
;
}
default:
{
cerr
<<
"Unrecognized key command '"
<<
char
(
iKey
)
<<
"'"
<<
endl
;
cout
<<
ita_convoi_commands
()
<<
endl
;
std
::
cerr
<<
"Unrecognized key command '"
<<
char
(
iKey
)
<<
"'"
<<
std
::
endl
;
std
::
cout
<<
ita_convoi_commands
()
<<
std
::
endl
;
break
;
}
}
}
oITAPA
.
Stop
();
oITAPA
.
Close
();
oITAPA
.
Finalize
();
return
0
;
}
string
ita_convoi_syntax
()
st
d
::
st
ring
ita_convoi_syntax
()
{
stringstream
ss
;
ss
<<
"Syntax: ita_convoi SAMPLE_INPUT_WAV_MONO IR_FILTER_WAV_MULTICHANNEL [BLOCKLENGTH] [PORTAUDIO_DEVICE]"
<<
endl
;
st
d
::
st
ringstream
ss
;
ss
<<
"Syntax: ita_convoi SAMPLE_INPUT_WAV_MONO IR_FILTER_WAV_MULTICHANNEL [BLOCKLENGTH] [PORTAUDIO_DEVICE]"
<<
std
::
endl
;
return
ss
.
str
();
}
string
ita_convoi_commands
()
st
d
::
st
ring
ita_convoi_commands
()
{
stringstream
ss
;
ss
<<
"Commands:
\t
'q' quit"
<<
endl
;
ss
<<
"
\t\t\t
'm' toggle mute"
<<
endl
;
ss
<<
"
\t\t
'n' switch to next IR channel"
<<
endl
;
ss
<<
"
\t\t
1-9 exchange IR filter to given channel, if available"
<<
endl
;
std
::
stringstream
ss
;
ss
<<
"Commands:
\t
'q' quit"
<<
std
::
endl
;
ss
<<
"
\t\t
'm' toggle mute"
<<
std
::
endl
;
ss
<<
"
\t\t
'n' switch to next IR channel"
<<
std
::
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
();
}
...
...
@@ -275,4 +303,15 @@ void ita_convio_exchange_channel( ITAStreamConvolver* pSC, const ITASampleFrame&
pFilter
->
load
(
sfIR
[
iChannelIndex
].
GetData
(),
sfIR
.
GetLength
()
);
pSC
->
exchangeFilter
(
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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment