[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14029] branches/soc-2007-hcube: sound system improvements: working ffmpeg reader, factory api for reader/ witer/device backends, added device config api, added stop sample and stop all samples buttons to sound buttons.

Csaba Hruska csaba.hruska at gmail.com
Sun Mar 9 21:32:42 CET 2008


Revision: 14029
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14029
Author:   hcube
Date:     2008-03-09 21:32:42 +0100 (Sun, 09 Mar 2008)

Log Message:
-----------
sound system improvements: working ffmpeg reader, factory api for reader/witer/device backends, added device config api, added stop sample and stop all samples buttons to sound buttons.

Modified Paths:
--------------
    branches/soc-2007-hcube/intern/tinySND/SConscript
    branches/soc-2007-hcube/intern/tinySND/SND_AiffReader.h
    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_WavReader.h
    branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.h
    branches/soc-2007-hcube/intern/tinySND/ffmpeg/ffmpegReader.cpp
    branches/soc-2007-hcube/intern/tinySND/ffmpeg/ffmpegReader.h
    branches/soc-2007-hcube/intern/tinySND/intern/SND_AiffReader.cpp
    branches/soc-2007-hcube/intern/tinySND/intern/SND_WavReader.cpp
    branches/soc-2007-hcube/intern/tinySND/mad/madReader.cpp
    branches/soc-2007-hcube/intern/tinySND/mad/madReader.h
    branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.cpp
    branches/soc-2007-hcube/intern/tinySND/sdl/SDLDevice.h
    branches/soc-2007-hcube/intern/tinySND/sndfile/sndfileReader.cpp
    branches/soc-2007-hcube/intern/tinySND/sndfile/sndfileReader.h
    branches/soc-2007-hcube/intern/tinySND/vorbis/vorbisReader.cpp
    branches/soc-2007-hcube/intern/tinySND/vorbis/vorbisReader.h
    branches/soc-2007-hcube/source/blender/include/BAU_soundsystem.h
    branches/soc-2007-hcube/source/blender/include/butspace.h
    branches/soc-2007-hcube/source/blender/src/buttons_scene.c
    branches/soc-2007-hcube/source/blender/src/drawseq.c
    branches/soc-2007-hcube/source/blender/src/soundsystem.c

Added Paths:
-----------
    branches/soc-2007-hcube/intern/tinySND/blender/SND_device.cpp
    branches/soc-2007-hcube/intern/tinySND/blender/SND_factory.cpp
    branches/soc-2007-hcube/intern/tinySND/blender/SND_file.cpp
    branches/soc-2007-hcube/intern/tinySND/blender/SND_general.cpp
    branches/soc-2007-hcube/intern/tinySND/blender/SND_internal.h
    branches/soc-2007-hcube/intern/tinySND/blender/SND_mixbuffer.cpp
    branches/soc-2007-hcube/intern/tinySND/blender/SND_sound.cpp
    branches/soc-2007-hcube/intern/tinySND/blender/SND_soundattrs.cpp
    branches/soc-2007-hcube/intern/tinySND/blender/SND_soundvisual.cpp
    branches/soc-2007-hcube/intern/tinySND/wavpack/
    branches/soc-2007-hcube/intern/tinySND/wavpack/wavpackReader.cpp
    branches/soc-2007-hcube/intern/tinySND/wavpack/wavpackReader.h

Removed Paths:
-------------
    branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp

Modified: branches/soc-2007-hcube/intern/tinySND/SConscript
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SConscript	2008-03-09 20:25:57 UTC (rev 14028)
+++ branches/soc-2007-hcube/intern/tinySND/SConscript	2008-03-09 20:32:42 UTC (rev 14029)
@@ -41,4 +41,9 @@
     incs += ' vorbis ' + env['BF_VORBIS_INC']
     defs += ' WITH_VORBIS'
 
+#if env['WITH_BF_WAVPACK']:
+#    sources += env.Glob('wavpack/*.cpp')
+#    incs += ' vorbis ' + env['BF_WAVPACK_INC']
+#    defs += ' WITH_WAVPACK'
+
 env.BlenderLib ('bf_soundsystem', sources, Split(incs), Split(defs), libtype=['core','player'], priority = [90,50] )

Modified: branches/soc-2007-hcube/intern/tinySND/SND_AiffReader.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_AiffReader.h	2008-03-09 20:25:57 UTC (rev 14028)
+++ branches/soc-2007-hcube/intern/tinySND/SND_AiffReader.h	2008-03-09 20:32:42 UTC (rev 14029)
@@ -10,7 +10,7 @@
 			SND_AiffReader( char *data, int size );
 			~SND_AiffReader();
     
-	bool	isFormatSupported();
+	bool	initialize();
     
 	void	seek( int frameNum );
 	void	fillBuffer( float *buffer, int framesNum );    

Modified: branches/soc-2007-hcube/intern/tinySND/SND_DataProvider.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_DataProvider.h	2008-03-09 20:25:57 UTC (rev 14028)
+++ branches/soc-2007-hcube/intern/tinySND/SND_DataProvider.h	2008-03-09 20:32:42 UTC (rev 14029)
@@ -11,7 +11,7 @@
 	virtual			~SND_DataProvider() {}
     
 	// true if file loading is succed, false if there was an error
-	virtual bool	isFormatSupported() = 0;
+	virtual bool	initialize() = 0;
     
 	int				getNumFrames() const { return mNumFrames; }
 	float			getDuration() const { return mDuration; } // in sec
@@ -33,7 +33,6 @@
 	int		mBitRate;
 	float	mSampleRate;
 	int		mNumChannels;
-	int		mCurrentFrame;
 	bool	mIsSeekable;
 };
 

Modified: branches/soc-2007-hcube/intern/tinySND/SND_Defines.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_Defines.h	2008-03-09 20:25:57 UTC (rev 14028)
+++ branches/soc-2007-hcube/intern/tinySND/SND_Defines.h	2008-03-09 20:32:42 UTC (rev 14029)
@@ -39,12 +39,12 @@
 
 // these are frame counts
 // the final values
-#define SND_WAVE_BUFFER_FRAMES				(24*1024)
-#define SND_WAVE_BUFFER_STEP_FRAMES			(8*1024)
+//#define SND_WAVE_BUFFER_FRAMES				(24*1024)
+//#define SND_WAVE_BUFFER_STEP_FRAMES			(8*1024)
 
 // smaller values are good for testing
-//#define SND_WAVE_BUFFER_FRAMES				(12*1024)
-//#define SND_WAVE_BUFFER_STEP_FRAMES			(4*1024)
+#define SND_WAVE_BUFFER_FRAMES				(12*1024)
+#define SND_WAVE_BUFFER_STEP_FRAMES			(4*1024)
 
 #define SND_MIX_BUFFER_FRAMES				(16*1024)
 

Modified: branches/soc-2007-hcube/intern/tinySND/SND_WavReader.h
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/SND_WavReader.h	2008-03-09 20:25:57 UTC (rev 14028)
+++ branches/soc-2007-hcube/intern/tinySND/SND_WavReader.h	2008-03-09 20:32:42 UTC (rev 14029)
@@ -10,7 +10,7 @@
 			SND_WavReader( char *data, int size );
 			~SND_WavReader();
     
-	bool	isFormatSupported();
+	bool	initialize();
     
 	void	seek( int frameNum );
 	void	fillBuffer( float *buffer, int framesNum );    

Deleted: branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp
===================================================================
--- branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp	2008-03-09 20:25:57 UTC (rev 14028)
+++ branches/soc-2007-hcube/intern/tinySND/blender/SND_C-api.cpp	2008-03-09 20:32:42 UTC (rev 14029)
@@ -1,862 +0,0 @@
-#include <vector>
-#include <assert.h>
-#include <math.h>
-
-#include "SND_C-api.h"
-#include "SND_Device.h"
-#include "SND_NullDevice.h"
-#include "SND_FXSample.h"
-#include "SND_FXMixer.h"
-#include "SND_FXSRC.h"
-#include "SND_FXDuplicator.h"
-#include "SND_WavReader.h"
-#include "SND_AiffReader.h"
-
-#ifdef WITH_SDL
-#include "SDLDevice.h"
-#endif
-
-#ifdef WITH_PORTAUDIO
-#include "portaudioDevice.h"
-#endif
-
-#ifdef WITH_JACK
-#include "jackDevice.h"
-#endif
-
-#ifdef WITH_SNDFILE
-#include "sndfileReader.h"
-#include "sndfileWriter.h"
-#endif
-
-#ifdef WITH_FFMPEG
-#include "ffmpegReader.h"
-#endif
-
-#ifdef WITH_VORBIS
-#include "vorbisReader.h"
-#endif
-
-#ifdef WITH_MAD
-#include "madReader.h"
-#endif
-
-#ifdef WIN32
-#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
-#endif //WIN32
-
-class SND_Sound
-{
-public:
-
-	SND_DataProvider			*mDataProvider;
-	SND_DataCache				*mDataCache;
-	SND_FXDuplicator			*mDuplicator;
-	
-	SND_FXMixer					*mMixerLeft;
-	SND_FXMixer					*mMixerRight;
-
-	char						*mVisualWaveBuffer;
-	
-	std::vector<SND_FXSample*>	mSamples;
-	std::vector<SND_FXSRC*>		mSRCs;
-	
-	// sound attributes
-	float						mGain;	// in dB
-	float						mPan;	// -1.0 ... 1.0
-	bool						mIsMuted;
-};
-
-enum PlayTarget
-{
-	AUDIODEVICE_TARGET		= 0,
-	AUDIOFILE_TARGET		= 1,
-	AUDIOBUFFER_TARGET		= 2
-};
-
-static PlayTarget				gPlayTarget			= AUDIODEVICE_TARGET;
-static std::vector<SND_Sound*> 	gSounds;
-static SND_Device				*gDevice			= 0;
-static SND_DataMultiplexer		*gDataMultiplexer	= 0;
-static SND_FXMixer				*gFXMixerLeft		= 0;
-static SND_FXMixer				*gFXMixerRight		= 0;
-static SND_DataConsumer			*gFileWriter		= 0;
-
-static SND_DataMultiplexer		*gCommonDataMultiplexer	= 0;
-
-static SND_CallbackFunction		*gCallbackFunction	= 0;
-static void						*gCallbackUserData1	= 0;
-static void						*gCallbackUserData2	= 0;
-
-static int						gMixBufferSampleRate	= 0;
-
-// callback for blender audio system
-static void gAudioCallback_cb( int framesNum, void *userData1, void *userData2 )
-{
-	if( gCallbackFunction != 0 )
-	{
-		gCallbackFunction( framesNum, gCallbackUserData1, gCallbackUserData2 );
-	}
-}
-
-int SND_IsInitialized(void)
-{
-	return gDevice != 0;
-}
-
-void SND_Initialize( int useSoundDevice )
-{
-	assert( gDevice == 0 );
-
-	extern void do_init_ffmpeg();
-
-//	do_init_ffmpeg();
-
-	gFileWriter = 0;
-	gPlayTarget = AUDIODEVICE_TARGET;
-	gCallbackFunction = 0;
-	gCallbackUserData1 = 0;
-	gCallbackUserData2 = 0;
-
-	gDevice = 0;	
-
-	if( useSoundDevice )
-	{
-#ifdef WITH_SDL
-		if( gDevice == 0 )
-		{
-			gDevice = new SDLDevice();
-		}
-#endif
-
-#ifdef WITH_PORTAUDIO
-		if( gDevice == 0 )
-		{
-			gDevice = new portaudioDevice();
-		}
-#endif
-
-#ifdef WITH_JACK
-		if( gDevice == 0 )
-		{
-			gDevice = new jackDevice();
-		}
-#endif
-	}
-	
-	if( gDevice == 0 )
-	{
-		gDevice = new SND_NullDevice();
-	}
-	
-	gDevice->initialize();
-
-	gDataMultiplexer = new SND_DataMultiplexer();
-	gDataMultiplexer->setNumChannels( gDevice->getNumChannels() );
-	gDataMultiplexer->setSampleFormat( gDevice->getSampleFormat() );
-
-	// add callback for blender sound system
-	gDataMultiplexer->setCallback( gAudioCallback_cb );
-	
-	gSounds.clear();
-
-	gFXMixerLeft	= new SND_FXMixer();
-	gFXMixerRight	= new SND_FXMixer();
-	gDataMultiplexer->assignSoundToChannel( gFXMixerLeft, 0 );
-	gDataMultiplexer->assignSoundToChannel( gFXMixerRight, 1 );
-	
-	gCommonDataMultiplexer = new SND_DataMultiplexer();
-
-	gDevice->setInput( gDataMultiplexer );
-	gDevice->enable();
-}
-
-void SND_Finalize(void)
-{
-	assert( gDevice != 0 );
-
-	gDataMultiplexer->setCallback( 0 );
-	gDevice->finalize();
-	
-	delete gCommonDataMultiplexer;
-	delete gFXMixerLeft;
-	delete gFXMixerRight;
-	delete gDataMultiplexer;
-	delete gDevice;
-	
-	gDevice = 0;
-}
-
-void SND_Enable(void)
-{
-	assert( gDevice != 0 );
-
-	gDevice->enable();
-}
-
-void SND_Disable(void)
-{
-	assert( gDevice != 0 );
-
-	gDevice->disable();
-}
-
-int SND_GetMixRate(void)
-{
-	assert( gDevice != 0 );
-
-	if(	gPlayTarget == AUDIODEVICE_TARGET )
-	{
-		return (int)gDevice->getSampleRate();
-	}
-
-	if(	gPlayTarget == AUDIOFILE_TARGET )
-	{
-		assert( gFileWriter != 0 );
-		return (int)gFileWriter->getSampleRate();
-	}
-	
-	if(	gPlayTarget == AUDIOBUFFER_TARGET )
-	{
-		return gMixBufferSampleRate;
-	}
-	
-	return 0;
-}
-
-void SND_SetCallback( SND_AudioCallbackFunction *callbackFunction, void *userData1, void *userData2 )
-{
-	gCallbackFunction = (SND_CallbackFunction*)callbackFunction;
-	gCallbackUserData1 = userData1;
-	gCallbackUserData2 = userData2;
-}
-
-//file handling
-
-int SND_FileOpenForWrite( char *filename, int sampleRate )
-{
-	assert( gDevice != 0 );
-	assert( gPlayTarget == AUDIODEVICE_TARGET );
-	
-	gDevice->disable();
-
-#ifdef WITH_SNDFILE
-	gFileWriter = new sndfileWriter( filename );
-#else
-	// currently we have only one exporter backend
-	gDevice->enable();
-	return false;
-#endif	
-
-	gFileWriter->setInput( gDataMultiplexer );
-	
-	//setup parameters
-	gFileWriter->setSampleRate( sampleRate );
-	gFileWriter->setSampleFormat( SND_FORMAT_PCM_16 );
-	gFileWriter->setNumChannels( 2 );
-	
-	if( !gFileWriter->initialize() )
-	{
-		delete gFileWriter;
-		gFileWriter = 0;
-		
-		gDevice->enable();
-		return false;
-	}
-	
-	gPlayTarget = AUDIOFILE_TARGET;
-	
-	// setup sounds datamultiplexer format
-	gDataMultiplexer->setSampleFormat( gFileWriter->getSampleFormat() );
-	
-	// setup sounds samplerates
-	// setup sounds a good samplerate method
-	std::vector<SND_Sound*>::const_iterator i;
-	for( i = gSounds.begin() ; i != gSounds.end() ; ++i )
-	{
-		SND_Sound *sound = (*i);
-		for( std::vector<SND_FXSRC*>::iterator j = sound->mSRCs.begin() ; j != sound->mSRCs.end() ; ++j )
-		{
-			(*j)->setConverterType( SRC_SINC_BEST_QUALITY );
-			(*j)->setSampleRate( (float)sampleRate );
-		}
-	}
-	
-	return true;
-}
-
-void SND_FileWriteFrames( int framesNum )
-{
-	assert( gFileWriter != 0 );
-	assert( gPlayTarget == AUDIOFILE_TARGET );
-	
-	gFileWriter->consumeData( framesNum );
-}
-
-void SND_FileClose(void)
-{
-	assert( gDevice != 0 );
-	assert( gFileWriter != 0 );
-	assert( gPlayTarget == AUDIOFILE_TARGET );
-
-	// restore sounds samplerates
-	// restore sounds samplerate method
-	float sampleRate = gDevice->getSampleRate();
-	std::vector<SND_Sound*>::const_iterator i;
-	for( i = gSounds.begin() ; i != gSounds.end() ; ++i )
-	{
-		SND_Sound *sound = (*i);
-		for( std::vector<SND_FXSRC*>::iterator j = sound->mSRCs.begin() ; j != sound->mSRCs.end() ; ++j )
-		{
-			(*j)->setConverterType( SRC_LINEAR );
-			(*j)->setSampleRate( sampleRate );
-		}
-	}
-	
-	// restore datamultiplexer format
-	gDataMultiplexer->setSampleFormat( gDevice->getSampleFormat() );
-	
-	gFileWriter->finalize();
-	delete gFileWriter;
-	
-	gFileWriter = 0;
-	
-	gDevice->enable();

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list