Adding AddSamples method for write-and-add sample buffer manipulation

parent 7a645a95
......@@ -171,6 +171,36 @@ public:
* \note Kein Schreiben ber das Pufferende hinaus!
*/
void write( const float* pfSrc, int iCount, int iDestOffset = 0 );
//! Write samples from a source to the buffer (overwrites!)
/**
* Writes iCount samples from the given buffer starting at read position 0
* into the sample buffer beginning at given destination offset.
*
* @param pfSrc Source buffer / float array / vector
* @param iCount Number of samples to be added from source buffer into sample buffer
* @param iDestOffset Write position in sample buffer
*
* \@ote Make sure source buffer has iCount valid samples. Buffer will be overwritten by new samples.
*/
inline void WriteSamples( const float* pfSrc, int iCount, int iDestOffset = 0 )
{
write( pfSrc, iCount, iDestOffset );
};
//! Add samples from a source to the buffer
/**
* Adds iCount samples from the given buffer starting at read position 0
* into the sample buffer beginning at given destination offset.
*
* @param pfSrc Source buffer / float array / vector
* @param iCount Number of samples to be added from source buffer into sample buffer
* @param iDestOffset Write position in sample buffer
*
* \@ote Make sure source buffer has iCount valid samples
*/
void AddSamples( const float* pfSrc, int iCount, int iDestOffset = 0 );
//! Samples aus einem anderen Puffer in den Puffer kopieren
/**
......
......@@ -239,6 +239,19 @@ void ITASampleBuffer::write( const ITASampleBuffer& sbSrc, int iCount, int iSrcO
write( &sbSrc, iCount, iSrcOffset, iDestOffset );
}
void ITASampleBuffer::AddSamples( const float* pfSrc, int iCount, int iDestOffset )
{
assert( pfSrc != NULL );
assert( iCount >= 0 );
assert( ( iDestOffset >= 0 ) );
assert( ( iDestOffset + iCount ) <= m_iLength );
for( size_t i = 0; i < (size_t) iCount; i++ )
{
m_pfData[ i + iDestOffset ] += pfSrc[ i ];
}
}
void ITASampleBuffer::cyclic_read( float* pfDest, int iCount, int iSrcOffset ) const
{
assert( pfDest != NULL );
......
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