Commit 1d287bd0 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Trying to implement very simple FFT conversion method, but WIP

parent a0679a96
......@@ -19,12 +19,15 @@
#ifndef INCLUDE_WATCHER_ITA_FFT_UTILS
#define INCLUDE_WATCHER_ITA_FFT_UTILS
#include <ITAFFTDefinitions.h>
#include "ITAFFTDefinitions.h"
#include <ITAHDFTSpectra.h>
#include <ITAHDFTSpectrum.h>
#include <ITAHDFTSpectra.h>
#include <ITASampleBuffer.h>
#include <ITASampleFrame.h>
#include <ITAFiniteImpulseResponse.h>
#include <ITAMultichannelFiniteImpulseResponse.h>
namespace ITAFFTUtils
......@@ -45,6 +48,10 @@ namespace ITAFFTUtils
*/
ITA_FFT_API void Convert( const ITABase::CHDFTSpectra* pFreqDomainSpectra, ITASampleFrame& sfIR );
ITA_FFT_API void Convert( const ITABase::CFiniteImpulseResponse& oIR, ITABase::CHDFTSpectrum* pSpectrum );
ITA_FFT_API void Convert( const ITABase::CMultichannelFiniteImpulseResponse& oIR, ITABase::CHDFTSpectra* pSpectra );
//! Export a single-channel HDFT spectrum as a WAV file
/**
* \param[in] pFreqDomainSpectrum HDFT spectra in frequency domain
......
......@@ -5,6 +5,8 @@
#include <ITAFFT.h>
#include <cassert>
void ITAFFTUtils::Convert( const ITABase::CHDFTSpectrum* pSpectrum, ITASampleBuffer& sbIR )
{
sbIR.Init( pSpectrum->GetDFTSize() - 1, true );
......@@ -42,7 +44,41 @@ void ITAFFTUtils::Convert( const ITABase::CHDFTSpectra* pSpectra, ITASampleFrame
// Normalize after IFFT
sfIR.div_scalar( float( sfIR.length() ) );
return;
}
void ITAFFTUtils::Convert( const ITABase::CFiniteImpulseResponse& oIR, ITABase::CHDFTSpectrum* pSpectrum )
{
assert( pSpectrum->GetSampleRate() == oIR.GetSampleRate() );
ITASampleBuffer sbSourceData( pSpectrum->GetDFTSize() - 1, true ); // local copy
ITAFFT fft( ITAFFT::FFT_R2C, oIR.GetLength(), sbSourceData.GetData(), pSpectrum->GetData() );
// Make local copy of input (will be destroyed by in-place FFT)
sbSourceData.write( pSpectrum->GetData(), sbSourceData.GetLength() );
float* fIn = sbSourceData.GetData();
float* fOut = pSpectrum->GetData();
fft.execute( fIn, fOut );
return;
}
void ITAFFTUtils::Convert( const ITABase::CMultichannelFiniteImpulseResponse& oIR, ITABase::CHDFTSpectra* pSpectra )
{
assert( pSpectra->GetSampleRate() == oIR.GetSampleRate() );
ITASampleBuffer sbSourceData( pSpectra->GetDFTSize() - 1, true ); // local copy
ITAFFT fft( ITAFFT::FFT_R2C, oIR.GetLength(), sbSourceData.GetData(), (*pSpectra)[0]->GetData() );
for( int n = 0; n < pSpectra->GetNumChannels(); n++ )
{
auto pSpectrum = (*pSpectra)[ n ];
// Make local copy of input (will be destroyed by in-place FFT)
sbSourceData.write( pSpectrum->GetData(), sbSourceData.GetLength() );
float* fIn = sbSourceData.GetData();
float* fOut = pSpectrum->GetData();
fft.execute( fIn, fOut );
}
return;
}
......@@ -59,7 +95,7 @@ void ITAFFTUtils::Export( const ITABase::CHDFTSpectrum* pSpectrum, const std::st
sbIR.Normalize();
writeAudiofile( sFilePathFinal, &sbIR, pSpectrum->GetSampleRate(), ITAQuantization::ITA_FLOAT );
return;
}
......
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