[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11301] branches/soc-2007-hcube/intern/ tinySND/intern/SND_FXMixer.cpp: Added buffer handling code.
Csaba Hruska
csaba.hruska at gmail.com
Wed Jul 18 12:40:58 CEST 2007
Revision: 11301
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11301
Author: hcube
Date: 2007-07-18 12:40:58 +0200 (Wed, 18 Jul 2007)
Log Message:
-----------
Added buffer handling code.
Modified Paths:
--------------
branches/soc-2007-hcube/intern/tinySND/intern/SND_FXMixer.cpp
Modified: branches/soc-2007-hcube/intern/tinySND/intern/SND_FXMixer.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/intern/SND_FXMixer.cpp 2007-07-18 10:39:40 UTC (rev 11300)
+++ branches/soc-2007-hcube/intern/tinySND/intern/SND_FXMixer.cpp 2007-07-18 10:40:58 UTC (rev 11301)
@@ -97,7 +97,7 @@
bool SND_FXMixer::isDataAvailable(void)
{
- if( mIsMuted || mGain==0 || mSounds.empty() )
+ if( mIsMuted || mGain==0.0 || mSounds.empty() )
{
return false;
}
@@ -118,13 +118,8 @@
int sndNum, j, n;
float mixFactor;
float *buffer;
-
- // if our buffer is not enough big, then allocate a new one
- // !!!!!!!! UNIMPLEMENTED YET !!!!!!!!!!!!!!!!!!!!
- // Do only fake mixing, not physically correct
- // FIXIT!!!!!!!!!!!!
-
+ // compressor effect is not implemented, maybe in the future
// collect sounds where data is available, count them
sndNum = 0;
@@ -142,8 +137,16 @@
// no mixing is needed, there is only one channel and gain is 1.0
return mSoundBuffers[ 0 ];
}
+
+ if( mBufferSize < framesNum )
+ {
+ delete mBuffer;
+ mBufferSize = (framesNum / SND_MIX_BUFFER_SIZE + 1) * SND_MIX_BUFFER_SIZE;
+ mBuffer = new float[ mBufferSize ];
+ }
+
// mix collected sounds
- mixFactor = mGain;// / ((float)sndNum);
+ mixFactor = mGain;
for( j = 0 ; j < sndNum ; ++j )
{
buffer = mSoundBuffers[ j ];
@@ -158,7 +161,6 @@
}
else
{
- // others adds own pcm data
for( n = 0 ; n < framesNum ; ++n )
{
mBuffer[ n ] += mixFactor * buffer[0];
More information about the Bf-blender-cvs
mailing list