Commit 29a804aa authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Fixing problems with merging in CMake conf of tests folger

parents 7149838c 779c0266
......@@ -111,3 +111,7 @@ set_property( TARGET ITASIMOVariableDelayLineBaseTest PROPERTY FOLDER "ITACoreLi
if( ITA_DSP_WITH_INTEL_MKL_SUPPORT )
add_subdirectory( "mkl" )
endif( )
if( DSPFILTERS_FOUND OR TRUE )
add_subdirectory( "dspfilters" )
endif( )
cmake_minimum_required( VERSION 2.8 )
project( ITADSPTest )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
vista_use_package( ITADSP REQUIRED FIND_DEPENDENCIES )
vista_use_package( DspFilters REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
if( ITA_CORE_LIBS_BUILD_STATIC )
add_definitions( -DITA_BASE_STATIC -DITA_DSP_STATIC -DITA_DATA_SOURCES_STATIC -DITA_CONVOLUTION_STATIC )
endif( )
if( ITA_VISTA_BUILD_STATIC )
add_definitions( -DVISTATOOLS_STATIC -DVISTABASE_STATIC -DVISTAMATH_STATIC -DVISTAASPECTS_STATIC -DVISTAINTERPROCCOMM_STATIC )
endif( )
add_executable( NativeDspFiltersTest NativeDspFiltersTest.cpp )
target_link_libraries( NativeDspFiltersTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( NativeDspFiltersTest )
vista_install( NativeDspFiltersTest )
vista_create_default_info_file( NativeDspFiltersTest )
set_property( TARGET NativeDspFiltersTest PROPERTY FOLDER "ITACoreLibs/Tests/ITADSP/dspfilters" )
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2017
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
* Testing DspFilters library.
*
*/
#include <DspFilters/Butterworth.h>
#include <ITAConstants.h>
#include <ITAFiniteImpulseResponse.h>
#include <cassert>
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
using namespace Dsp;
using namespace ITABase;
using namespace ITAConstants;
float fSampleRate = 44100.0f;
const int iOrder = 10;
const int iChannels = 1;
int iFilterLength = ( int ) pow( 2, 12 );
void manual_low_pass_1kHz();
void manual_high_pass_1kHz();
void manual_band_pass_1kHz();
void tri_band();
void downcast_test();
void octave_bands();
int main( int, char** )
{
manual_low_pass_1kHz();
manual_high_pass_1kHz();
manual_band_pass_1kHz();
tri_band();
downcast_test();
octave_bands();
return 255;
}
void manual_low_pass_1kHz()
{
SimpleFilter< Butterworth::LowPass< iOrder >, iChannels > oBandPassFilter;
float fCuttoffFrequency = 1000.0f;
oBandPassFilter.setup( iOrder, fSampleRate, fCuttoffFrequency );
CFiniteImpulseResponse oDirac( iFilterLength, fSampleRate );
oDirac.SetDirac();
float* pf = oDirac.GetData();
oBandPassFilter.process( iFilterLength, &pf );
oDirac.Store( "NativeDspFiltersTest_IR_LP_1kHz.wav" );
}
void manual_high_pass_1kHz()
{
SimpleFilter< Butterworth::HighPass< iOrder >, iChannels > oBandPassFilter;
float fCuttoffFrequency = 1000.0f;
oBandPassFilter.setup( iOrder, fSampleRate, fCuttoffFrequency );
CFiniteImpulseResponse oDirac( iFilterLength, fSampleRate );
oDirac.SetDirac();
float* pf = oDirac.GetData();
oBandPassFilter.process( iFilterLength, &pf );
oDirac.Store( "NativeDspFiltersTest_IR_HP_1kHz.wav" );
}
void manual_band_pass_1kHz()
{
SimpleFilter< Butterworth::BandPass< iOrder >, iChannels > oBandPassFilter;
float fCenterFrequency = 1000.0f;
float fBandWidth = fCenterFrequency * ( float ) ( sqrt( 2 ) - 1 / sqrt( 2 ) );
oBandPassFilter.setup( iOrder, fSampleRate, fCenterFrequency, fBandWidth );
CFiniteImpulseResponse oDirac( iFilterLength, fSampleRate );
oDirac.SetDirac();
float* pf = oDirac.GetData();
oBandPassFilter.process( iFilterLength, &pf );
oDirac.Store( "NativeDspFiltersTest_IR_BP_1kHz.wav" );
}
void tri_band()
{
float fLowerFrequencyCuttoff = 330.0f;
float fHigherFrequencyCuttoff = 3900.0f;
float fMidCenterFrequency = 2300.0f;
float fMidBandWidth = 4000;
SimpleFilter< Butterworth::LowPass< iOrder >, iChannels > oLPF;
oLPF.setup( iOrder, fSampleRate, fLowerFrequencyCuttoff );
SimpleFilter< Butterworth::HighPass< iOrder >, iChannels > oHPF;
oHPF.setup( iOrder, fSampleRate, fHigherFrequencyCuttoff );
SimpleFilter< Butterworth::BandPass< iOrder >, iChannels > oBPF;
assert( fMidBandWidth > 0 );
oBPF.setup( iOrder, fSampleRate, fMidCenterFrequency, fMidBandWidth );
CFiniteImpulseResponse oIR( iFilterLength, fSampleRate );
oIR.SetDirac();
float* pf = oIR.GetData();
oLPF.process( iFilterLength, &pf );
oIR.Store( "NativeDspFiltersTest_IR_Triband_Low.wav" );
oIR.SetDirac();
pf = oIR.GetData();
oBPF.process( iFilterLength, &pf );
oIR.Store( "NativeDspFiltersTest_IR_Triband_Mid.wav" );
oIR.SetDirac();
pf = oIR.GetData();
oHPF.process( iFilterLength, &pf );
oIR.Store( "NativeDspFiltersTest_IR_Triband_High.wav" );
}
void downcast_test()
{
SimpleFilter< Butterworth::BandPass< iOrder >, iChannels > oBandPassFilter;
SimpleFilter< Butterworth::BandPass< iOrder >, iChannels >* pBPF = &oBandPassFilter;
float fV = 1.0f;
float* pf = &fV;
pBPF->process( 1, &pf );
}
void octave_bands()
{
CFiniteImpulseResponse oIR( iFilterLength, fSampleRate );
float fLowPassFrequencyCuttoff = OCTAVE_CENTER_FREQUENCIES_ISO_F[0] * sqrt( 2.0f );
SimpleFilter< Butterworth::LowPass< iOrder >, iChannels > oLPF;
oLPF.setup( iOrder, fSampleRate, fLowPassFrequencyCuttoff );
oIR.SetDirac();
float* pf = oIR.GetData();
oLPF.process( iFilterLength, &pf );
oIR.Store( "NativeDspFiltersTest_IR_OctaveBands_LP.wav" );
for( size_t i = 1; i < OCTAVE_CENTER_FREQUENCIES_ISO_F.size() - 1; i++ )
{
float fMidCenterFrequency = OCTAVE_CENTER_FREQUENCIES_ISO_F[i];
float fMidBandWidth = ( OCTAVE_CENTER_FREQUENCIES_ISO_F[ i + 1 ] - OCTAVE_CENTER_FREQUENCIES_ISO_F[ i - 1 ] ) / 2.15f;
SimpleFilter< Butterworth::BandPass< iOrder >, iChannels > oBPF;
assert( fMidBandWidth > 0 );
oBPF.setup( iOrder, fSampleRate, fMidCenterFrequency, fMidBandWidth );
oIR.SetDirac();
pf = oIR.GetData();
oBPF.process( iFilterLength, &pf );
oIR.Store( "NativeDspFiltersTest_IR_OctaveBands_BP" + std::to_string( ( long ) ( i ) ) + ".wav" );
}
float fHighPassFrequencyCuttoff = OCTAVE_CENTER_FREQUENCIES_ISO_F[ OCTAVE_CENTER_FREQUENCIES_ISO_F.size() - 1 ] / sqrt( 2.0f );
SimpleFilter< Butterworth::HighPass< iOrder >, iChannels > oHPF;
oHPF.setup( iOrder, fSampleRate, fHighPassFrequencyCuttoff );
oIR.SetDirac();
pf = oIR.GetData();
oHPF.process( iFilterLength, &pf );
oIR.Store( "NativeDspFiltersTest_IR_OctaveBands_HP.wav" );
}
%% Manual filters at 1kHz
IR_LP_1kHz = ita_read( 'NativeDspFiltersTest_IR_LP_1kHz.wav' );
IR_HP_1kHz = ita_read( 'NativeDspFiltersTest_IR_HP_1kHz.wav' );
IR_BP_1kHz = ita_read( 'NativeDspFiltersTest_IR_BP_1kHz.wav' );
IR_manual_filters_1kHz = ita_merge( IR_LP_1kHz, IR_HP_1kHz, IR_BP_1kHz );
IR_manual_filters_1kHz.channelNames = { 'Low pass 1kHz', 'High pass 1kHz', 'Band pass 1kHz and bandwidth 707Hz' };
%IR_manual_filters_1kHz.pf
%% Tribands
IR_Triband_Low = ita_read( 'NativeDspFiltersTest_IR_Triband_Low.wav' );
IR_Triband_Mid = ita_read( 'NativeDspFiltersTest_IR_Triband_Mid.wav' );
IR_Triband_High = ita_read( 'NativeDspFiltersTest_IR_Triband_High.wav' );
IR_Triband = ita_merge( IR_Triband_Low, IR_Triband_Mid, IR_Triband_High );
IR_Triband = ita_merge( IR_Triband, IR_Triband.sum );
IR_Triband.channelNames = { 'Low pass 250kHz cutoff', ...
'Band pass 1kHz bandwidth 3.75kHz', ...
'High pass 4kHz cutoff', ...
'Triband identity (sum)' };
%IR_Triband.pf
%% Octaves
IR_Octaves_LP = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_LP.wav' );
IR_Octaves_BP1 = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_BP1.wav' );
IR_Octaves_BP2 = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_BP2.wav' );
IR_Octaves_BP3 = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_BP3.wav' );
IR_Octaves_BP4 = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_BP4.wav' );
IR_Octaves_BP5 = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_BP5.wav' );
IR_Octaves_BP6 = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_BP6.wav' );
IR_Octaves_BP7 = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_BP7.wav' );
IR_Octaves_BP8 = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_BP8.wav' );
IR_Octaves_HP = ita_read( 'NativeDspFiltersTest_IR_OctaveBands_HP.wav' );
IR_Octaves = ita_merge( IR_Octaves_LP, IR_Octaves_BP1, IR_Octaves_BP2,IR_Octaves_BP3, IR_Octaves_BP4, IR_Octaves_BP5, IR_Octaves_BP6, IR_Octaves_BP7, IR_Octaves_BP8, IR_Octaves_HP );
IR_Octaves = ita_merge( IR_Octaves, IR_Octaves.sum );
IR_Octaves.pf
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