More fixes

This commit is contained in:
Vesa
2014-04-08 23:07:16 +03:00
parent 5397bbeaf4
commit 7b0d829cc4
4 changed files with 36 additions and 64 deletions

View File

@@ -37,7 +37,7 @@ void BandLimitedWave::generateWaves()
for( i = 1; i <= MAXLEN; i++ )
{
const int len = 1 << i;
const double om = 1.0 / len;
//const double om = 1.0 / len;
double max = 0.0;
for( int ph = 0; ph < len; ph++ )
@@ -48,11 +48,11 @@ void BandLimitedWave::generateWaves()
do
{
hlen = static_cast<double>( len ) / static_cast<double>( harm );
const double amp = -1.0 / static_cast<double>( harm ) * ( hlen <= 4 ? 0.5 : 1.0 ) * ( hlen < 8 ? 0.75 : 1.0 );
const double a2 = cos( om * harm * F_2PI );
s += amp * a2 * sin( static_cast<double>( ph * harm ) / static_cast<double>( len ) * F_2PI );
const double amp = -1.0 / static_cast<double>( harm );
//const double a2 = cos( om * harm * F_2PI );
s += amp * /*a2 **/sin( static_cast<double>( ph * harm ) / static_cast<double>( len ) * F_2PI );
harm++;
} while( hlen >= 2.0 );
} while( hlen >= 4.0 );
s_waveforms[ BandLimitedWave::BLSaw ].setSampleAt( i, ph, s );
max = qMax( max, qAbs( s ) );
}
@@ -68,7 +68,7 @@ void BandLimitedWave::generateWaves()
for( i = 1; i <= MAXLEN; i++ )
{
const int len = 1 << i;
const double om = 1.0 / len;
//const double om = 1.0 / len;
double max = 0.0;
for( int ph = 0; ph < len; ph++ )
@@ -79,11 +79,11 @@ void BandLimitedWave::generateWaves()
do
{
hlen = static_cast<double>( len ) / static_cast<double>( harm );
const double amp = 1.0 / static_cast<double>( harm ) * ( hlen <= 4 ? 0.5 : 1.0 ) * ( hlen < 8 ? 0.75 : 1.0 );
const double a2 = cos( om * harm * F_2PI );
s += amp * a2 * sin( static_cast<double>( ph * harm ) / static_cast<double>( len ) * F_2PI );
const double amp = 1.0 / static_cast<double>( harm );
//const double a2 = cos( om * harm * F_2PI );
s += amp * /*a2 **/ sin( static_cast<double>( ph * harm ) / static_cast<double>( len ) * F_2PI );
harm += 2;
} while( hlen >= 2.0 );
} while( hlen >= 4.0 );
s_waveforms[ BandLimitedWave::BLSquare ].setSampleAt( i, ph, s );
max = qMax( max, qAbs( s ) );
}
@@ -111,12 +111,12 @@ void BandLimitedWave::generateWaves()
do
{
hlen = static_cast<double>( len ) / static_cast<double>( harm );
const double amp = 1.0 / static_cast<double>( harm * harm ) * ( hlen <= 4 ? 0.5 : 1.0 ) * ( hlen < 8 ? 0.75 : 1.0 );
const double amp = 1.0 / static_cast<double>( harm * harm );
//const double a2 = cos( om * harm * F_2PI );
s += amp * /*a2 **/ sin( ( static_cast<double>( ph * harm ) / static_cast<double>( len ) +
( ( harm + 1 ) % 4 == 0 ? 0.5 : 0.0 ) ) * F_2PI );
harm += 2;
} while( hlen >= 2.0 );
} while( hlen >= 4.0 );
s_waveforms[ BandLimitedWave::BLTriangle ].setSampleAt( i, ph, s );
max = qMax( max, qAbs( s ) );
}