Fixing problems with Dirac function generator, but still not really nice.

parent f7d2a5ae
#include "ITAStreamFunctionGenerator.h" #include "ITAStreamFunctionGenerator.h"
#include <ITAConstants.h> #include <ITAConstants.h>
#include <ITADataSourceRealization.h> #include <ITADataSourceRealization.h>
...@@ -53,8 +53,13 @@ double ITAStreamFunctionGenerator::GetFrequency() const ...@@ -53,8 +53,13 @@ double ITAStreamFunctionGenerator::GetFrequency() const
void ITAStreamFunctionGenerator::SetFrequency( double dFrequency ) void ITAStreamFunctionGenerator::SetFrequency( double dFrequency )
{ {
assert( dFrequency >= 0 ); if( GetFunction() == DIRAC && dFrequency <= 0.0f )
m_iPeriodLengthSamples = ( int ) round( m_dSampleRate / dFrequency ); m_iPeriodLengthSamples = m_iSampleCount;
else
{
assert( dFrequency > 0.0f );
m_iPeriodLengthSamples = ( int ) round( m_dSampleRate / dFrequency );
}
} }
int ITAStreamFunctionGenerator::GetPeriodAsSamples() const int ITAStreamFunctionGenerator::GetPeriodAsSamples() const
...@@ -185,16 +190,18 @@ void ITAStreamFunctionGenerator::ProcessStream( const ITAStreamInfo* ) ...@@ -185,16 +190,18 @@ void ITAStreamFunctionGenerator::ProcessStream( const ITAStreamInfo* )
case DIRAC: case DIRAC:
iNumSamples = ( m_bPeriodic ? ( int ) m_uiBlocklength : ( std::min )( ( int ) m_uiBlocklength, m_iPeriodLengthSamples - m_iSampleCount ) ); iNumSamples = ( m_bPeriodic ? ( int ) m_uiBlocklength : ( std::min )( ( int ) m_uiBlocklength, m_iPeriodLengthSamples - m_iSampleCount ) );
if( m_bPeriodic ) if( m_bPeriodic )
{ {
for( int i = 0; i < iNumSamples; i++ )
for( int i = 0; i < iNumSamples; i++ ) pfOutputData[ i ] = ( m_iSampleCount++ % N ? 0 : a ); pfOutputData[ i ] = ( m_iSampleCount++ % N ? 0 : a );
} }
else { else
{
pfOutputData[ 0 ] = ( m_iSampleCount == 0 ? a : 0 ); pfOutputData[ 0 ] = ( m_iSampleCount == 0 ? a : 0 );
for( int i = 1; i < iNumSamples; i++ ) pfOutputData[ i ] = 0; for( int i = 1; i < GetBlocklength(); i++ )
m_iSampleCount += iNumSamples; pfOutputData[ i ] = 0.0f;
m_iSampleCount += GetBlocklength();
} }
break; break;
......
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