Commit 8960309c authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Style and switching to FIR implementation of third octave filter bank

parent e42c2872
......@@ -24,13 +24,13 @@ CVAAudiofileSignalSource::CVAAudiofileSignalSource( int iBufferLength, double dS
m_sfAudioBuffer.init( 2, iBufferLength, true );
std::vector< float* > vfBufferPointer;
vfBufferPointer.push_back( m_sfAudioBuffer[0].data() );
vfBufferPointer.push_back( m_sfAudioBuffer[1].data() );
vfBufferPointer.push_back( m_sfAudioBuffer[ 0 ].data() );
vfBufferPointer.push_back( m_sfAudioBuffer[ 1 ].data() );
m_pBufferDataSource = new ITABufferDatasource( vfBufferPointer, iBufferLength, dSampleRate, iBlockLength );
m_pBufferDataSource->SetPaused( true );
m_pBufferDataSource->SetLoopMode( false );
SetDatasourceDelegatorTarget( m_pBufferDataSource );
}
......@@ -44,33 +44,33 @@ CVAAudiofileSignalSource::CVAAudiofileSignalSource( const std::string& sFileName
{
m_sbOutBuffer.Init( iBlockLength, true );
CITAAudioSample sfFileBuffer(dSampleRate);
sfFileBuffer.LoadWithSampleRateConversion(sFileName);
CITAAudioSample sfFileBuffer( dSampleRate );
sfFileBuffer.LoadWithSampleRateConversion( sFileName );
std::vector< float* > vfBufferPointer;
int iGivenChannels = sfFileBuffer.channels();
if( iGivenChannels == 1 )
{
m_sfAudioBuffer.init( 2, sfFileBuffer.length(), false );
m_sfAudioBuffer[ 0 ].write( sfFileBuffer[ 0 ], sfFileBuffer.length() );
m_sfAudioBuffer[ 1 ].Zero();
vfBufferPointer.push_back( m_sfAudioBuffer[0].data() );
vfBufferPointer.push_back( m_sfAudioBuffer[1].data() );
vfBufferPointer.push_back( m_sfAudioBuffer[ 0 ].data() );
vfBufferPointer.push_back( m_sfAudioBuffer[ 1 ].data() );
}
else
{
VA_WARN( "VABufferSignalSource", "More than one channel in file '" << sFileName << "' found, using first." );
m_sfAudioBuffer = sfFileBuffer;
for( int i=0; i<m_sfAudioBuffer.channels(); i++ )
vfBufferPointer.push_back( m_sfAudioBuffer[i].data() );
for( int i = 0; i < m_sfAudioBuffer.channels(); i++ )
vfBufferPointer.push_back( m_sfAudioBuffer[ i ].data() );
}
m_pBufferDataSource = new ITABufferDatasource( vfBufferPointer, m_sfAudioBuffer.length(), dSampleRate, iBlockLength );
m_pBufferDataSource->SetPaused( true );
m_pBufferDataSource->SetLoopMode( false );
SetDatasourceDelegatorTarget( m_pBufferDataSource );
}
......@@ -108,16 +108,16 @@ void CVAAudiofileSignalSource::SetPlaybackAction( int iPlayStateAction )
void CVAAudiofileSignalSource::SetCursorSeconds( double dPos )
{
double dDuration = m_pBufferDataSource->GetCapacity()/m_pBufferDataSource->GetSampleRate();
double dDuration = m_pBufferDataSource->GetCapacity() / m_pBufferDataSource->GetSampleRate();
int iPos;
if (dPos < 0)
if( dPos < 0 )
iPos = 0;
else if (dPos > dDuration)
else if( dPos > dDuration )
iPos = m_pBufferDataSource->GetCapacity();
else
iPos = (int) floor( dPos * m_pBufferDataSource->GetSampleRate() );
iPos = ( int ) floor( dPos * m_pBufferDataSource->GetSampleRate() );
m_pBufferDataSource->SetCursor(iPos);
m_pBufferDataSource->SetCursor( iPos );
}
int CVAAudiofileSignalSource::GetType() const
......@@ -143,16 +143,16 @@ std::string CVAAudiofileSignalSource::GetStateString() const
std::string CVAAudiofileSignalSource::GetStateString( int iPlayState ) const
{
std::string s;
if( iPlayState == IVACore::VA_PLAYBACK_STATE_PLAYING )
m_pBufferDataSource->GetLoopMode() ? s = "playing and looping" : s = "playing";
else if( iPlayState == IVACore::VA_PLAYBACK_STATE_PAUSED )
s = "paused";
else if( iPlayState == IVACore::VA_PLAYBACK_STATE_STOPPED )
s = "stopped";
s = "stopped";
else
s = "unkown";
return s;
}
......@@ -161,7 +161,7 @@ IVACore* CVAAudiofileSignalSource::GetAssociatedCore() const
return m_pAssociatedCore;
}
void CVAAudiofileSignalSource::HandleRegistration(IVACore* pParentCore)
void CVAAudiofileSignalSource::HandleRegistration( IVACore* pParentCore )
{
m_pAssociatedCore = pParentCore;
}
......@@ -175,12 +175,12 @@ const float* CVAAudiofileSignalSource::GetStreamBlock( const CVAAudiostreamState
{
const int iNewPlayAction = m_iRequestedPlaybackAction;
const bool bSyncMod = pStreamInfo->bSyncMod; // If true, hold changes back until false
int iResidualSamples = m_pBufferDataSource->GetCursor() - m_pBufferDataSource->GetCapacity();
bool bEndOfFileReached = ( iResidualSamples >= 0 );
int iNewPlaybackState = IVACore::VA_PLAYBACK_STATE_INVALID;
switch ( m_iCurrentPlayState )
switch( m_iCurrentPlayState )
{
case IVACore::VA_PLAYBACK_STATE_STOPPED:
......@@ -243,7 +243,7 @@ const float* CVAAudiofileSignalSource::GetStreamBlock( const CVAAudiostreamState
// Do not apply any changes during synced modification, but process if required
if( bSyncMod )
{
// Special case: if running into EOF, state change may be required
// Special case: if running into EOF, state change may be required
if( bEndOfFileReached )
{
m_pBufferDataSource->Rewind();
......@@ -292,13 +292,13 @@ const float* CVAAudiofileSignalSource::GetStreamBlock( const CVAAudiostreamState
{
m_pBufferDataSource->Rewind();
m_pBufferDataSource->SetPaused( false );
iNewPlaybackState =IVACore::VA_PLAYBACK_STATE_PLAYING;
iNewPlaybackState = IVACore::VA_PLAYBACK_STATE_PLAYING;
}
else if( iNewPlayAction == IVACore::VA_PLAYBACK_ACTION_PAUSE )
{
m_pBufferDataSource->Rewind();
m_pBufferDataSource->SetPaused( true );
iNewPlaybackState =IVACore::VA_PLAYBACK_STATE_PAUSED;
iNewPlaybackState = IVACore::VA_PLAYBACK_STATE_PAUSED;
}
else if( iNewPlayAction == IVACore::VA_PLAYBACK_ACTION_STOP )
{
......@@ -321,7 +321,7 @@ const float* CVAAudiofileSignalSource::GetStreamBlock( const CVAAudiostreamState
assert( iNewPlaybackState != IVACore::VA_PLAYBACK_STATE_INVALID );
m_iCurrentPlayState = iNewPlaybackState;
}
// Process audio file signal source: copy samples from buffer
if( m_iCurrentPlayState == IVACore::VA_PLAYBACK_STATE_PLAYING )
{
......
......@@ -1124,8 +1124,8 @@ void CVABinauralFreeFieldAudioRenderer::UpdateGlobalAuralizationMode( int iGloba
CVABFFSoundPath::CVABFFSoundPath( double dSamplerate, int iBlocklength, int iHRIRFilterLength, int iDirFilterLength )
{
pThirdOctaveFilterBank = CITAThirdOctaveFilterbank::Create( dSamplerate, iBlocklength,
//CITAThirdOctaveFilterbank::FIR_SPLINE_LINEAR_PHASE);
CITAThirdOctaveFilterbank::IIR_BIQUADS_ORDER10 );
CITAThirdOctaveFilterbank::FIR_SPLINE_LINEAR_PHASE);
//CITAThirdOctaveFilterbank::IIR_BIQUADS_ORDER10 );
pThirdOctaveFilterBank->SetIdentity();
float fReserverdMaxDelaySamples = (float) ( 3 * dSamplerate ); // 3 Sekunden ~ 1km Entfernung
......
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