Revision: 15809
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15809
Author:   hcube
Date:     2008-07-27 18:18:27 +0200 (Sun, 27 Jul 2008)

Log Message:
-----------
added intern/soundsystem

Modified Paths:
--------------
    branches/sound-branch/extern/tinySND/core/SND_FXMixer.cpp
    branches/sound-branch/extern/tinySND/core/SND_FXMixer.h
    branches/sound-branch/extern/tinySND/core/SND_SoundInterface.h

Added Paths:
-----------
    branches/sound-branch/intern/soundsystem/
    branches/sound-branch/intern/soundsystem/Makefile
    branches/sound-branch/intern/soundsystem/SConscript
    branches/sound-branch/intern/soundsystem/SND_C-api.h
    branches/sound-branch/intern/soundsystem/SND_device.cpp
    branches/sound-branch/intern/soundsystem/SND_factory.cpp
    branches/sound-branch/intern/soundsystem/SND_file.cpp
    branches/sound-branch/intern/soundsystem/SND_general.cpp
    branches/sound-branch/intern/soundsystem/SND_internal.h
    branches/sound-branch/intern/soundsystem/SND_mixbuffer.cpp
    branches/sound-branch/intern/soundsystem/SND_sound.cpp
    branches/sound-branch/intern/soundsystem/SND_soundattrs.cpp
    branches/sound-branch/intern/soundsystem/SND_soundvisual.cpp
    branches/sound-branch/intern/soundsystem/readme

Modified: branches/sound-branch/extern/tinySND/core/SND_FXMixer.cpp
===================================================================
--- branches/sound-branch/extern/tinySND/core/SND_FXMixer.cpp   2008-07-27 
16:02:40 UTC (rev 15808)
+++ branches/sound-branch/extern/tinySND/core/SND_FXMixer.cpp   2008-07-27 
16:18:27 UTC (rev 15809)
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include <assert.h>
 #include "SND_FXMixer.h"
 #include "SND_Defines.h"
@@ -13,6 +12,7 @@
        mSampleRate = 0.0;
        mGain = 1.0;
        mIsMuted = false;
+       mIsClamped = false;
 
        // assign mix buffer
        mBuffer = new float[ SND_MIX_BUFFER_FRAMES ];
@@ -96,6 +96,16 @@
        mIsMuted = isMuted;
 }
 
+bool SND_FXMixer::isClamped(void)
+{
+       return mIsClamped;
+}
+
+void SND_FXMixer::setClamp( bool isClamped )
+{
+       mIsClamped = isClamped;
+}
+
 float SND_FXMixer::getSampleRate(void)
 {
        return mSampleRate;
@@ -123,6 +133,7 @@
        std::vector<SND_SoundInterface*>::const_iterator i;
        int sndNum, j, n;
        float mixFactor;
+       float data;
        float *buffer;
 
        // compressor effect is not implemented, maybe in the future
@@ -144,7 +155,7 @@
                }
        }
 
-       if( sndNum==1 && mGain==1.0 )
+       if( sndNum==1 && mGain==1.0 && mIsClamped==false )
        {
                // no mixing is needed, there is only one channel and gain is 
1.0
                return mSoundBuffers[ 0 ];
@@ -180,6 +191,23 @@
                        }
                }
        }
+
+       if( mIsClamped )
+       {
+               for( n = 0 ; n < framesNum ; ++n )
+               {
+                       data = mBuffer[ n ];
+                       if( data < -1.0 )
+                       {
+                               data = -1.0;
+                       }
+                       else if( data > 1.0 )
+                       {
+                               data = 1.0;
+                       }
+                       mBuffer[ n ] = data;
+               }
+       }
        return mBuffer;
 }
 

Modified: branches/sound-branch/extern/tinySND/core/SND_FXMixer.h
===================================================================
--- branches/sound-branch/extern/tinySND/core/SND_FXMixer.h     2008-07-27 
16:02:40 UTC (rev 15808)
+++ branches/sound-branch/extern/tinySND/core/SND_FXMixer.h     2008-07-27 
16:18:27 UTC (rev 15809)
@@ -23,6 +23,9 @@
        bool    isMuted();
        void    setMute( bool isMuted );
 
+       bool    isClamped();
+       void    setClamp( bool isClamped );
+
        float   getSampleRate();
        bool    isDataAvailable();
        float*  getPCMDataPtr( int framesNum );
@@ -35,6 +38,7 @@
        int             mBufferSize;    // number of frames
        float   mSampleRate;
        bool    mIsMuted;
+       bool    mIsClamped;
        float   mGain;
 };
 

Modified: branches/sound-branch/extern/tinySND/core/SND_SoundInterface.h
===================================================================
--- branches/sound-branch/extern/tinySND/core/SND_SoundInterface.h      
2008-07-27 16:02:40 UTC (rev 15808)
+++ branches/sound-branch/extern/tinySND/core/SND_SoundInterface.h      
2008-07-27 16:18:27 UTC (rev 15809)
@@ -14,6 +14,7 @@
        virtual bool    isDataAvailable() = 0;
 
        // we can request sound data. do not request big part, only few 
kilobytes are recommended
+       // All samples in tinySND are floats fitting [-1.0, 1.0] range.
        virtual float*  getPCMDataPtr( int framesNum ) = 0; // incremets frame 
counter according play state
        
        // calling callback before real work/mixing is done in getPCMDataPtr

Added: branches/sound-branch/intern/soundsystem/Makefile
===================================================================
--- branches/sound-branch/intern/soundsystem/Makefile                           
(rev 0)
+++ branches/sound-branch/intern/soundsystem/Makefile   2008-07-27 16:18:27 UTC 
(rev 15809)
@@ -0,0 +1,50 @@
+#
+# $Id: Makefile 2786 2004-07-13 11:42:13Z blendix $
+#
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License.  See http://www.blender.org/BL/ for information
+# about this.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+# opennl intern Makefile
+#
+
+LIBNAME = soundsystem
+DIR = $(OCGDIR)/$(LIBNAME)
+
+include nan_compile.mk
+
+CCFLAGS += $(NAN_LEVEL_2_CPP_WARNINGS)
+
+CPPFLAGS += -I../superlu -I$(BF_TINYSND)/include
+
+install: all debug
+       @[ -d $(NAN_SOUNDSYSTEM) ] || mkdir $(NAN_SOUNDSYSTEM)
+       @[ -d $(NAN_SOUNDSYSTEM)/include ] || mkdir $(NAN_SOUNDSYSTEM)/include
+       @[ -d $(NAN_SOUNDSYSTEM)/lib ] || mkdir $(NAN_SOUNDSYSTEM)/lib
+       @[ -d $(NAN_SOUNDSYSTEM)/lib/debug ] || mkdir 
$(NAN_SOUNDSYSTEM)/lib/debug
+       @../tools/cpifdiff.sh $(DIR)/libsoundsystem.a $(NAN_SOUNDSYSTEM)/lib
+       @../tools/cpifdiff.sh *.h $(NAN_SOUNDSYSTEM)/include
+

Added: branches/sound-branch/intern/soundsystem/SConscript
===================================================================
--- branches/sound-branch/intern/soundsystem/SConscript                         
(rev 0)
+++ branches/sound-branch/intern/soundsystem/SConscript 2008-07-27 16:18:27 UTC 
(rev 15809)
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+Import ('env')
+
+sources = env.Glob('./*.cpp')
+incs = '. '+ env['BF_TINYSND_INC']
+defs = ''
+
+if env['WITH_BF_SAMPLERATE']:
+    incs += ' samplerate ' + env['BF_SAMPLERATE_INC']
+    defs += ' WITH_SAMPLERATE'
+
+if env['WITH_BF_SDL']:
+    incs += ' sdl ' + env['BF_SDL_INC']
+    defs += ' WITH_SDL'
+
+if env['WITH_BF_PORTAUDIO']:
+    incs += ' portaudio ' + env['BF_PORTAUDIO_INC']
+    defs += ' WITH_PORTAUDIO'
+
+if env['WITH_BF_JACK']:
+    incs += ' jack ' + env['BF_JACK_INC']
+    defs += ' WITH_JACK'
+
+if env['WITH_BF_SNDFILE']:
+    incs += ' sndfile ' + env['BF_SNDFILE_INC']
+    defs += ' WITH_SNDFILE'
+
+if env['WITH_BF_FFMPEG']:
+    incs += ' ffmpeg ' + env['BF_FFMPEG_INC']
+    defs += ' WITH_FFMPEG'
+
+if env['WITH_BF_MAD']:
+    incs += ' mad ' + env['BF_MAD_INC']
+    defs += ' WITH_MAD'
+
+if env['WITH_BF_VORBIS']:
+    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] )

Added: branches/sound-branch/intern/soundsystem/SND_C-api.h
===================================================================
--- branches/sound-branch/intern/soundsystem/SND_C-api.h                        
        (rev 0)
+++ branches/sound-branch/intern/soundsystem/SND_C-api.h        2008-07-27 
16:18:27 UTC (rev 15809)
@@ -0,0 +1,108 @@
+#ifndef        SND_BLENDER_H
+#define SND_BLENDER_H
+
+#ifdef __cplusplus
+extern "C" { 
+#endif
+
+#define SND_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
+
+SND_DECLARE_HANDLE(SND_SoundIHandle);
+
+struct PackedFile;
+
+// Exclusive C API for Blender
+// goals: be simple
+
+typedef struct
+{
+       int             channelsNum;
+       int             framesNum;
+       int             bitRate;
+       float   frameRate;
+
+} SND_SoundInfo;
+
+typedef struct
+{
+       int             bufferSize;
+       int             channelsNum;
+       int             bitRate;
+       float   frameRate;
+
+} SND_DeviceInfo;
+
+typedef void SND_AudioCallbackFunction( int framesNum, void *userData1, void 
*userData2 );
+
+#ifndef SND_PLAYMODE
+#define SND_PLAYMODE
+typedef enum {
+       SND_FORWARD,
+       SND_BACKWARD
+} SND_PlayMode;
+#endif
+
+// general
+extern int             SND_IsInitialized(void);
+extern void            SND_Initialize( int useSoundDevice );
+extern void            SND_Finalize(void);
+extern void            SND_Enable(void);
+extern void            SND_Disable(void);
+
+extern int             SND_GetMixRate(void);
+
+extern void            SND_SetCallback( SND_AudioCallbackFunction 
*callbackFunction, unsigned int cbRateNum, void *userData1, void *userData2 );
+
+// audio device backend
+extern int             SND_GetNumDevices();
+extern char*   SND_GetDeviceName( int deviceIdx );
+extern void            SND_GetActiveDevice( int* deviceIdx, SND_DeviceInfo 
*info );
+extern void            SND_SetActiveDevice( int deviceIdx, SND_DeviceInfo 
*info );
+
+// file handling
+extern int             SND_FileOpenForWrite( char *filename, int sampleRate );
+extern void            SND_FileWriteFrames( int framesNum );
+extern void            SND_FileClose(void);
+
+// mixbuffer handling
+extern int             SND_MixBufferOpen( int sampleRate );
+extern void            SND_MixBufferFill( void *buffer, int framesNum );
+extern void            SND_MixBufferClose(void);
+
+// sound handling
+extern SND_SoundIHandle        SND_SoundNew( char *filename ); // hides 
various DataProvider backends
+extern void            SND_SoundDelete( SND_SoundIHandle soundHandle );
+
+extern SND_PlayMode            SND_SoundGetPlayDirection( SND_SoundIHandle 
soundHandle );
+extern void            SND_SoundSetPlayDirection( SND_SoundIHandle 
soundHandle, SND_PlayMode mode );
+
+extern int             SND_SoundIsPlaying( SND_SoundIHandle soundHandle );
+extern void            SND_SoundPlay( SND_SoundIHandle soundHandle );
+extern void            SND_SoundStop( SND_SoundIHandle soundHandle );
+
+extern void            SND_SoundSeek( SND_SoundIHandle soundHandle, int 
frameNum );
+extern int             SND_SoundGetFramePos( SND_SoundIHandle soundHandle );
+
+// sound attributes
+extern float   SND_SoundGetGain( SND_SoundIHandle soundHandle );
+extern void            SND_SoundSetGain( SND_SoundIHandle soundHandle, float 
gain );
+
+extern float   SND_SoundGetPan( SND_SoundIHandle soundHandle );
+extern void            SND_SoundSetPan( SND_SoundIHandle soundHandle, float 
pan );
+
+extern int             SND_SoundIsMuted( SND_SoundIHandle soundHandle );
+extern void            SND_SoundSetMute( SND_SoundIHandle soundHandle, int 
mute );
+
+
+extern void            SND_SoundGetInfo( SND_SoundIHandle soundHandle, 
SND_SoundInfo *sndInfo );
+
+extern char*   SND_SoundGetVisualPCMData( SND_SoundIHandle soundHandle );
+
+extern void            SND_SoundStopAll(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+

Added: branches/sound-branch/intern/soundsystem/SND_device.cpp
===================================================================
--- branches/sound-branch/intern/soundsystem/SND_device.cpp                     
        (rev 0)
+++ branches/sound-branch/intern/soundsystem/SND_device.cpp     2008-07-27 
16:18:27 UTC (rev 15809)
@@ -0,0 +1,33 @@
+#include "SND_internal.h"
+
+int SND_GetNumDevices()
+{
+       return gSndCfg.mDevices.size();
+}
+

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to