Starting restructure of recording behaviour to allow for a lazy setting of out...

Starting restructure of recording behaviour to allow for a lazy setting of out file path, e.g. to modify during runtime
parent a04d1327
......@@ -66,14 +66,6 @@ ProjectName = MyVirtualAcousticsProject
[Debug]
# Record device input and store to hard drive (will record every input channel)
InputRecordEnabled = false
InputRecordFileName = $(ProjectName)_in.wav
# Record device output and store to hard drive (will record every output channel)
OutputRecordEnabled = false
OutputRecordFilePath = $(ProjectName)_out.wav
# Set log level: 0 = quiet; 1 = errors; 2 = warnings (default); 3 = info; 4 = verbose; 5 = trace;
LogLevel = @ITA_VACORE_DEFAULT_DEBUG_LEVEL@
......@@ -109,6 +101,16 @@ BufferSize = AUTO
# Define number of output channels manually (e.g. for virtual device)
OutputChannels = AUTO
# Record device input and store to hard drive (will record every input channel)
RecordInputEnabled = false
RecordInputFileName = device_in.wav
RecordInputBaseFolder = recordings/$(ProjectName)/device
# Record device output and store to hard drive (will record every output channel)
RecordOutputEnabled = false
RecordOutputFileName = device_out.wav
RecordOutputBaseFolder = recordings/$(ProjectName)/device
[Calibration]
......@@ -233,7 +235,8 @@ NumChannels = 2
IRFilterLengthSamples = 88200
OutputMonitoring = true
RecordOutputEnabled = false
RecordOutputFilePath = $(ProjectName)_Renderer_MyGenericRenderer_Output.wav
RecordOutputFileName = renderer_out.wav
RecordOutputBaseFolder = recordings/$(ProjectName)/renderer/MyGenericRenderer
[Renderer:MyAirTrafficNoiseRenderer]
Class = BinauralAirTrafficNoise
......
......@@ -221,7 +221,7 @@ protected:
bool bValidTrajectoryPresent; //!< Estimation possible -> valid trajectory present
ITASampleFrame* psfOutput; //!< Accumulated listener output signals
ITAAudiofileWriter* pListenerOutputAudioFileWriter; //!< File writer used for dumping the listener signals
ITABufferedAudiofileWriter* pListenerOutputAudioFileWriter; //!< File writer used for dumping the listener signals
void PreRequest()
{
......@@ -261,7 +261,8 @@ protected:
props.eQuantization = ITAQuantization::ITA_FLOAT;
props.iChannels = 2;
props.iLength = 0;
pListenerOutputAudioFileWriter = ITABufferedAudiofileWriter::create( sOutput, props );
pListenerOutputAudioFileWriter = ITABufferedAudiofileWriter::create( props );
pListenerOutputAudioFileWriter->SetFilePath( sOutput );
}
void FinalizeDump()
......
......@@ -220,7 +220,7 @@ protected:
bool bValidTrajectoryPresent; //!< Estimation possible -> valid trajectory present
ITASampleFrame* psfOutput; //!< Accumulated listener output signals
ITAAudiofileWriter* pListenerOutputAudioFileWriter; //!< File writer used for dumping the listener signals
ITABufferedAudiofileWriter* pListenerOutputAudioFileWriter; //!< File writer used for dumping the listener signals
inline void PreRequest()
{
......@@ -261,7 +261,8 @@ protected:
props.eQuantization = ITAQuantization::ITA_FLOAT;
props.iChannels = 2;
props.iLength = 0;
pListenerOutputAudioFileWriter = ITABufferedAudiofileWriter::create( sOutput, props );
pListenerOutputAudioFileWriter = ITABufferedAudiofileWriter::create( props );
pListenerOutputAudioFileWriter->SetFilePath( sOutput );
};
inline void FinalizeDump()
......
......@@ -920,7 +920,8 @@ CVAPrototypeFreeFieldAudioRenderer::CVAPFFReceiver* CVAPrototypeFreeFieldAudioRe
props.eQuantization = ITAQuantization::ITA_FLOAT;
props.iChannels = m_iRecordSoundReceiversNumChannels;
props.iLength = 0;
pListener->pListenerOutputAudioFileWriter = ITABufferedAudiofileWriter::create( sFileBaseName, props );
pListener->pListenerOutputAudioFileWriter = ITABufferedAudiofileWriter::create( props );
pListener->pListenerOutputAudioFileWriter->SetFilePath( sFileBaseName );
VA_INFO( "PrototypeFreeFieldAudioRenderer", "Will record listener output signal and export to file '" << sFileBaseName << "' using " << m_iRecordSoundReceiversNumChannels << " channels after deletion" );
}
......
......@@ -212,7 +212,7 @@ protected:
bool bValidTrajectoryPresent; //!< Estimation possible -> valid trajectory present
ITASampleFrame* psfOutput; //!< Accumulated listener output signals
ITAAudiofileWriter* pListenerOutputAudioFileWriter; //!< File writer used for dumping the listener signals
ITABufferedAudiofileWriter* pListenerOutputAudioFileWriter; //!< File writer used for dumping the listener signals
void PreRequest()
{
......
......@@ -121,7 +121,7 @@ public:
CVAStruct CallObject( const CVAStruct& oArgs );
void onStartDumpListeners(const std::string& sFilenameFormat);
void onStartDumpListeners( const std::string& sFilenameFormat );
void onStopDumpListeners();
protected:
......@@ -216,7 +216,7 @@ protected:
VAVec3 vPredUp; //!< Estimated Orientation (Up-Vektor)
ITASampleFrame* psfOutput; //!< Accumulated listener output signals
ITAAudiofileWriter* pListenerOutputAudioFileWriter; //!< File writer used for dumping the listener signals
ITABufferedAudiofileWriter* pListenerOutputAudioFileWriter; //!< File writer used for dumping the listener signals
void PreRequest()
{
......@@ -243,10 +243,10 @@ protected:
FinalizeDump();
};
void InitDump(const std::string& sFilename) {
std::string sOutput(sFilename);
sOutput = SubstituteMacro(sOutput, "ListenerName", pData->sName);
sOutput = SubstituteMacro(sOutput, "ListenerID", IntToString(pData->iID));
void InitDump( const std::string& sFilename ) {
std::string sOutput( sFilename );
sOutput = SubstituteMacro( sOutput, "ListenerName", pData->sName );
sOutput = SubstituteMacro( sOutput, "ListenerID", IntToString( pData->iID ) );
ITAAudiofileProperties props;
props.dSampleRate = m_pCore->GetCoreConfig()->oAudioDriverConfig.dSampleRate;
......@@ -254,7 +254,8 @@ protected:
props.eQuantization = ITAQuantization::ITA_FLOAT;
props.iChannels = 2;
props.iLength = 0;
pListenerOutputAudioFileWriter = ITABufferedAudiofileWriter::create(sOutput, props);
pListenerOutputAudioFileWriter = ITABufferedAudiofileWriter::create( props );
pListenerOutputAudioFileWriter->SetFilePath( sOutput );
}
void FinalizeDump() {
......
......@@ -116,13 +116,17 @@ void CVACoreConfig::Init( const CVAStruct& oData )
oHardwareSetup.Init( oData );
conf.OptBool( "Debug/InputRecordEnabled", bRecordDeviceInputEnabled, false );
conf.OptString( "Debug/InputRecordFilePath", sRecordDeviceInputFilePath );
sRecordDeviceInputFilePath = mMacros.SubstituteMacros( sRecordDeviceInputFilePath );
conf.OptBool( "Debug/OutputRecordEnabled", bRecordDeviceOutputEnabled, false );
conf.OptString( "Debug/OutputRecordFilePath", sRecordFinalOutputFilePath );
sRecordFinalOutputFilePath = mMacros.SubstituteMacros( sRecordFinalOutputFilePath );
conf.OptBool( "Audio device/RecordInputEnabled", bRecordDeviceInputEnabled, false );
conf.OptString( "Audio device/RecordInputFileName", sRecordDeviceInputFileName, "device_in.wav" );
sRecordDeviceInputFileName = mMacros.SubstituteMacros( sRecordDeviceInputFileName );
conf.OptString( "Audio device/RecordInputBaseFolder", sRecordDeviceInputBaseFolder, "recordings/device" );
sRecordDeviceInputBaseFolder = mMacros.SubstituteMacros( sRecordDeviceInputBaseFolder );
conf.OptBool( "Audio device/RecordOutputEnabled", bRecordDeviceOutputEnabled, false );
conf.OptString( "Audio device/RecordOutputFileName", sRecordDeviceOutputFileName, "device_out.wav" );
sRecordDeviceOutputFileName = mMacros.SubstituteMacros( sRecordDeviceOutputFileName );
conf.OptString( "Audio device/RecordOutputBaseFolder", sRecordDeviceOutputBaseFolder, "recordings/device" );
sRecordDeviceOutputBaseFolder = mMacros.SubstituteMacros( sRecordDeviceOutputBaseFolder );
conf.OptNumber( "HomogeneousMedium/DefaultRelativeHumidity", oInitialHomogeneousMedium.dRelativeHumidityPercent, g_dDefaultRelativeHumidity );
conf.OptNumber( "HomogeneousMedium/DefaultSoundSpeed", oInitialHomogeneousMedium.dSoundSpeed, g_dDefaultSpeedOfSound );
......@@ -135,7 +139,7 @@ void CVACoreConfig::Init( const CVAStruct& oData )
if( sDefaultAmplitudeCalibrationMode == "124dB" )
dDefaultAmplitudeCalibration = g_dSoundPower_128dB_SPL_1m;
conf.OptNumber( "Calibration/DefaultMinimumDistance", dDefaultMinimumDistance, 0.25f ); // translates +12 dB SPL
conf.OptNumber( "Calibration/DefaultMinimumDistance", dDefaultMinimumDistance, 0.25f ); // translates to max +12 dB SPL
conf.OptNumber( "Calibration/DefaultDistance", dDefaultDistance, 2.0f ); // translates to -6 dB SPL
......
......@@ -39,10 +39,12 @@ public:
std::vector< std::string > vsSearchPaths; //!< Search paths (existing directories only)
bool bRecordDeviceInputEnabled; //!< Switch to store entire device input stream record to hard drive
std::string sRecordDeviceInputFilePath; //!< File path where to store the input stream record to hard drive
std::string sRecordDeviceInputFileName; //!< File path where to store the input stream record to hard drive
std::string sRecordDeviceInputBaseFolder; //!< File base path of stream record
bool bRecordDeviceOutputEnabled; //!< Switch to store entire device output stream record to hard drive
std::string sRecordFinalOutputFilePath; //!< File path where to store the output stream record to hard drive
std::string sRecordDeviceOutputFileName; //!< File path where to store the output stream record to hard drive
std::string sRecordDeviceOutputBaseFolder; //!< File base path of stream record
int iTriggerUpdateMilliseconds;
......
......@@ -492,7 +492,26 @@ void CVACoreImpl::Initialize() {
if( m_oCoreConfig.bRecordDeviceInputEnabled )
{
m_pStreamProbeDeviceInput = new ITAStreamProbe( pInputTail, m_oCoreConfig.sRecordDeviceInputFilePath );
VistaFileSystemFile oRecordFile( m_oCoreConfig.sRecordDeviceInputFileName );
VistaFileSystemDirectory oRecordBaseFolder( m_oCoreConfig.sRecordDeviceInputBaseFolder );
if( !oRecordBaseFolder.Exists() )
{
if( oRecordBaseFolder.CreateWithParentDirectories() )
{
VA_INFO( "Core", "Created device input record base folder " << oRecordBaseFolder.GetName() << " with parent directories" );
}
else
{
VA_EXCEPT2( INVALID_PARAMETER, "Could not create non-existent device input record base folder '" + oRecordBaseFolder.GetName() + "'" );
}
}
std::string sFilePath = oRecordBaseFolder.GetName() + "/" + oRecordFile.GetLocalName();
if( VistaFileSystemFile( sFilePath ).Exists() )
VA_INFO( "Core", "Device input record file '" << sFilePath << "' exists, will overwrite" );
m_pStreamProbeDeviceInput = new ITAStreamProbe( pInputTail, sFilePath );
pInputTail = m_pStreamProbeDeviceInput;
}
}
......@@ -560,7 +579,26 @@ void CVACoreImpl::Initialize() {
ITADatasource* pOutputTail = m_pOutputStreamDetector;
if( m_oCoreConfig.bRecordDeviceOutputEnabled )
{
m_pStreamProbeFinal = new ITAStreamProbe( pOutputTail, m_oCoreConfig.sRecordFinalOutputFilePath );
VistaFileSystemFile oRecordFile( m_oCoreConfig.sRecordDeviceOutputFileName );
VistaFileSystemDirectory oRecordBaseFolder( m_oCoreConfig.sRecordDeviceOutputBaseFolder );
if( !oRecordBaseFolder.Exists() )
{
if( oRecordBaseFolder.CreateWithParentDirectories() )
{
VA_INFO( "Core", "Created device output record base folder " << oRecordBaseFolder.GetName() << " with parent directories" );
}
else
{
VA_EXCEPT2( INVALID_PARAMETER, "Could not create non-existent device output record base folder '" + oRecordBaseFolder.GetName() + "'" );
}
}
std::string sFilePath = oRecordBaseFolder.GetName() + "/" + oRecordFile.GetLocalName();
if( VistaFileSystemFile( sFilePath ).Exists() )
VA_INFO( "Core", "Device output record file '" << sFilePath << "' exists, will overwrite" );
m_pStreamProbeFinal = new ITAStreamProbe( pOutputTail, sFilePath );
pOutputTail = m_pStreamProbeFinal;
}
......@@ -4504,7 +4542,6 @@ void CVACoreImpl::InitializeAudioRenderers()
conf.ReqString( "RecordOutputBaseFolder", sBaseFolderRAW );
std::string sBaseFolder = m_oCoreConfig.mMacros.SubstituteMacros( sBaseFolderRAW );
oRecordOutputBaseFolder.SetName( sBaseFolder );
}
if( !oRecordOutputBaseFolder.Exists() )
......@@ -4517,16 +4554,10 @@ void CVACoreImpl::InitializeAudioRenderers()
{
VA_EXCEPT2( INVALID_PARAMETER, "Could not create non-existent renderer record base folder '" + oRecordOutputBaseFolder.GetName() + "'" );
}
}
if( oRecordOutputFile.Exists() )
{
VA_INFO( "Core", "Rendering record file '" << oRecordOutputFile.GetName() << "' exists, will overwrite" );
}
oParams.sRecordOutputFileName = oRecordOutputFile.GetLocalName();
oParams.sRecordOutputBaseFolder = oRecordOutputFile.GetParentDirectory();
oParams.sRecordOutputBaseFolder = oRecordOutputBaseFolder.GetName();
}
......@@ -4547,6 +4578,10 @@ void CVACoreImpl::InitializeAudioRenderers()
if( oParams.bRecordOutputEnabled )
{
std::string sFilePath = oParams.sRecordOutputBaseFolder + "/" + oParams.sRecordOutputFileName;
if( VistaFileSystemFile( sFilePath ).Exists() )
VA_INFO( "Core", "Rendering record file '" << sFilePath << "' exists, will overwrite" );
VistaFileSystemFile oFile( sFilePath );
oRendererDesc.pOutputRecorder = new ITAStreamProbe( pRendererOutputTail, oFile.GetName() );
pRendererOutputTail = oRendererDesc.pOutputRecorder;
......@@ -4675,7 +4710,6 @@ void CVACoreImpl::InitializeReproductionModules()
conf.ReqString( "RecordInputBaseFolder", sBaseFolderRAW );
std::string sBaseFolder = m_oCoreConfig.mMacros.SubstituteMacros( sBaseFolderRAW );
oRecordInputFolder.SetName( sBaseFolder );
}
if( !oRecordInputFolder.Exists() )
......@@ -4688,16 +4722,10 @@ void CVACoreImpl::InitializeReproductionModules()
{
VA_EXCEPT2( INVALID_PARAMETER, "Could not create non-existent reproduction input record base folder '" + oRecordInputFolder.GetName() + "'" );
}
}
if( oRecordInputFile.Exists() )
{
VA_INFO( "Core", "Reproduction input record file '" << oRecordInputFile.GetName() << "' exists, will overwrite" );
}
oParams.sRecordInputFileName = oRecordInputFile.GetLocalName();
oParams.sRecordInputBaseFolder = oRecordInputFile.GetParentDirectory();
oParams.sRecordInputBaseFolder = oRecordInputFolder.GetName();
}
......@@ -4707,7 +4735,7 @@ void CVACoreImpl::InitializeReproductionModules()
if( oParams.bRecordOutputEnabled )
{
VistaFileSystemFile oRecordOutputFile( "reproduction.wav" );
VistaFileSystemDirectory oRecordOutputFolder( "./" );
VistaFileSystemDirectory oRecordOutputBaseFolder( "./" );
std::string sFilePathRAWDeprecated;
conf.OptString( "RecordOutputFilePath", sFilePathRAWDeprecated );
......@@ -4721,7 +4749,7 @@ void CVACoreImpl::InitializeReproductionModules()
std::string sRecordOutputFilePath = m_oCoreConfig.mMacros.SubstituteMacros( sFilePathRAWDeprecated );
oRecordOutputFile.SetName( sRecordOutputFilePath );
oRecordOutputFolder.SetName( oRecordOutputFile.GetParentDirectory() );
oRecordOutputBaseFolder.SetName( oRecordOutputFile.GetParentDirectory() );
}
else
{
......@@ -4733,30 +4761,23 @@ void CVACoreImpl::InitializeReproductionModules()
std::string sBaseFolderRAW;
conf.ReqString( "RecordOutputBaseFolder", sBaseFolderRAW );
std::string sBaseFolder = m_oCoreConfig.mMacros.SubstituteMacros( sBaseFolderRAW );
oRecordOutputFolder.SetName( sBaseFolder );
oRecordOutputBaseFolder.SetName( sBaseFolder );
}
if( !oRecordOutputFolder.Exists() )
if( !oRecordOutputBaseFolder.Exists() )
{
if( oRecordOutputFolder.CreateWithParentDirectories() )
if( oRecordOutputBaseFolder.CreateWithParentDirectories() )
{
VA_INFO( "Core", "Created reproduction output record base folder " << oRecordOutputFolder.GetName() << " with parent directories" );
VA_INFO( "Core", "Created reproduction output record base folder " << oRecordOutputBaseFolder.GetName() << " with parent directories" );
}
else
{
VA_EXCEPT2( INVALID_PARAMETER, "Could not create non-existent reproduction output record base folder '" + oRecordOutputFolder.GetName() + "'" );
}
VA_EXCEPT2( INVALID_PARAMETER, "Could not create non-existent reproduction output record base folder '" + oRecordOutputBaseFolder.GetName() + "'" );
}
if( oRecordOutputFile.Exists() )
{
VA_INFO( "Core", "Reproduction output record file '" << oRecordOutputFile.GetName() << "' exists, will overwrite" );
}
oParams.sRecordOutputFileName = oRecordOutputFile.GetLocalName();
oParams.sRecordOutputBaseFolder = oRecordOutputFile.GetParentDirectory();
oParams.sRecordOutputBaseFolder = oRecordOutputBaseFolder.GetName();
}
......@@ -4803,6 +4824,10 @@ void CVACoreImpl::InitializeReproductionModules()
{
std::string sFilePath = oParams.sRecordInputBaseFolder + "/" + oParams.sRecordInputFileName;
VistaFileSystemFile oFile( sFilePath );
if( oFile.Exists() )
VA_INFO( "Core", "Reproduction input record file '" << oFile.GetName() << "' exists, will overwrite" );
oDesc.pInputRecorder = new ITAStreamProbe( pInputTail, oFile.GetName() );
pInputTail = oDesc.pInputRecorder;
VA_TRACE( "Core", "Reproduction will record input to file '" << oFile.GetName() << "'" );
......@@ -4822,6 +4847,10 @@ void CVACoreImpl::InitializeReproductionModules()
{
std::string sFilePath = oParams.sRecordOutputBaseFolder + "/" + oParams.sRecordOutputFileName;
VistaFileSystemFile oFile( sFilePath );
if( oFile.Exists() )
VA_INFO( "Core", "Reproduction output record file '" << oFile.GetName() << "' exists, will overwrite" );
oDesc.pOutputRecorder = new ITAStreamProbe( pOutputTail, oFile.GetName() );
pOutputTail = oDesc.pOutputRecorder;
VA_TRACE( "Core", "Reproduction will record output to file '" << oFile.GetName() << "'" );
......@@ -5188,7 +5217,7 @@ void CVACoreImpl::SendRenderingModuleOutputDetectorsUpdateEvents()
m_pEventManager->BroadcastEvent( ev );
}
}
}
void CVACoreImpl::SendReproductionModuleOIDetectorsUpdateEvents()
{
......@@ -5345,6 +5374,11 @@ CVAStruct CVACoreImpl::CallObject( const CVAStruct& oArgs )
}
}
if( oArgs.HasKey( "Audio device/RecordInputFileName" ) )
{
VA_EXCEPT_NOT_IMPLEMENTED;
}
VA_VERBOSE( "Core", "Core module will transmit answer now" );
return oReturn;
}
......
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