Commits (30)
*.ini
*.json
HTML
*.bat
*.mat
......
......@@ -11,6 +11,7 @@ vista_use_package( ITAFFT REQUIRED FIND_DEPENDENCIES )
vista_use_package( ITAConvolution REQUIRED FIND_DEPENDENCIES ) # required for FIR filtering (uses block convolver)
vista_use_package( TBB REQUIRED FIND_DEPENDENCIES )
vista_use_package( SPLINE REQUIRED FIND_DEPENDENCIES )
vista_use_package( DspFilters REQUIRED FIND_DEPENDENCIES )
vista_find_package( libjson OPTIONAL QUIET )
vista_find_package( MKL OPTIONAL QUIET )
......@@ -28,6 +29,8 @@ include_directories( "include" )
# sources
set( ITADSPHeader
"include/ITADSP/PD/JetEngine.h"
"include/ITADSP/ThirdOctaveFilterbank/IIRBurg.h"
"include/ITADSPDefinitions.h"
"include/ITASIMOVariableDelayLine.h"
"include/ITASIMOVariableDelayLineBase.h"
......@@ -42,6 +45,8 @@ set( ITADSPHeader
"include/ITAThirdOctaveFIRFilterGenerator.h"
)
set( ITADSPSources
"src/ITADSP/PD/JetEngine.cpp"
"src/ITADSP/ThirdOctaveFilterbank/IIRBurg.cpp"
"src/ITASIMOVariableDelayLine.cpp"
"src/ITASIMOVariableDelayLineBase.cpp"
"src/ITABiquad.cpp"
......@@ -50,6 +55,7 @@ set( ITADSPSources
"src/ITAIIRFilterEngine.cpp"
"src/ITAThirdOctaveFilterbank.cpp"
"src/ITAThirdOctaveFilterbankIIR.cpp"
"src/ITAThirdOctaveFilterbankFIR.cpp"
"src/ITAThirdOctaveFIRFilterGenerator.cpp"
"src/ITAThirdOctaveFilterbankIIRCoefficients.h"
"src/ITAVariableDelayLine.cpp"
......
Copyright 2015-2017 Institute of Technical Acoustics, RWTH Aachen University
Copyright 2015-2020 Institute of Technical Acoustics, RWTH Aachen University
Licensed under the Apache License, Version 2.0 (the "License");
you may not use files of this project except in compliance with the License.
......
......@@ -6,7 +6,7 @@ It is a component of [ITACoreLibs](https://git.rwth-aachen.de/ita/ITACoreLibs),
### License
Copyright 2015-2017 Institute of Technical Acoustics, RWTH Aachen University
Copyright 2015-2020 Institute of Technical Acoustics, RWTH Aachen University
Licensed under the Apache License, Version 2.0 (the "License");
you may not use files of this project except in compliance with the License.
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_DSP_PD_JET_ENGINE
#define IW_ITA_DSP_PD_JET_ENGINE
#include <ITADSPDefinitions.h>
#include <ITAThirdOctaveFilterbank.h>
#include <VistaTools/VistaRandomNumberGenerator.h>
#include <DspFilters/Butterworth.h>
#include <tbb/concurrent_queue.h>
#include <atomic>
#include <algorithm>
#include <atomic>
#include <vector>
class CITAIIRFilterEngine;
class CITAThirdOctaveFIRFilterGenerator;
namespace ITADSP
{
namespace PD
{
//! Pure data patch implementation of a jet engine
/**
* Manual implementation of the "jet engine" pure data patch (combining "forced flame" and "turbine") from Andy Farnell's Designing Sound
*/
class ITA_DSP_API CJetEngine
{
public:
CJetEngine( double dSampleRate = 44100.0f, float fRPMInit = 1000.0f, bool bColdStart = true );
virtual ~CJetEngine();
virtual void SetRPM( float fNewRPM );
virtual void Process( float* pfOutputBuffer, int iNumSamples );
protected:
// We'll protect data exchange between user and audio thread
// with atomics, but a request, swap & acknowledge approach with
// mutex / locking would be more elegant
struct CAudioContext
{
std::atomic< float > vfRPM;
std::vector< float > vfTurbineModeFrequencies;
std::vector< float > vfTurbineModePhaseShift;
} oCtxAudio;
float GetRPMNormalized( float fRPM ) const;
private:
VistaRandomNumberGenerator oRNG;
Dsp::SimpleFilter< Dsp::Butterworth::BandPass< 1 >, 1 > m_oForcedFlameBP1, m_oForcedFlameBP2, m_oForcedFlameBP3;
Dsp::SimpleFilter< Dsp::Butterworth::HighPass< 1 >, 1 > m_oForcedFlameHP1;
Dsp::SimpleFilter< Dsp::Butterworth::LowPass< 1 >, 1 > m_oJetEngineLP1, m_oJetEngineLP2;
std::vector< float > m_vfTurbineBaseModeFrequencies, m_vfTurbineBaseModeAmplitudes, m_vfRPMRange;
float m_fTempSample;
double m_dSampleRate;
};
}
}
#endif // IW_ITA_DSP_PD_JET_ENGINE
/*
* ----------------------------------------------------------------
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
* // / //__ ___/ // _ |
* // / // / // /_| |
* // / // / // ___ |
* //__/ //__/ //__/ |__|
*
* ----------------------------------------------------------------
*
*/
#ifndef IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_BURG
#define IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_BURG
#include <ITADSPDefinitions.h>
#include <ITAThirdOctaveFilterbank.h>
#include <vector>
#include <tbb/concurrent_queue.h>
class CITAIIRFilterEngine;
class CITAThirdOctaveFIRFilterGenerator;
namespace ITADSP
{
namespace ThirdOctaveFilterbank
{
//! Third-octave filterbank realisation using IIR filter structur und Burg coefficient design
/**
* Diese Klasse realisiert eine Terzfilterbank (#CVAThirdOctaveFilterbank) mit der Methode der direct form II
* für Verstärkungsfaktoren eines Terzbank-Betragsspektrums (#CVAThirdOctaveMagnitudes).
*
*/
class ITA_DSP_API CIIRBurg : public CITAThirdOctaveFilterbank
{
public:
//! Konstruktor mit Samplerate und Blocklänge
/**
* \param dSamplerate Samplingrate
* \param iBlocklength Blocklänge
*/
CIIRBurg( const double dSampleRate, const int iBlockLength, const int iFilterOrder = 4 );
//! Destruktor
virtual ~CIIRBurg();
//! Verstärkungen (Gains) setzen
/**
* \param oGains Verstärkungsfaktoren
* \param bSmoothChangeover Wenn true, dann überblenden (default), sonst sofort internen Gain umschalten
*/
void SetMagnitudes( const ITABase::CThirdOctaveGainMagnitudeSpectrum& oGains, const bool );
//! Alle internen Zustände zurücksetzen (Akkumulatoren der Biquads)
void Clear();
//! Verarbeite Samples (Filtern)
/**
* \param pfInputSamples Eingabesamples (Anzahl = Blocklänge)
* \param pfOutputSamples Ausgabesamples (Anzahl = Blocklänge)
*/
void Process( const float* pfInputSamples, float* pfOutputSamples );
private:
int m_iBlockLength; //!< Blocklänge
CITAIIRFilterEngine* m_pFilterEngine;
CITAThirdOctaveFIRFilterGenerator* m_pFilterGenerator;
};
}
}
#endif // IW_ITA_DSP_THIRD_OCTAVE_FILTERBANK_IIR_BURG
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......@@ -44,10 +44,12 @@ namespace ITADSP
inline CFilterCoefficients( unsigned int uiOrder = 0, bool bARMAInit = false )
: iDesignAlgorithm( ITADSP::UNSPECIFIED )
, bIsARMA( bARMAInit )
{
Initialise( uiOrder, bARMAInit );
};
//! Initialize (sets coeffs to zero)
inline void Initialise( unsigned int uiOrder_, bool bARMAInit_ )
{
bIsARMA = bARMAInit_;
......@@ -58,8 +60,11 @@ namespace ITADSP
vfNumerator.resize( 1 );
vfDenominator.resize( uiOrder + 1 );
SetZero();
};
//! Initialize with given order (sets coeffs to zero)
inline void InitialiseOrder( unsigned int uiOrder_ )
{
uiOrder = uiOrder_;
......@@ -69,11 +74,13 @@ namespace ITADSP
vfNumerator.resize( 1 );
vfDenominator.resize( uiOrder + 1 );
SetZero();
};
inline void SetZero()
{
for( size_t i = 1; i < vfNumerator.size(); i++ )
for( size_t i = 0; i < vfNumerator.size(); i++ )
vfNumerator[ i ] = 0.0f;
if( vfDenominator.size() > 0 )
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......@@ -39,17 +39,17 @@ namespace ITADSP
{
ITA_DSP_API void Yulewalk( const ITABase::CFiniteImpulseResponse& oIR, CFilterCoefficients& oCoeffs );
ITA_DSP_API void Burg(const ITABase::CFiniteImpulseResponse& oIR, CFilterCoefficients& oCoeffs);
ITA_DSP_API void Burg( const ITABase::CFiniteImpulseResponse& oIR, CFilterCoefficients& oCoeffs );
ITA_DSP_API float InnerProduct(const float *x, const float *y, const int length);
ITA_DSP_API float InnerProduct( const float *x, const float *y, const int length );
ITA_DSP_API void numf();
ITA_DSP_API void denf( float *A, const ITASampleBuffer& R, int na );
ITA_DSP_API void toeplitz(float **out, const ITASampleBuffer &row, const ITASampleBuffer &column);
ITA_DSP_API void toeplitz( float **out, const ITASampleBuffer &row, const ITASampleBuffer &column );
ITA_DSP_API void toeplitz(float **out, const ITASampleBuffer &in, int na);
ITA_DSP_API void toeplitz( float **out, const ITASampleBuffer &in, int na );
}
}
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......@@ -209,7 +209,7 @@ public:
* @param[in] iCursorID Cursor identifier
* @param[in] iLength Number of samples that should be read from the VDL
*
* @return Effective number of samples required for read() call
* @return Effective number of samples required for read() call with included difference cause by switching from old to new delay
*/
int GetEffectiveReadLength( const int iCursorID, int iLength ) const;
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......@@ -21,9 +21,9 @@
#include <ITADSPDefinitions.h>
#include <ITAThirdOctaveMagnitudeSpectrum.h>
#include <ITAFFT.h>
#include <ITAStopWatch.h>
#include <ITASampleBuffer.h>
#include <ITAThirdOctaveMagnitudeSpectrum.h>
#include <string.h>
#include <vector>
......@@ -36,13 +36,6 @@
class ITA_DSP_API CITAThirdOctaveFIRFilterGenerator
{
public:
// Design methods
enum
{
LINEAR_PHASE = 0,
MINIMUM_PHASE
};
// Konstruktor
CITAThirdOctaveFIRFilterGenerator( const double dSampleRate, const int iFilterLength );
......@@ -52,35 +45,38 @@ public:
// Filterlnge zurckgeben [Samples]
int GetFilterLength() const;
//! Returns sampling rate [Samples/s]
double GetSampleRate() const;
// Latenz in den Filtern zurckgeben [Samples]
int GetLatency() const;
// Mittlere Laufzeit der Erzeuger-Methode zurckgeben
double GetAverageRuntime() const;
// Dateiname fr Debug-Ausgaben setzen
void SetDumpFilename( const std::string& sFilename );
// Filter erzeugen
void GenerateFilter( const ITABase::CThirdOctaveGainMagnitudeSpectrum& oTOMagnitudes, float* pfFilterCoeffs, bool bMinimumPhase = false);
void GenerateFilter( const ITABase::CThirdOctaveGainMagnitudeSpectrum& oTOMagnitudes, float* pfFilterCoeffs, bool bMinimumPhase = false ) const;
//! Generate FIR filter from third octave (linear) magnitude spectrum
/**
* @param[in] oTOGainMagnitudes Target energetic spectrum
* @param[out] sbImpulseResponse Generated impulse response (time domain filter coefficients) (must be equal or longer than initial filter length of generator class)
* @param[out] bMinimumPhase Request minimum phase
*/
void CITAThirdOctaveFIRFilterGenerator::GenerateFilter( const ITABase::CThirdOctaveGainMagnitudeSpectrum& oTOGainMagnitudes, ITASampleBuffer& sbImpulseResponse, bool bMinimumPhase /*=false*/ ) const;
private:
double m_dSamplerate; // Abtastrate der Ausgabefilter [Hz]
int m_iFilterLength; // Lnge der Ausgabefilter
int m_iDFTCoeffs; // Anzahl symetrischer DFT-Koeffizienten
float m_fDeltaF; // DFT-Frequenzauflsung [Hz]
int m_iInputFreqs; // Anzahl Frequenzsttzstellen fr Interpolation (31 Terzen + 2 Rnder)
float* m_pfInputFreqs; // Frequenzsttzstellen der Eingabedaten (Terzen) @todo jst: std::vector
float* m_pfInputData; // Zwischenspeicher fr die Interpolation @todo jst: std::vector
float* m_ypp; // Interpolationsdaten
float* m_pfBuf1;
float* m_pfBuf2;
bool m_bWindow; // Apply window?
float* m_pfWindow;
ITAFFT m_ifft;
std::string m_sDumpFilename;
mutable ITAStopWatch m_sw;
int m_iNumInputFreqs; // Anzahl Frequenzsttzstellen fr Interpolation (31 Terzen + 2 Rnder)
std::vector< float > m_vfInputFreqVector; // Frequenzsttzstellen der Eingabedaten (Terzen) @todo jst: std::vector
mutable std::vector< float > m_vfInputFreqData; // Zwischenspeicher fr die Interpolation @todo jst: std::vector
mutable float* m_ypp; //! Cubic spline interplation data
mutable std::vector< float > m_vfFreqDataInterpolated;
std::vector< float > m_vfImpulseResponse;
mutable ITAFFT m_ifft;
};
#endif // IW_ITA_THIRD_OCTAVE_FILTER_GENERATOR
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......@@ -40,7 +40,9 @@ public:
enum
{
FIR_SPLINE_LINEAR_PHASE = 0, //!< Linearphasiges FIR Filter mit Spline-Interpolation
IIR_BIQUADS_ORDER10 //!< Rekursives IIR Filter umgesetzt durch kaskadierte Biquads
IIR_BIQUADS_ORDER10, //!< Rekursives IIR Filter umgesetzt durch kaskadierte Biquads
IIR_BURG_ORDER4, //!< Recursive 4th-order IIR filtering with a Burg coefficient design
IIR_BURG_ORDER10, //!< Recursive 10th-order IIR filtering with a Burg coefficient design
} FilterbankRealisationMethods;
//! Factory method zum erzeugen einer Filterbank
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......@@ -22,83 +22,32 @@
#include <ITAThirdOctaveFilterbank.h>
#include <ITAThirdOctaveFIRFilterGenerator.h>
#include <ITAUPConvolution.h>
#include <ITAUPFilter.h>
#include <ITAFastMath.h>
#include <cassert>
class ITAUPConvolution;
//! Terzfilterbank mittels Dynamic Single-Channel Blockfalter (FIR Filter)
class ITA_DSP_API CITAThirdOctaveFilterbankFIR : public CITAThirdOctaveFilterbank
{
public:
inline CITAThirdOctaveFilterbankFIR( const double dSampleRate, const int iBlockLength )
: m_pfFilter( nullptr )
, m_pGenerator( nullptr )
, m_pConvolver( nullptr )
{
m_iBlocklength = iBlockLength;
// [fwe] Hier wird die Filterlänge für Directivities festgelegt
m_iFilterLength = 128;
m_pfFilter = fm_falloc( m_iFilterLength, true );
m_pGenerator = new CITAThirdOctaveFIRFilterGenerator( dSampleRate, m_iFilterLength );
m_pConvolver = new ITAUPConvolution( iBlockLength, m_iFilterLength );
m_pConvolver->SetFilterExchangeFadingFunction( ITABase::FadingFunction::COSINE_SQUARE );
m_pConvolver->SetFilterCrossfadeLength( 32 );
SetIdentity( false );
}
inline virtual ~CITAThirdOctaveFilterbankFIR()
{
fm_free( m_pfFilter );
delete m_pGenerator;
delete m_pConvolver;
}
inline virtual void SetIdentity( const bool bSmoothChangeover )
{
ITAUPFilter* pFilter = m_pConvolver->RequestFilter();
int iLatency = m_pGenerator->GetLatency();
assert( iLatency < m_iFilterLength );
fm_zero( m_pfFilter, m_iFilterLength );
m_pfFilter[ iLatency ] = 1;
pFilter->Load( m_pfFilter, m_iFilterLength );
m_pConvolver->ExchangeFilter( pFilter, ( bSmoothChangeover ? ITABase::FadingFunction::COSINE_SQUARE : ITABase::FadingFunction::SWITCH ) );
pFilter->Release(); // Auto-release
}
inline virtual void SetMagnitudes( const ITABase::CThirdOctaveGainMagnitudeSpectrum& oMags, const bool bSmoothChangeover = true )
{
m_pGenerator->GenerateFilter( oMags, m_pfFilter );
ITAUPFilter* pFilter = m_pConvolver->RequestFilter();
pFilter->Load( m_pfFilter, m_iFilterLength );
m_pConvolver->ExchangeFilter( pFilter, ( bSmoothChangeover ? ITABase::FadingFunction::COSINE_SQUARE : ITABase::FadingFunction::SWITCH ) );
pFilter->Release(); // Auto-release
}
inline int GetLatency() const
{
return m_pGenerator->GetLatency();
}
CITAThirdOctaveFilterbankFIR( const double dSampleRate, const int iBlockLength );
inline virtual void Clear()
{
m_pConvolver->clear();
SetIdentity( true );
}
virtual ~CITAThirdOctaveFilterbankFIR();
inline virtual void Process( const float* pfInputSamples, float* pfOutputSamples )
{
m_pConvolver->Process( pfInputSamples, m_iBlocklength, pfOutputSamples, m_iBlocklength );
}
virtual void SetIdentity( const bool bSmoothChangeover = true );
virtual void SetMagnitudes( const ITABase::CThirdOctaveGainMagnitudeSpectrum& oMags, const bool bSmoothChangeover = true );
int GetLatency() const;
virtual void Clear();
virtual void Process( const float* pfInputSamples, float* pfOutputSamples );
private:
int m_iBlocklength;
int m_iFilterLength;
float* m_pfFilter;
int m_iConvolutionTaps;
int m_iGeneratorFilterLength;
std::vector< float > m_vfGeneratedFIR;
CITAThirdOctaveFIRFilterGenerator* m_pGenerator;
ITAUPConvolution* m_pConvolver;
};
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......
......@@ -3,7 +3,7 @@
*
* ITA core libs
* (c) Copyright Institute of Technical Acoustics (ITA)
* RWTH Aachen University, Germany, 2015-2019
* RWTH Aachen University, Germany, 2015-2020
*
* ----------------------------------------------------------------
* ____ __________ _______
......