Commit 9f4297e3 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Implementing load/store for ITASampleFrame and adding test

parent b4a6022e
......@@ -78,6 +78,7 @@ void ITASampleFrame::Load( const std::string& sFilePath )
void ITASampleFrame::Load( const std::string& sFilePath, double& dSampleRate )
{
#ifdef ITABASE_WITH_SNDFILE
ITAAudiofileReader* pReader( NULL );
try
{
......@@ -105,15 +106,11 @@ void ITASampleFrame::Load( const std::string& sFilePath, double& dSampleRate )
}
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
{
#ifdef ITABASE_WITH_SNDFILE
......@@ -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 )
{
for (ch_it it=m_vChannels.begin(); it!=m_vChannels.end(); ++it)
......
......@@ -2,25 +2,34 @@ cmake_minimum_required( VERSION 2.8 )
if( NOT ITABASE_COMMON_BUILD )
project( SampleBufferTest )
project( ITABaseTests )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
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 )
target_link_libraries( SampleBufferTest ${VISTA_USE_PACKAGE_LIBRARIES} )
add_executable( SampleBufferTest SampleBufferTest.cpp )
target_link_libraries( SampleBufferTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( SampleBufferTest )
vista_install( SampleBufferTest )
vista_create_default_info_file( SampleBufferTest )
vista_configure_app( SampleBufferTest )
vista_install( SampleBufferTest )
vista_create_default_info_file( SampleBufferTest )
set_property( TARGET SampleBufferTest PROPERTY FOLDER "ITATests/ITABase" )
endif( VFOUND_SNDFILE AND ITA_BASE_WITH_SNDFILE )
set_property( TARGET SampleBufferTest PROPERTY FOLDER "ITACoreLibs/Tests/ITABase" )
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