add stride

This commit is contained in:
Glenn Maynard
2006-12-09 22:43:44 +00:00
parent 4e73095fce
commit fa5a6102f4
2 changed files with 11 additions and 7 deletions
+10 -6
View File
@@ -53,23 +53,27 @@ void RageSoundMixBuffer::Extend( unsigned iSamples )
}
}
void RageSoundMixBuffer::write( const int16_t *pBuf, unsigned iSize )
void RageSoundMixBuffer::write( const int16_t *pBuf, unsigned iSize, int iSourceStride, int iDestStride )
{
Extend( iSize );
/* iSize = 3, iDestStride = 2 uses 4 frames. Don't allocate the stride of the
* last sample. */
Extend( iSize * iDestStride - (iDestStride-1) );
/* Scale volume and add. */
int32_t *pDestBuf = m_pMixbuf+m_iOffset;
#ifdef USE_VEC
if( g_bVector )
if( g_bVector && iSourceStride == 1 && iDestStride == 1 )
{
Vector::FastSoundWrite( pDestBuf, pBuf, iSize, m_iVolumeFactor );
return;
}
#endif
for( unsigned pos = 0; pos < iSize; ++pos )
while( iSize )
{
*pDestBuf += pBuf[pos] * m_iVolumeFactor;
++pDestBuf;
*pDestBuf += *pBuf * m_iVolumeFactor;
pBuf += iSourceStride;
pDestBuf += iDestStride;
--iSize;
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ public:
~RageSoundMixBuffer();
/* Mix the given buffer of samples. */
void write( const int16_t *buf, unsigned size );
void write( const int16_t *buf, unsigned size, int iSourceStride = 1, int iDestStride = 1 );
/* Extend the buffer as if write() was called with a buffer of silence. */
void Extend( unsigned iSamples );