[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38730] branches/soc-2011-pepper: 3D Audio GSoC:

Joerg Mueller nexyon at gmail.com
Tue Jul 26 15:56:31 CEST 2011


Revision: 38730
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38730
Author:   nexyon
Date:     2011-07-26 13:56:31 +0000 (Tue, 26 Jul 2011)
Log Message:
-----------
3D Audio GSoC:
Main: Complete rewrite of the sequencer related audio code to support 3D Audio objects later and especially adressing the animation system problems (see mailing list if interested).
Note: Animation is not working yet, so with this commit volume animation doesn't work anymore, that's the next step.

Minor things:
* Changed AUD_Reference behaviour a little to be more usage safe.
* Fixed bug in AUD_I3DHandle: Missing virtual destructor
* Fixed enmus in AUD_Space.h
* Fixed a warning in rna_scene.c
* Removed an unneeded call in rna_sound.c

Modified Paths:
--------------
    branches/soc-2011-pepper/intern/audaspace/CMakeLists.txt
    branches/soc-2011-pepper/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
    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_I3DHandle.h
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_IHandle.h
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_NULLDevice.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_ReadDevice.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_ReadDevice.h
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_Reference.h
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerFactory.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerFactory.h
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerReader.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerReader.h
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SoftwareDevice.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_SoftwareDevice.h
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_Space.h
    branches/soc-2011-pepper/source/blender/blenkernel/BKE_sequencer.h
    branches/soc-2011-pepper/source/blender/blenkernel/BKE_sound.h
    branches/soc-2011-pepper/source/blender/blenkernel/intern/sequencer.c
    branches/soc-2011-pepper/source/blender/blenkernel/intern/sound.c
    branches/soc-2011-pepper/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_scene.c
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_sequencer.c
    branches/soc-2011-pepper/source/blender/makesrna/intern/rna_sound.c

Added Paths:
-----------
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_AnimateableProperty.cpp
    branches/soc-2011-pepper/intern/audaspace/intern/AUD_AnimateableProperty.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_SequencerHandle.h

Modified: branches/soc-2011-pepper/intern/audaspace/CMakeLists.txt
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/CMakeLists.txt	2011-07-26 13:56:16 UTC (rev 38729)
+++ branches/soc-2011-pepper/intern/audaspace/CMakeLists.txt	2011-07-26 13:56:31 UTC (rev 38730)
@@ -68,6 +68,8 @@
 	FX/AUD_SuperposeReader.cpp
 	FX/AUD_VolumeFactory.cpp
 	intern/AUD_3DMath.h
+	intern/AUD_AnimateableProperty.cpp
+	intern/AUD_AnimateableProperty.h
 	intern/AUD_Buffer.cpp
 	intern/AUD_Buffer.h
 	intern/AUD_BufferReader.cpp
@@ -109,8 +111,12 @@
 	intern/AUD_ReferenceHandler.cpp
 	intern/AUD_ResampleReader.cpp
 	intern/AUD_ResampleReader.h
+	intern/AUD_SequencerEntry.cpp
+	intern/AUD_SequencerEntry.h
 	intern/AUD_SequencerFactory.cpp
 	intern/AUD_SequencerFactory.h
+	intern/AUD_SequencerHandle.cpp
+	intern/AUD_SequencerHandle.h
 	intern/AUD_SequencerReader.cpp
 	intern/AUD_SequencerReader.h
 	intern/AUD_SilenceFactory.cpp

Modified: branches/soc-2011-pepper/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp	2011-07-26 13:56:16 UTC (rev 38729)
+++ branches/soc-2011-pepper/intern/audaspace/OpenAL/AUD_OpenALDevice.cpp	2011-07-26 13:56:31 UTC (rev 38730)
@@ -1168,7 +1168,7 @@
 
 	// check format
 	if(specs.channels == AUD_CHANNELS_INVALID)
-		return NULL;
+		return AUD_Reference<AUD_IHandle>();
 
 	if(m_specs.format != AUD_FORMAT_FLOAT32)
 		reader = new AUD_ConverterReader(reader, m_specs);
@@ -1176,7 +1176,7 @@
 	ALenum format;
 
 	if(!getFormat(format, specs))
-		return NULL;
+		return AUD_Reference<AUD_IHandle>();
 
 	lock();
 	alcSuspendContext(m_context);

Added: branches/soc-2011-pepper/intern/audaspace/intern/AUD_AnimateableProperty.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_AnimateableProperty.cpp	                        (rev 0)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_AnimateableProperty.cpp	2011-07-26 13:56:31 UTC (rev 38730)
@@ -0,0 +1,103 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2009-2011 Jörg Hermann Müller
+ *
+ * This file is part of AudaSpace.
+ *
+ * Audaspace 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.
+ *
+ * AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file audaspace/intern/AUD_AnimateableProperty.cpp
+ *  \ingroup audaspaceintern
+ */
+
+
+#include "AUD_AnimateableProperty.h"
+
+#include <cstring>
+
+AUD_AnimateableProperty::AUD_AnimateableProperty(int count) :
+	AUD_Buffer(count * sizeof(float)), m_count(count), m_isAnimated(false), m_changed(false)
+{
+	memset(getBuffer(), 0, count * sizeof(float));
+
+	pthread_mutexattr_t attr;
+	pthread_mutexattr_init(&attr);
+	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+
+	pthread_mutex_init(&m_mutex, &attr);
+
+	pthread_mutexattr_destroy(&attr);
+}
+
+AUD_AnimateableProperty::~AUD_AnimateableProperty()
+{
+	pthread_mutex_destroy(&m_mutex);
+}
+
+void AUD_AnimateableProperty::lock()
+{
+	pthread_mutex_lock(&m_mutex);
+}
+
+void AUD_AnimateableProperty::unlock()
+{
+	pthread_mutex_unlock(&m_mutex);
+}
+
+void AUD_AnimateableProperty::write(const float* data)
+{
+	lock();
+
+	m_isAnimated = false;
+	m_changed = true;
+	memcpy(getBuffer(), data, m_count * sizeof(float));
+
+	unlock();
+}
+
+void AUD_AnimateableProperty::write(const float* data, int position, int count)
+{
+	lock();
+
+	m_isAnimated = true;
+	m_changed = true;
+	assureSize((count + position) * m_count * sizeof(float), true);
+	memcpy(getBuffer() + position * m_count, data, count * m_count * sizeof(float));
+
+	unlock();
+}
+
+const float* AUD_AnimateableProperty::read(int position) const
+{
+	return getBuffer() + position * m_count;
+}
+
+bool AUD_AnimateableProperty::isAnimated() const
+{
+	return m_isAnimated;
+}
+
+bool AUD_AnimateableProperty::hasChanged()
+{
+	bool result = m_changed;
+	m_changed = false;
+	return result;
+}


Property changes on: branches/soc-2011-pepper/intern/audaspace/intern/AUD_AnimateableProperty.cpp
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Added: branches/soc-2011-pepper/intern/audaspace/intern/AUD_AnimateableProperty.h
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_AnimateableProperty.h	                        (rev 0)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_AnimateableProperty.h	2011-07-26 13:56:31 UTC (rev 38730)
@@ -0,0 +1,94 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * Copyright 2009-2011 Jörg Hermann Müller
+ *
+ * This file is part of AudaSpace.
+ *
+ * Audaspace 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.
+ *
+ * AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file audaspace/intern/AUD_AnimateableProperty.h
+ *  \ingroup audaspaceintern
+ */
+
+
+#ifndef AUD_ANIMATEABLEPROPERTY
+#define AUD_ANIMATEABLEPROPERTY
+
+#include "AUD_Buffer.h"
+
+#include <pthread.h>
+
+/**
+ * This class saves animation data for float properties.
+ */
+class AUD_AnimateableProperty : private AUD_Buffer
+{
+private:
+	/// The count of floats for a single property.
+	const int m_count;
+
+	/// Whether the property is animated or not.
+	bool m_isAnimated;
+
+	/// The mutex for locking.
+	pthread_mutex_t m_mutex;
+
+	/// Whether the property has been changed.
+	bool m_changed;
+
+	// hide copy constructor and operator=
+	AUD_AnimateableProperty(const AUD_AnimateableProperty&);
+	AUD_AnimateableProperty& operator=(const AUD_AnimateableProperty&);
+
+public:
+	/**
+	 * Creates a new animateable property.
+	 * \param count The count of floats for a single property.
+	 */
+	AUD_AnimateableProperty(int count = 1);
+
+	/**
+	 * Destroys the animateable property.
+	 */
+	~AUD_AnimateableProperty();
+
+	/**
+	 * Locks the property.
+	 */
+	void lock();
+
+	/**
+	 * Unlocks the previously locked property.
+	 */
+	void unlock();
+
+	void write(const float* data);
+
+	void write(const float* data, int position, int count);
+
+	const float* read(int position) const;
+
+	bool isAnimated() const;
+
+	bool hasChanged();
+};
+
+#endif //AUD_ANIMATEABLEPROPERTY


Property changes on: branches/soc-2011-pepper/intern/audaspace/intern/AUD_AnimateableProperty.h
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

Modified: branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp	2011-07-26 13:56:16 UTC (rev 38729)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp	2011-07-26 13:56:31 UTC (rev 38730)
@@ -65,6 +65,7 @@
 #include "AUD_ReadDevice.h"
 #include "AUD_IReader.h"
 #include "AUD_SequencerFactory.h"
+#include "AUD_SequencerEntry.h"
 #include "AUD_SilenceFactory.h"
 
 #ifdef WITH_SDL
@@ -112,7 +113,7 @@
 
 int AUD_init(AUD_DeviceType device, AUD_DeviceSpecs specs, int buffersize)
 {
-	AUD_Reference<AUD_IDevice> dev = NULL;
+	AUD_Reference<AUD_IDevice> dev;
 
 	if(!AUD_device.isNull())
 		AUD_exit();
@@ -156,7 +157,7 @@
 
 void AUD_exit()
 {
-	AUD_device = NULL;
+	AUD_device = AUD_Reference<AUD_IDevice>();
 	AUD_3ddevice = NULL;
 }
 
@@ -880,14 +881,14 @@
 	return NULL;
 }
 
-AUD_Sound* AUD_createSequencer(int muted, void* data, AUD_volumeFunction volume)
+AUD_Sound* AUD_createSequencer(float fps, int muted)
 {
 	// specs are changed at a later point!
 	AUD_Specs specs;
 	specs.channels = AUD_CHANNELS_STEREO;
 	specs.rate = AUD_RATE_44100;
-	AUD_Reference<AUD_SequencerFactory>* sequencer = new AUD_Reference<AUD_SequencerFactory>(new AUD_SequencerFactory(specs, muted, data, volume));
-	return reinterpret_cast<AUD_Sound*>(sequencer);
+	AUD_Sound* sequencer = new AUD_Sound(AUD_Reference<AUD_SequencerFactory>(new AUD_SequencerFactory(specs, fps, muted)));
+	return sequencer;
 }
 
 void AUD_destroySequencer(AUD_Sound* sequencer)
@@ -900,29 +901,43 @@
 	((AUD_SequencerFactory*)sequencer->get())->mute(muted);
 }
 
-AUD_Reference<AUD_SequencerEntry>* AUD_addSequencer(AUD_Sound* sequencer, AUD_Sound** sound,
-								 float begin, float end, float skip, void* data)
+void AUD_setSequencerFPS(AUD_Sound* sequencer, float fps)
 {
-	return new AUD_Reference<AUD_SequencerEntry>(((AUD_SequencerFactory*)sequencer->get())->add(sound, begin, end, skip, data));
+	((AUD_SequencerFactory*)sequencer->get())->setFPS(fps);
 }
 
-void AUD_removeSequencer(AUD_Sound* sequencer, AUD_Reference<AUD_SequencerEntry>* entry)
+AUD_SEntry* AUD_addSequence(AUD_Sound* sequencer, AUD_Sound* sound,
+							 float begin, float end, float skip)
 {
+	if(!sound)
+		return new AUD_SEntry(((AUD_SequencerFactory*)sequencer->get())->add(AUD_Sound(), begin, end, skip));
+	return new AUD_SEntry(((AUD_SequencerFactory*)sequencer->get())->add(*sound, begin, end, skip));
+}
+
+void AUD_removeSequence(AUD_Sound* sequencer, AUD_SEntry* entry)
+{
 	((AUD_SequencerFactory*)sequencer->get())->remove(*entry);
 	delete entry;
 }
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list