Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

Implementing load/store for ITASampleFrame and adding test

parent b4a6022e
...@@ -78,6 +78,7 @@ void ITASampleFrame::Load( const std::string& sFilePath ) ...@@ -78,6 +78,7 @@ void ITASampleFrame::Load( const std::string& sFilePath )
void ITASampleFrame::Load( const std::string& sFilePath, double& dSampleRate ) void ITASampleFrame::Load( const std::string& sFilePath, double& dSampleRate )
{ {
#ifdef ITABASE_WITH_SNDFILE
ITAAudiofileReader* pReader( NULL ); ITAAudiofileReader* pReader( NULL );
try try
{ {
...@@ -105,15 +106,11 @@ void ITASampleFrame::Load( const std::string& sFilePath, double& dSampleRate ) ...@@ -105,15 +106,11 @@ void ITASampleFrame::Load( const std::string& sFilePath, double& dSampleRate )
} }
delete pReader; delete pReader;
#else
ITA_EXCEPT1( NOT_IMPLEMENTED, "ITASampleFrame::Store() function not available without libsndfile" );
#endif
} }
void ITASampleFrame::free()
{
m_vChannels.clear();
m_iChannels = 0;
m_iLength = 0;
};
void ITASampleFrame::Store( const std::string& sFilePath, double dSamplingRate ) const void ITASampleFrame::Store( const std::string& sFilePath, double dSamplingRate ) const
{ {
#ifdef ITABASE_WITH_SNDFILE #ifdef ITABASE_WITH_SNDFILE
...@@ -148,6 +145,13 @@ void ITASampleFrame::Store( const std::string& sFilePath, double dSamplingRate ) ...@@ -148,6 +145,13 @@ void ITASampleFrame::Store( const std::string& sFilePath, double dSamplingRate )
} }
void ITASampleFrame::free()
{
m_vChannels.clear();
m_iChannels = 0;
m_iLength = 0;
};
void ITASampleFrame::fill( float fValue ) void ITASampleFrame::fill( float fValue )
{ {
for (ch_it it=m_vChannels.begin(); it!=m_vChannels.end(); ++it) for (ch_it it=m_vChannels.begin(); it!=m_vChannels.end(); ++it)
......
...@@ -2,25 +2,34 @@ cmake_minimum_required( VERSION 2.8 ) ...@@ -2,25 +2,34 @@ cmake_minimum_required( VERSION 2.8 )
if( NOT ITABASE_COMMON_BUILD ) if( NOT ITABASE_COMMON_BUILD )
project( SampleBufferTest ) project( ITABaseTests )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" ) list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon ) include( VistaCommon )
endif() endif()
vista_use_package( ITABase REQUIRED ) vista_use_package( ITABase REQUIRED FIND_DEPENDENCIES )
if( WIN32 )
add_definitions( -DITA_BASE_DLL )
endif( WIN32 )
if( VFOUND_SNDFILE AND ITA_BASE_WITH_SNDFILE ) add_executable( SampleBufferTest SampleBufferTest.cpp )
add_executable( SampleBufferTest SampleBufferTest.cpp ) target_link_libraries( SampleBufferTest ${VISTA_USE_PACKAGE_LIBRARIES} )
target_link_libraries( SampleBufferTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( SampleBufferTest ) vista_configure_app( SampleBufferTest )
vista_install( SampleBufferTest ) vista_install( SampleBufferTest )
vista_create_default_info_file( SampleBufferTest ) vista_create_default_info_file( SampleBufferTest )
set_property( TARGET SampleBufferTest PROPERTY FOLDER "ITATests/ITABase" ) set_property( TARGET SampleBufferTest PROPERTY FOLDER "ITACoreLibs/Tests/ITABase" )
endif( VFOUND_SNDFILE AND ITA_BASE_WITH_SNDFILE )
if( ITA_BASE_WITH_SNDFILE )
add_executable( SampleFrameTest SampleFrameTest.cpp )
target_link_libraries( SampleFrameTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( SampleFrameTest )
vista_install( SampleFrameTest )
vista_create_default_info_file( SampleFrameTest )
set_property( TARGET SampleFrameTest PROPERTY FOLDER "ITACoreLibs/Tests/ITABase" )
endif( ITA_BASE_WITH_SNDFILE )
#include <ITAException.h>
#include <ITAStopWatch.h>
#include <ITASampleFrame.h>
#include <iostream>
#include <assert.h>
using namespace std;
int main( int argc, char** argv )
{
ITASampleFrame sf;
double dSampleRate;
sf.Load( "OldDiesel.wav", dSampleRate );
sf.div_scalar( 2 );
sf.Store( "OldDiesel_out.wav", dSampleRate ); // ITA_FLOAT
return 0;
}
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