Revision: 22294
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22294
Author:   nexyon
Date:     2009-08-07 11:38:24 +0200 (Fri, 07 Aug 2009)

Log Message:
-----------
Sound Branch:
 * Added some documentation.
 * Fixed the loading of sounds from libraries.

Modified Paths:
--------------
    branches/soundsystem/intern/audaspace/intern/AUD_IDevice.h
    branches/soundsystem/source/blender/blenkernel/intern/sound.c
    branches/soundsystem/source/gameengine/Ketsji/KX_SoundActuator.cpp

Modified: branches/soundsystem/intern/audaspace/intern/AUD_IDevice.h
===================================================================
--- branches/soundsystem/intern/audaspace/intern/AUD_IDevice.h  2009-08-07 
05:35:48 UTC (rev 22293)
+++ branches/soundsystem/intern/audaspace/intern/AUD_IDevice.h  2009-08-07 
09:38:24 UTC (rev 22294)
@@ -86,7 +86,8 @@
        virtual bool resume(AUD_Handle* handle)=0;
 
        /**
-        * Stops a played back or paused sound.
+        * Stops a played back or paused sound. The handle is definitely invalid
+        * afterwards.
         * \param handle The handle returned by the play function.
         * \return
         *        - true if the sound has been stopped.

Modified: branches/soundsystem/source/blender/blenkernel/intern/sound.c
===================================================================
--- branches/soundsystem/source/blender/blenkernel/intern/sound.c       
2009-08-07 05:35:48 UTC (rev 22293)
+++ branches/soundsystem/source/blender/blenkernel/intern/sound.c       
2009-08-07 09:38:24 UTC (rev 22294)
@@ -192,14 +192,21 @@
                case SOUND_TYPE_FILE:
                {
                        char fullpath[FILE_MAX];
+                       char *path;
 
                        /* load sound */
                        PackedFile* pf = sound->packedfile;
 
                        /* dont modify soundact->sound->name, only change a 
copy */
                        BLI_strncpy(fullpath, sound->name, sizeof(fullpath));
-                       BLI_convertstringcode(fullpath, G.sce);
 
+                       if(sound->id.lib)
+                               path = sound->id.lib->filename;
+                       else
+                               path = G.sce;
+
+                       BLI_convertstringcode(fullpath, path);
+
                        /* but we need a packed file then */
                        if (pf)
                                sound->snd_sound = AUD_loadBuffer((unsigned 
char*) pf->data, pf->size);

Modified: branches/soundsystem/source/gameengine/Ketsji/KX_SoundActuator.cpp
===================================================================
--- branches/soundsystem/source/gameengine/Ketsji/KX_SoundActuator.cpp  
2009-08-07 05:35:48 UTC (rev 22293)
+++ branches/soundsystem/source/gameengine/Ketsji/KX_SoundActuator.cpp  
2009-08-07 09:38:24 UTC (rev 22294)
@@ -80,7 +80,9 @@
        if(!m_sound)
                return;
 
+       // this is the sound that will be played and not deleted afterwards
        AUD_Sound* sound = m_sound;
+       // this sounds are for temporary stacked sounds, will be deleted if not 
NULL
        AUD_Sound* sound2 = NULL;
        AUD_Sound* sound3 = NULL;
 
@@ -88,11 +90,14 @@
        {
        case KX_SOUNDACT_LOOPBIDIRECTIONAL:
        case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
+               // create a ping pong sound on sound2 stacked on the orignal 
sound
                sound2 = AUD_pingpongSound(sound);
+               // create a loop sound on sound3 stacked on the pingpong sound 
and let that one play (save it to sound)
                sound = sound3 = AUD_loopSound(sound2);
                break;
        case KX_SOUNDACT_LOOPEND:
        case KX_SOUNDACT_LOOPSTOP:
+               // create a loop sound on sound2 stacked on the pingpong sound 
and let that one play (save it to sound)
                sound = sound2 = AUD_loopSound(sound);
                break;
        case KX_SOUNDACT_PLAYSTOP:
@@ -103,6 +108,7 @@
 
        if(m_is3d)
        {
+               // sound shall be played 3D
                m_handle = AUD_play3D(sound, 0);
 
                AUD_set3DSourceSetting(m_handle, AUD_3DSS_MAX_GAIN, 
m_3d.max_gain);
@@ -121,6 +127,8 @@
        AUD_setSoundVolume(m_handle, m_volume);
        m_isplaying = true;
 
+       // now we unload the pingpong and loop sounds, as we don't need them 
anymore
+       // the started sound will continue playing like it was created, don't 
worry!
        if(sound3)
                AUD_unload(sound3);
        if(sound2)
@@ -169,16 +177,19 @@
                        case KX_SOUNDACT_LOOPSTOP:
                        case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
                                {
+                                       // stop immediately
                                        AUD_stop(m_handle);
                                        break;
                                }
                        case KX_SOUNDACT_PLAYEND:
                                {
+                                       // do nothing, sound will stop anyway 
when it's finished
                                        break;
                                }
                        case KX_SOUNDACT_LOOPEND:
                        case KX_SOUNDACT_LOOPBIDIRECTIONAL:
                                {
+                                       // stop the looping so that the sound 
stops when it finished
                                        AUD_stopLoop(m_handle);
                                        break;
                                }
@@ -217,6 +228,12 @@
                        
((KX_GameObject*)this->GetParent())->GetLinearVelocity().getValue(data.velocity);
                        
((KX_GameObject*)this->GetParent())->NodeGetWorldOrientation().getValue3x3(data.orientation);
 
+                       /*
+                        * The 3D data from blender has to be transformed for 
OpenAL:
+                        *  - In blender z is up and y is forwards
+                        *  - In OpenAL y is up and z is backwards
+                        * We have to do that for all 5 vectors.
+                        */
                        f = data.position[1];
                        data.position[1] = data.position[2];
                        data.position[2] = -f;


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

Reply via email to