Aufgrund eines Versionsupdates wird GitLab am 17.12. zwischen 9:00 und 9:30 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to a version upgrade, GitLab won't be accessible at 17.12. between 9 and 9:30 a.m.

Commit b179addd authored by Jonas Stienen's avatar Jonas Stienen

Fixing some problems with ita_convoi and the ITAPA usage, streaming is now running

parent a38eb579
......@@ -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();
std::string ita_convoi_syntax();
std::string 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
string sInputFilePath = string( argv[ 1 ] );
std::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
string sIRFilePath = string( argv[ 2 ] );
std::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 = iKey - 1;
iCurrentIRChannelIndex = iRequestedChannelIndex;
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()
std::string ita_convoi_syntax()
{
stringstream ss;
ss << "Syntax: ita_convoi SAMPLE_INPUT_WAV_MONO IR_FILTER_WAV_MULTICHANNEL [BLOCKLENGTH] [PORTAUDIO_DEVICE]" << endl;
std::stringstream 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()
std::string 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\t1-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\t1-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;
}
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