[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11565] branches/soc-2007-hcube/intern/ tinySND: Added Duplicator class to make it possible to root sound data path to multiple targets .

Csaba Hruska csaba.hruska at gmail.com
Sun Aug 12 16:36:22 CEST 2007


Revision: 11565
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11565
Author:   hcube
Date:     2007-08-12 16:36:22 +0200 (Sun, 12 Aug 2007)

Log Message:
-----------
Added Duplicator class to make it possible to root sound data path to multiple targets.

Added Paths:
-----------
    branches/soc-2007-hcube/intern/tinySND/SND_FXDuplicator.h
    branches/soc-2007-hcube/intern/tinySND/intern/SND_FXDuplicator.cpp

Added: branches/soc-2007-hcube/intern/tinySND/SND_FXDuplicator.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_FXDuplicator.h	                        (rev 0)
+++ branches/soc-2007-hcube/intern/tinySND/SND_FXDuplicator.h	2007-08-12 14:36:22 UTC (rev 11565)
@@ -0,0 +1,36 @@
+#ifndef __SND_FXDUPLICATOR_H__
+#define __SND_FXDUPLICATOR_H__
+
+#include "SND_SoundInterface.h"
+
+class SND_FXDuplicator: public SND_SoundInterface
+{
+public:
+	SND_FXDuplicator();
+	~SND_FXDuplicator();
+
+	void setInput( SND_SoundInterface *input );
+	SND_SoundInterface *getInput();
+	
+	void setNumCopy( int numCopy );
+	int getNumCopy();
+	
+	bool isMuted();
+	void setMute( bool isMuted );
+
+	float getSampleRate();
+	bool isDataAvailable();
+	float* getPCMDataPtr( int framesNum );
+	
+private:
+	SND_SoundInterface	*mInput;
+	float				*mBuffer;
+	int					 mBufferSize;	// number of frames
+	bool				 mIsMuted;
+	float				 mSampleRate;
+	int					 mNumCopy;
+	int					 mCounter;
+};
+
+#endif //__SND_FXDUPLICATOR_H__
+

Added: branches/soc-2007-hcube/intern/tinySND/intern/SND_FXDuplicator.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/intern/SND_FXDuplicator.cpp	                        (rev 0)
+++ branches/soc-2007-hcube/intern/tinySND/intern/SND_FXDuplicator.cpp	2007-08-12 14:36:22 UTC (rev 11565)
@@ -0,0 +1,81 @@
+#include <assert.h>
+#include "SND_FXDuplicator.h"
+
+SND_FXDuplicator::SND_FXDuplicator()
+{
+	mNumCopy = 1;
+	mInput = 0;
+}
+
+SND_FXDuplicator::~SND_FXDuplicator()
+{
+}
+
+void SND_FXDuplicator::setInput( SND_SoundInterface *input )
+{
+	mInput = input;
+	mCounter = 0;
+	mBuffer = 0;
+	
+	if( mInput != 0 )
+	{
+		mSampleRate = mInput->getSampleRate();
+	}
+}
+
+SND_SoundInterface* SND_FXDuplicator::getInput(void)
+{
+	return mInput;
+}
+
+void SND_FXDuplicator::setNumCopy( int numCopy )
+{
+	mNumCopy = numCopy;
+}
+
+int SND_FXDuplicator::getNumCopy()
+{
+	return mNumCopy;
+}
+
+bool SND_FXDuplicator::isMuted(void)
+{
+	return mIsMuted;
+}
+
+void SND_FXDuplicator::setMute( bool isMuted )
+{
+	mIsMuted = isMuted;
+}
+
+float SND_FXDuplicator::getSampleRate(void)
+{
+	return mSampleRate;
+}
+
+bool SND_FXDuplicator::isDataAvailable(void)
+{
+	if( mIsMuted || mInput==0 )
+	{
+		return false;
+	}
+	
+	return mInput->isDataAvailable();
+}
+
+float* SND_FXDuplicator::getPCMDataPtr( int framesNum )
+{
+	assert( mBuffer == 0 || mBufferSize == framesNum );
+	
+	if( mCounter <= 0 )
+	{
+		mBuffer = mInput->getPCMDataPtr( framesNum );
+		mCounter = mNumCopy;
+		mBufferSize = framesNum;
+	}
+	
+	--mCounter;
+	
+	return mBuffer;
+}
+





More information about the Bf-blender-cvs mailing list