Commit 56d61b79 authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen
Browse files

Refactoring sample buffer fading definitions, now all in ITABaseDefinition and...

Refactoring sample buffer fading definitions, now all in ITABaseDefinition and with appropriate namespacing and enum declaration
parent 04063a2c
......@@ -121,7 +121,7 @@ public:
/**
* Fades in sample region [iOffset, iOffset+iCount] using given fading function
*/
void Fade( int iOffset, int iCount, int iFadeDirection, int iFadeFunction );
void Fade( int iOffset, int iCount, int iFadingSign, int iFadingFunction = ITABase::FadingFunction::COSINE_SQUARE );
//! Crossfade
/**
......@@ -133,8 +133,8 @@ public:
* Danach werden iCount Samples zwischen den beiden Puffern kreuzgeblendet.
* Dahinter folgen nur noch Samples dieses Puffers.
*/
void Crossfade( const ITASampleBuffer* psbSrc, int iOffset, int iCount, int iFadeDirection, int iFadeFunction );
void Crossfade( const ITASampleBuffer& sbSrc, int iOffset, int iCount, int iFadeDirection, int iFadeFunction );
void Crossfade( const ITASampleBuffer* psbSrc, int iOffset, int iCount, int iCrossfadeDirection, int iFadingFunction = ITABase::FadingFunction::COSINE_SQUARE );
void Crossfade( const ITASampleBuffer& sbSrc, int iOffset, int iCount, int iCrossfadeDirection, int iFadingFunction = ITABase::FadingFunction::COSINE_SQUARE );
//! Envelope
/**
......@@ -333,31 +333,11 @@ public:
//! Werte als Zeichenkette zurckgeben
std::string ValuesToString() const;
void Load( const std::string& sFilePath );
void Load( const std::string& sFilePath, float& fSampleRate );
void Store( const std::string& sFilePath, const float fSampleRate = 44100.0f ) const;
//! berblendfunktionen
enum
{
LINEAR = 0, //!< Lineare berblendung aka. Rampe
COSINE_SQUARE = 1 //!< Cosinus-Quadrat berblendung (aka Hanning-Fenster)
};
//! berblendrichtungen
enum
{
FADE_IN = 0, //!< Einblenden
FADE_OUT = 1 //!< Ausblenden
};
enum
{
CROSSFADE_TO_SOURCE = 0, //!< Kreuzblende hin zum Quellsignal
CROSSFADE_FROM_SOURCE = 1 //!< Kreuzblende weg vom Quellsignal
};
private:
int m_iLength;
float* m_pfData;
......
......@@ -142,90 +142,52 @@ void ITASampleBuffer::Identity()
m_pfData[ i ] = 0;
}
void ITASampleBuffer::Fade( int iOffset, int iCount, int iFadeDirection, int iFadeFunction )
void ITASampleBuffer::Fade( int iOffset, int iCount, int iFadingSign, int iFadingFunction )
{
assert( iOffset >= 0 );
assert( iCount > 0 );
assert( ( iOffset + iCount ) <= m_iLength );
int iFlags = 0;
switch( iFadeDirection )
{
case FADE_IN:
iFlags |= ITA_FADE_IN;
break;
case FADE_OUT:
iFlags |= ITA_FADE_OUT;
break;
default:
// Ungültiger Wert
assert( false );
}
switch( iFadeFunction ) {
case LINEAR:
iFlags |= ITA_FADE_LINEAR;
break;
case COSINE_SQUARE:
iFlags |= ITA_FADE_COSINE_SQUARE;
break;
default:
// Ungültiger Wert
assert( false );
}
::Fade( m_pfData + iOffset, iCount, iFlags );
::Fade( m_pfData + iOffset, iCount, iFadingSign, iFadingFunction );
}
void ITASampleBuffer::Crossfade( const ITASampleBuffer* psbSrc, int iOffset, int iCount, int iFadeDirection, int iFadeFunction )
void ITASampleBuffer::Crossfade( const ITASampleBuffer* psbSrc, int iOffset, int iCount, int iCrossfadeDirection, int iFadeFunction )
{
assert( psbSrc );
assert( iOffset >= 0 );
assert( iCount >= 0 );
assert( ( iOffset + iCount ) <= m_iLength );
assert( ( iOffset + iCount ) <= psbSrc->m_iLength );
int iFlags = 0;
switch( iFadeFunction )
switch( iCrossfadeDirection )
{
case LINEAR:
iFlags |= ITA_FADE_LINEAR;
break;
case COSINE_SQUARE:
iFlags |= ITA_FADE_COSINE_SQUARE;
break;
default:
// Ungültiger Wert
assert( false );
}
switch( iFadeDirection )
case ITABase::CrossfadeDirection::OFF_SOURCE:
{
case CROSSFADE_FROM_SOURCE:
// Samples am Anfang kopieren
for( int i = 0; i < iOffset; i++ )
m_pfData[ i ] = psbSrc->m_pfData[ i ];
::Crossfade( psbSrc->m_pfData + iOffset, m_pfData + iOffset, m_pfData + iOffset, iCount, iFlags );
::Crossfade( psbSrc->m_pfData + iOffset, m_pfData + iOffset, m_pfData + iOffset, iCount, iFadeFunction );
return;
case CROSSFADE_TO_SOURCE:
}
case ITABase::CrossfadeDirection::TO_SOURCE:
{
assert( psbSrc->m_iLength >= m_iLength );
::Crossfade( m_pfData + iOffset, psbSrc->m_pfData + iOffset, m_pfData + iOffset, iCount, iFlags );
::Crossfade( m_pfData + iOffset, psbSrc->m_pfData + iOffset, m_pfData + iOffset, iCount, iFadeFunction );
// Samples am Ende kopieren
for( int i = iOffset + iCount; i < m_iLength; i++ )
m_pfData[ i ] = psbSrc->m_pfData[ i ];
return;
}
default:
{
// Ungültiger Wert
assert( false );
}
}
}
void ITASampleBuffer::Crossfade( const ITASampleBuffer& sbSrc, int iOffset, int iCount, int iFadeDirection, int iFadeFunction )
void ITASampleBuffer::Crossfade( const ITASampleBuffer& sbSrc, int iOffset, int iCount, int iCrossfadeDirection, int iFadeFunction )
{
Crossfade( &sbSrc, iOffset, iCount, iFadeDirection, iFadeFunction );
Crossfade( &sbSrc, iOffset, iCount, iCrossfadeDirection, iFadeFunction );
}
void ITASampleBuffer::Envelope( float fGain0, float fGain1 )
......
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