Revision: 38977
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38977
Author:   nexyon
Date:     2011-08-03 09:25:40 +0000 (Wed, 03 Aug 2011)
Log Message:
-----------
3D Audio GSoC:

* Minor audaspace library improvements.
* Considering location, velocity and orientation in AUD_SequencerReader and 
AUD_SequencerHandle.
* Bugfix: Maximum and Minimum volume weren't used before in the software device.
* Bugfix: Adding speaker objects via info space crashed.
* Listener settings now get updated in the audio system.

Modified Paths:
--------------
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_3DMath.h
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.h
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerEntry.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerEntry.h
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerHandle.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerReader.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SoftwareDevice.cpp
    branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_info.py
    branches/soc-2011-pepper/source/blender/blenkernel/BKE_sound.h
    branches/soc-2011-pepper/source/blender/blenkernel/intern/sound.c
    branches/soc-2011-pepper/source/blender/editors/object/object_add.c
    branches/soc-2011-pepper/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_scene.c

Modified: branches/soc-2011-pepper/intern/audaspace/intern/AUD_3DMath.h
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_3DMath.h       
2011-08-03 09:25:34 UTC (rev 38976)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_3DMath.h       
2011-08-03 09:25:40 UTC (rev 38977)
@@ -102,6 +102,15 @@
         * Retrieves the components of the vector.
         * \return The components as float[3].
         */
+       inline float* get()
+       {
+               return m_v;
+       }
+
+       /**
+        * Retrieves the components of the vector.
+        * \return The components as float[3].
+        */
        inline const float* get() const
        {
                return m_v;
@@ -152,6 +161,14 @@
        {
                return AUD_Vector3(-m_x, -m_y, -m_z);
        }
+
+       inline AUD_Vector3& operator-=(const AUD_Vector3& op)
+       {
+               m_x -= op.m_x;
+               m_y -= op.m_y;
+               m_z -= op.m_z;
+               return *this;
+       }
 };
 
 class AUD_Quaternion
@@ -234,6 +251,15 @@
         * Retrieves the components of the vector.
         * \return The components as float[4].
         */
+       inline float* get()
+       {
+               return m_v;
+       }
+
+       /**
+        * Retrieves the components of the vector.
+        * \return The components as float[4].
+        */
        inline const float* get() const
        {
                return m_v;

Modified: branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp      
2011-08-03 09:25:34 UTC (rev 38976)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp      
2011-08-03 09:25:40 UTC (rev 38977)
@@ -39,6 +39,7 @@
 #include "AUD_PyAPI.h"
 #endif
 
+#include <set>
 #include <cstdlib>
 #include <cstring>
 #include <cmath>
@@ -898,12 +899,12 @@
 
 void AUD_setSequencerMuted(AUD_Sound* sequencer, int muted)
 {
-       ((AUD_SequencerFactory*)sequencer->get())->mute(muted);
+       dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->mute(muted);
 }
 
 void AUD_setSequencerFPS(AUD_Sound* sequencer, float fps)
 {
-       ((AUD_SequencerFactory*)sequencer->get())->setFPS(fps);
+       dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->setFPS(fps);
 }
 
 AUD_SEntry* AUD_addSequence(AUD_Sound* sequencer, AUD_Sound* sound,
@@ -916,7 +917,7 @@
 
 void AUD_removeSequence(AUD_Sound* sequencer, AUD_SEntry* entry)
 {
-       ((AUD_SequencerFactory*)sequencer->get())->remove(*entry);
+       dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->remove(*entry);
        delete entry;
 }
 
@@ -930,6 +931,11 @@
        (*entry)->mute(mute);
 }
 
+void AUD_setRelativeSequence(AUD_SEntry* entry, char relative)
+{
+       (*entry)->setRelative(relative);
+}
+
 void AUD_updateSequenceSound(AUD_SEntry* entry, AUD_Sound* sound)
 {
        if(sound)
@@ -949,21 +955,38 @@
 
 void AUD_setSequencerAnimData(AUD_Sound* sequencer, 
AUD_AnimateablePropertyType type, int frame, float* data, char animated)
 {
-       AUD_AnimateableProperty* prop = 
((AUD_SequencerFactory*)sequencer->get())->getAnimProperty(type);
+       AUD_AnimateableProperty* prop = 
dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->getAnimProperty(type);
        if(animated)
                prop->write(data, frame, 1);
        else
                prop->write(data);
 }
 
+void AUD_updateSequenceData(AUD_SEntry* entry, float volume_max, float 
volume_min,
+                                                       float distance_max, 
float distance_reference, float attenuation,
+                                                       float cone_angle_outer, 
float cone_angle_inner, float cone_volume_outer)
+{
+       (*entry)->updateAll(volume_max, volume_min, distance_max, 
distance_reference, attenuation,
+                                               cone_angle_outer, 
cone_angle_inner, cone_volume_outer);
+}
+
+void AUD_updateSequencerData(AUD_Sound* sequencer, float speed_of_sound,
+                                                        float factor, 
AUD_DistanceModel model)
+{
+       AUD_SequencerFactory* f = 
dynamic_cast<AUD_SequencerFactory*>(sequencer->get());
+       f->setSpeedOfSound(speed_of_sound);
+       f->setDopplerFactor(factor);
+       f->setDistanceModel(model);
+}
+
 void AUD_setSequencerDeviceSpecs(AUD_Sound* sequencer)
 {
-       
((AUD_SequencerFactory*)sequencer->get())->setSpecs(AUD_device->getSpecs().specs);
+       
dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->setSpecs(AUD_device->getSpecs().specs);
 }
 
 void AUD_setSequencerSpecs(AUD_Sound* sequencer, AUD_Specs specs)
 {
-       ((AUD_SequencerFactory*)sequencer->get())->setSpecs(specs);
+       dynamic_cast<AUD_SequencerFactory*>(sequencer->get())->setSpecs(specs);
 }
 
 void AUD_seekSequencer(AUD_Handle* handle, float time)
@@ -1090,3 +1113,43 @@
 {
        delete handle;
 }
+
+void* AUD_createSet()
+{
+       return new std::set<void*>();
+}
+
+void AUD_destroySet(void* set)
+{
+       delete reinterpret_cast<std::set<void*>*>(set);
+}
+
+char AUD_removeSet(void* set, void* entry)
+{
+       if(set)
+               return reinterpret_cast<std::set<void*>*>(set)->erase(entry);
+       return 0;
+}
+
+void AUD_addSet(void* set, void* entry)
+{
+       if(entry)
+               reinterpret_cast<std::set<void*>*>(set)->insert(entry);
+}
+
+void* AUD_getSet(void* set)
+{
+       if(set)
+       {
+               std::set<void*>* rset = reinterpret_cast<std::set<void*>*>(set);
+               if(!rset->empty())
+               {
+                       std::set<void*>::iterator it = rset->begin();
+                       void* result = *it;
+                       rset->erase(it);
+                       return result;
+               }
+       }
+
+       return NULL;
+}

Modified: branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.h
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.h        
2011-08-03 09:25:34 UTC (rev 38976)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.h        
2011-08-03 09:25:40 UTC (rev 38977)
@@ -469,12 +469,21 @@
 
 extern void AUD_muteSequence(AUD_SEntry* entry, char mute);
 
+extern void AUD_setRelativeSequence(AUD_SEntry* entry, char relative);
+
 extern void AUD_updateSequenceSound(AUD_SEntry* entry, AUD_Sound* sound);
 
 extern void AUD_setSequenceAnimData(AUD_SEntry* entry, 
AUD_AnimateablePropertyType type, int frame, float* data, char animated);
 
 extern void AUD_setSequencerAnimData(AUD_Sound* sequencer, 
AUD_AnimateablePropertyType type, int frame, float* data, char animated);
 
+extern void AUD_updateSequenceData(AUD_SEntry* entry, float volume_max, float 
volume_min,
+                                                                  float 
distance_max, float distance_reference, float attenuation,
+                                                                  float 
cone_angle_outer, float cone_angle_inner, float cone_volume_outer);
+
+extern void AUD_updateSequencerData(AUD_Sound* sequencer, float speed_of_sound,
+                                                                       float 
factor, AUD_DistanceModel model);
+
 extern void AUD_setSequencerDeviceSpecs(AUD_Sound* sequencer);
 
 extern void AUD_setSequencerSpecs(AUD_Sound* sequencer, AUD_Specs specs);
@@ -499,6 +508,16 @@
 
 extern void AUD_freeHandle(AUD_Handle* channel);
 
+extern void* AUD_createSet();
+
+extern void AUD_destroySet(void* set);
+
+extern char AUD_removeSet(void* set, void* entry);
+
+extern void AUD_addSet(void* set, void* entry);
+
+extern void* AUD_getSet(void* set);
+
 #ifdef WITH_PYTHON
 extern PyObject* AUD_getPythonFactory(AUD_Sound* sound);
 

Modified: 
branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerEntry.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerEntry.cpp     
2011-08-03 09:25:34 UTC (rev 38976)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerEntry.cpp     
2011-08-03 09:25:40 UTC (rev 38977)
@@ -66,8 +66,11 @@
 
 void AUD_SequencerEntry::setSound(AUD_Reference<AUD_IFactory> sound)
 {
-       m_sound = sound;
-       m_sound_status++;
+       if(m_sound.get() != sound.get())
+       {
+               m_sound = sound;
+               m_sound_status++;
+       }
 }
 
 void AUD_SequencerEntry::move(float begin, float end, float skip)
@@ -110,6 +113,59 @@
        }
 }
 
+void AUD_SequencerEntry::updateAll(float volume_max, float volume_min, float 
distance_max,
+                                                                  float 
distance_reference, float attenuation, float cone_angle_outer,
+                                                                  float 
cone_angle_inner, float cone_volume_outer)
+{
+       if(volume_max != m_volume_max)
+       {
+               m_volume_max = volume_max;
+               m_status++;
+       }
+
+       if(volume_min != m_volume_min)
+       {
+               m_volume_min = volume_min;
+               m_status++;
+       }
+
+       if(distance_max != m_distance_max)
+       {
+               m_distance_max = distance_max;
+               m_status++;
+       }
+
+       if(distance_reference != m_distance_reference)
+       {
+               m_distance_reference = distance_reference;
+               m_status++;
+       }
+
+       if(attenuation != m_attenuation)
+       {
+               m_attenuation = attenuation;
+               m_status++;
+       }
+
+       if(cone_angle_outer != m_cone_angle_outer)
+       {
+               m_cone_angle_outer = cone_angle_outer;
+               m_status++;
+       }
+
+       if(cone_angle_inner != m_cone_angle_inner)
+       {
+               m_cone_angle_inner = cone_angle_inner;
+               m_status++;
+       }
+
+       if(cone_volume_outer != m_cone_volume_outer)
+       {
+               m_cone_volume_outer = cone_volume_outer;
+               m_status++;
+       }
+}
+
 bool AUD_SequencerEntry::isRelative()
 {
        return m_relative;
@@ -117,8 +173,11 @@
 
 void AUD_SequencerEntry::setRelative(bool relative)
 {
-       m_relative = relative;
-       m_status++;
+       if(m_relative != relative)
+       {
+               m_relative = relative;
+               m_status++;
+       }
 }
 
 float AUD_SequencerEntry::getVolumeMaximum()

Modified: branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerEntry.h
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerEntry.h       
2011-08-03 09:25:34 UTC (rev 38976)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerEntry.h       
2011-08-03 09:25:40 UTC (rev 38977)
@@ -78,6 +78,10 @@
 
        AUD_AnimateableProperty* getAnimProperty(AUD_AnimateablePropertyType 
type);
 
+       void updateAll(float volume_max, float volume_min, float distance_max,
+                                  float distance_reference, float attenuation, 
float cone_angle_outer,
+                                  float cone_angle_inner, float 
cone_volume_outer);
+
        /**
         * Checks whether the source location, velocity and orientation are 
relative
         * to the listener.

Modified: 
branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerHandle.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerHandle.cpp    
2011-08-03 09:25:34 UTC (rev 38976)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerHandle.cpp    
2011-08-03 09:25:40 UTC (rev 38977)
@@ -70,7 +70,7 @@
 {
        if(!m_handle.isNull())
        {
-               if(position >= m_entry->m_end)
+               if(position >= m_entry->m_end && m_entry->m_end >= 0)
                        m_handle->pause();
                else if(position >= m_entry->m_begin)
                        m_handle->resume();
@@ -120,8 +120,17 @@
                m_entry->m_panning.read(frame, &value);
                AUD_SoftwareDevice::setPanning(m_handle.get(), value);
 
-               // AUD_XXX: TODO: animation data
+               AUD_Vector3 v, v2;
+               AUD_Quaternion q;
 
+               m_entry->m_orientation.read(frame, q.get());
+               m_3dhandle->setSourceOrientation(q);

@@ 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