[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11302] branches/soc-2007-hcube/intern/ tinySND: no code change, just adding tabs for nice and more readable code.
Csaba Hruska
csaba.hruska at gmail.com
Wed Jul 18 12:44:24 CEST 2007
Revision: 11302
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11302
Author: hcube
Date: 2007-07-18 12:44:24 +0200 (Wed, 18 Jul 2007)
Log Message:
-----------
no code change, just adding tabs for nice and more readable code.
Modified Paths:
--------------
branches/soc-2007-hcube/intern/tinySND/SND_DataProvider.h
branches/soc-2007-hcube/intern/tinySND/SND_Defines.h
branches/soc-2007-hcube/intern/tinySND/SND_FXSample.h
branches/soc-2007-hcube/intern/tinySND/intern/SND_FXSample.cpp
Modified: branches/soc-2007-hcube/intern/tinySND/SND_DataProvider.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_DataProvider.h 2007-07-18 10:40:58 UTC (rev 11301)
+++ branches/soc-2007-hcube/intern/tinySND/SND_DataProvider.h 2007-07-18 10:44:24 UTC (rev 11302)
@@ -8,24 +8,24 @@
{
public:
- virtual ~SND_DataProvider() {}
+ virtual ~SND_DataProvider() {}
// true if file loading is succed, false if there was an error
virtual bool isFormatSupported() = 0;
- int getNumFrames() const { return mNumFrames; }
- float getDuration() const { return mDuration; } // in sec
+ int getNumFrames() const { return mNumFrames; }
+ float getDuration() const { return mDuration; } // in sec
- float getSampleRate() const { return mSampleRate; }
- int getBitRate() const { return mBitRate; }
+ float getSampleRate() const { return mSampleRate; }
+ int getBitRate() const { return mBitRate; }
- int getNumChannels() const { return mNumChannels; }
+ int getNumChannels() const { return mNumChannels; }
- int isSeekable() const { return mIsSeekable; }
+ int isSeekable() const { return mIsSeekable; }
- virtual void seek( int frameNum ) = 0;
+ virtual void seek( int frameNum ) = 0;
- virtual int fillBuffer( float *buffer, int channelIndex, int framesNum ) = 0;
+ virtual int fillBuffer( float *buffer, int channelIndex, int framesNum ) = 0;
protected:
int mNumFrames;
Modified: branches/soc-2007-hcube/intern/tinySND/SND_Defines.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_Defines.h 2007-07-18 10:40:58 UTC (rev 11301)
+++ branches/soc-2007-hcube/intern/tinySND/SND_Defines.h 2007-07-18 10:44:24 UTC (rev 11302)
@@ -37,7 +37,7 @@
#ifndef __SOUNDDEFINES_H
#define __SOUNDDEFINES_H
-#define SND_WAVE_BUFFER_SIZE (256*1024)
+#define SND_WAVE_BUFFER_SIZE (256*1024)
#define SND_MIX_BUFFER_SIZE (16*1024)
/* playstate flags */
Modified: branches/soc-2007-hcube/intern/tinySND/SND_FXSample.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_FXSample.h 2007-07-18 10:40:58 UTC (rev 11301)
+++ branches/soc-2007-hcube/intern/tinySND/SND_FXSample.h 2007-07-18 10:44:24 UTC (rev 11302)
@@ -26,6 +26,13 @@
BACKWARD = 1
};
+ enum LoopMode
+ {
+ OFF = 0,
+ NORMAL = 1,
+ BIDIRECTIONAL = 2
+ };
+
SND_FXSample( SND_DataProvider *dataProvider, int channelIdx );
PlayState getPlayState();
@@ -36,13 +43,16 @@
PlayDirection getPlayDirection();
void setPlayDirection( PlayDirection playDirection );
- void setLoopMode( int loopMode );
- void setLoopStart( int frameNum );
- void setLoopEnd( int frameNum );
+ LoopMode getLoopMode();
+ void setLoopMode( LoopMode loopMode );
+ int getLoopStartFrame();
+ void setLoopStartFrame( int frameNum );
+ int getLoopEndFrame();
+ void setLoopEndFrame( int frameNum );
void setGain( float gain );
float getGain();
-
+
bool isMuted();
void setMute( bool isMuted );
@@ -51,14 +61,13 @@
float getSampleRate();
int getBitRate();
-
- // we can request sound data. do not request big part, only few kilobytes are recommended
- float* getPCMDataPtr( int framesNum ); // incremets frame counter according play state
- int getCurrentFrameNum() const;
+ int getCurrentFrameNumber();
void seek( int frameNum );
-
+
bool isDataAvailable();
+ // we can request sound data. do not request big part, only few kilobytes are recommended
+ float* getPCMDataPtr( int framesNum ); // incremets frame counter according to play state
private:
float *mSourceBuffer; // it has it s own medium sized sample buffer max: ~300Kb
@@ -70,12 +79,15 @@
SND_DataProvider *mDataProvider;
- bool mIsMuted;
+ float mGain;
+ bool mIsMuted;
int mFrameCounter;
PlayState mPlayState;
- float mGain;
int mChannelNum;
PlayDirection mPlayDirection;
+ LoopMode mLoopMode;
+ int mLoopStartFrame;
+ int mLoopEndFrame;
};
Modified: branches/soc-2007-hcube/intern/tinySND/intern/SND_FXSample.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/intern/SND_FXSample.cpp 2007-07-18 10:40:58 UTC (rev 11301)
+++ branches/soc-2007-hcube/intern/tinySND/intern/SND_FXSample.cpp 2007-07-18 10:44:24 UTC (rev 11302)
@@ -2,7 +2,7 @@
Can be looped
dont do any format conversion
provides pcm data at same format that it comes from dataProvider
- handles: loops, atatched effects, gain
+ handles: loops, gain
*/
#include <assert.h>
@@ -14,6 +14,7 @@
mDataProvider = dataProvider;
mPlayState = SND_FXSample::STOPPED;
mPlayDirection = SND_FXSample::FORWARD;
+ mLoopMode = SND_FXSample::OFF;
mChannelNum = channelIdx;
@@ -31,42 +32,93 @@
mSourceBuffer = new float[size];
mDataProvider->fillBuffer( mSourceBuffer, mChannelNum, size );
+ mLoopStartFrame = 0;
+ mLoopEndFrame = frames;
mIsMuted = false;
mGain = 1.0;
}
-bool SND_FXSample::isMuted(void)
+SND_FXSample::PlayState SND_FXSample::getPlayState(void)
{
- return mIsMuted;
+ return mPlayState;
}
-void SND_FXSample::setMute( bool isMuted )
+void SND_FXSample::play(void)
{
- mIsMuted = isMuted;
+ mFrameCounter = 0;
+ mPlayState = SND_FXSample::STARTED;
}
-void SND_FXSample::setLoopMode( int loopMode )
+void SND_FXSample::stop(void)
{
+ mPlayState = SND_FXSample::STOPPED;
}
-void SND_FXSample::setLoopStart( int frameNum )
+void SND_FXSample::pause(void)
{
+ mPlayState = SND_FXSample::PAUSED;
}
-void SND_FXSample::setLoopEnd( int frameNum )
+SND_FXSample::PlayDirection SND_FXSample::getPlayDirection(void)
{
+ return mPlayDirection;
}
-void SND_FXSample::setGain( float gain )
+void SND_FXSample::setPlayDirection( PlayDirection playDirection )
{
- mGain = gain;
+ mPlayDirection = playDirection;
}
+SND_FXSample::LoopMode SND_FXSample::getLoopMode(void)
+{
+ return mLoopMode;
+}
+
+void SND_FXSample::setLoopMode( LoopMode loopMode )
+{
+ mLoopMode = loopMode;
+}
+
+int SND_FXSample::getLoopStartFrame(void)
+{
+ return mLoopStartFrame;
+}
+
+void SND_FXSample::setLoopStartFrame( int frameNum )
+{
+ mLoopStartFrame = frameNum;
+}
+
+int SND_FXSample::getLoopEndFrame(void)
+{
+ return mLoopEndFrame;
+}
+
+void SND_FXSample::setLoopEndFrame( int frameNum )
+{
+ mLoopEndFrame = frameNum;
+}
+
float SND_FXSample::getGain(void)
{
- return mGain;
+ return mGain;
}
+
+void SND_FXSample::setGain( float gain )
+{
+ mGain = gain;
+}
+bool SND_FXSample::isMuted(void)
+{
+ return mIsMuted;
+}
+
+void SND_FXSample::setMute( bool isMuted )
+{
+ mIsMuted = isMuted;
+}
+
int SND_FXSample::getNumFrames(void)
{
assert( mDataProvider != 0 );
@@ -95,42 +147,16 @@
return mDataProvider->getBitRate();
}
-void SND_FXSample::seek( int frameNum )
+int SND_FXSample::getCurrentFrameNumber(void)
{
- mFrameCounter = frameNum;
+ return mFrameCounter;
}
-SND_FXSample::PlayState SND_FXSample::getPlayState(void)
+void SND_FXSample::seek( int frameNum )
{
- return mPlayState;
+ mFrameCounter = frameNum;
}
-SND_FXSample::PlayDirection SND_FXSample::getPlayDirection(void)
-{
- return mPlayDirection;
-}
-
-void SND_FXSample::setPlayDirection( PlayDirection playDirection )
-{
- mPlayDirection = playDirection;
-}
-
-void SND_FXSample::play(void)
-{
- mFrameCounter = 0;
- mPlayState = SND_FXSample::STARTED;
-}
-
-void SND_FXSample::stop(void)
-{
- mPlayState = SND_FXSample::STOPPED;
-}
-
-void SND_FXSample::pause(void)
-{
- mPlayState = SND_FXSample::PAUSED;
-}
-
bool SND_FXSample::isDataAvailable(void)
{
return !mIsMuted && mGain!=0.0 && mPlayState==SND_FXSample::STARTED;
@@ -139,6 +165,11 @@
// we can request sound data. do not request big part, only few kilobytes are recommended
float* SND_FXSample::getPCMDataPtr( int framesNum )
{
+ // check if the wave buffer has enough data, load if it doesn't
+ // check if do we need use the mix buffer, return the data pointer if ok
+ // check if is the mix buffer large enough, reallocate if it isnt
+ // do mixing, looping, gaining
+
// !!! NOT HANDLES YET: framesNum > mSourceBufferSize
float *res = &mSourceBuffer[mFrameCounter];
// Not final code, it's just for fun
More information about the Bf-blender-cvs
mailing list