[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39301] branches/soc-2011-pepper: 3D Audio GSoC:
Joerg Mueller
nexyon at gmail.com
Thu Aug 11 13:41:24 CEST 2011
Revision: 39301
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39301
Author: nexyon
Date: 2011-08-11 11:41:24 +0000 (Thu, 11 Aug 2011)
Log Message:
-----------
3D Audio GSoC:
Adding a mono flag to mixdown non-mono sounds for 3D audio.
* Added mono sound loading.
* Bugfix: AUD_COMPARE_SPECS usage was wrong.
* Bugfix: JOS resampler = instead of ==.
* Bugfix: Change of a sound should apply settings in AUD_SequencerHandle.
* Bugfix: Memory leak when canceling open sound operator.
Modified Paths:
--------------
branches/soc-2011-pepper/intern/audaspace/FX/AUD_DoubleReader.cpp
branches/soc-2011-pepper/intern/audaspace/FX/AUD_SuperposeReader.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_JOSResampleReader.cpp
branches/soc-2011-pepper/intern/audaspace/intern/AUD_ReadDevice.cpp
branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerHandle.cpp
branches/soc-2011-pepper/release/scripts/startup/bl_ui/properties_data_speaker.py
branches/soc-2011-pepper/source/blender/blenkernel/intern/sound.c
branches/soc-2011-pepper/source/blender/editors/sound/sound_ops.c
branches/soc-2011-pepper/source/blender/makesdna/DNA_sound_types.h
branches/soc-2011-pepper/source/blender/makesrna/intern/rna_sound.c
Modified: branches/soc-2011-pepper/intern/audaspace/FX/AUD_DoubleReader.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/FX/AUD_DoubleReader.cpp 2011-08-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/intern/audaspace/FX/AUD_DoubleReader.cpp 2011-08-11 11:41:24 UTC (rev 39301)
@@ -98,13 +98,13 @@
specs1 = m_reader1->getSpecs();
specs2 = m_reader2->getSpecs();
if(AUD_COMPARE_SPECS(specs1, specs2))
- length = len;
- else
{
int len2 = length - len;
m_reader2->read(len2, eos, buffer + specs1.channels * len);
length = len + len2;
}
+ else
+ length = len;
}
}
else
Modified: branches/soc-2011-pepper/intern/audaspace/FX/AUD_SuperposeReader.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/FX/AUD_SuperposeReader.cpp 2011-08-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/intern/audaspace/FX/AUD_SuperposeReader.cpp 2011-08-11 11:41:24 UTC (rev 39301)
@@ -81,7 +81,7 @@
{
AUD_Specs specs = m_reader1->getSpecs();
AUD_Specs s2 = m_reader2->getSpecs();
- if(AUD_COMPARE_SPECS(specs, s2))
+ if(!AUD_COMPARE_SPECS(specs, s2))
AUD_THROW(AUD_ERROR_SPECS, specs_error);
int samplesize = AUD_SAMPLE_SIZE(specs);
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-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.cpp 2011-08-11 11:41:24 UTC (rev 39301)
@@ -321,6 +321,24 @@
}
}
+AUD_Sound* AUD_monoSound(AUD_Sound* sound)
+{
+ assert(sound);
+
+ try
+ {
+ AUD_DeviceSpecs specs;
+ specs.channels = AUD_CHANNELS_MONO;
+ specs.rate = AUD_RATE_INVALID;
+ specs.format = AUD_FORMAT_INVALID;
+ return new AUD_Sound(new AUD_ChannelMapperFactory(*sound, specs));
+ }
+ catch(AUD_Exception&)
+ {
+ return NULL;
+ }
+}
+
AUD_Sound* AUD_delaySound(AUD_Sound* sound, float delay)
{
assert(sound);
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-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_C-API.h 2011-08-11 11:41:24 UTC (rev 39301)
@@ -123,6 +123,13 @@
extern AUD_Sound* AUD_bufferSound(AUD_Sound* sound);
/**
+ * Rechannels the sound to be mono.
+ * \param sound The sound to rechannel.
+ * \return The mono sound.
+ */
+extern AUD_Sound* AUD_monoSound(AUD_Sound* sound);
+
+/**
* Delays a sound.
* \param sound The sound to dealy.
* \param delay The delay in seconds.
Modified: branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReader.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReader.cpp 2011-08-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_JOSResampleReader.cpp 2011-08-11 11:41:24 UTC (rev 39301)
@@ -306,7 +306,7 @@
m_n = m_cache_valid;
}
- eos = eos && ((m_n == m_cache_valid) || (length = 0));
+ eos = eos && ((m_n == m_cache_valid) || (length == 0));
}
// kaiser windowed (beta = 10) sinc lowpass with a cutt-off of 0.9
Modified: branches/soc-2011-pepper/intern/audaspace/intern/AUD_ReadDevice.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_ReadDevice.cpp 2011-08-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_ReadDevice.cpp 2011-08-11 11:41:24 UTC (rev 39301)
@@ -70,7 +70,7 @@
void AUD_ReadDevice::changeSpecs(AUD_Specs specs)
{
- if(AUD_COMPARE_SPECS(specs, m_specs.specs))
+ if(!AUD_COMPARE_SPECS(specs, m_specs.specs))
setSpecs(specs);
}
Modified: branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerHandle.cpp
===================================================================
--- branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerHandle.cpp 2011-08-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/intern/audaspace/intern/AUD_SequencerHandle.cpp 2011-08-11 11:41:24 UTC (rev 39301)
@@ -88,6 +88,8 @@
}
m_sound_status = m_entry->m_sound_status;
+ m_pos_status--;
+ m_status--;
}
if(m_pos_status != m_entry->m_pos_status)
Modified: branches/soc-2011-pepper/release/scripts/startup/bl_ui/properties_data_speaker.py
===================================================================
--- branches/soc-2011-pepper/release/scripts/startup/bl_ui/properties_data_speaker.py 2011-08-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/release/scripts/startup/bl_ui/properties_data_speaker.py 2011-08-11 11:41:24 UTC (rev 39301)
@@ -63,7 +63,7 @@
split = layout.split(percentage=0.75)
- split.template_ID(speaker, "sound", open="sound.open")
+ split.template_ID(speaker, "sound", open="sound.open_mono")
split.prop(speaker, "muted")
split = layout.split()
Modified: branches/soc-2011-pepper/source/blender/blenkernel/intern/sound.c
===================================================================
--- branches/soc-2011-pepper/source/blender/blenkernel/intern/sound.c 2011-08-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/source/blender/blenkernel/intern/sound.c 2011-08-11 11:41:24 UTC (rev 39301)
@@ -349,6 +349,13 @@
break;
}
#endif
+ if(sound->flags & SOUND_FLAGS_MONO)
+ {
+ void* handle = AUD_monoSound(sound->handle);
+ AUD_unload(sound->handle);
+ sound->handle = handle;
+ }
+
if(sound->flags & SOUND_FLAGS_CACHING)
{
sound->cache = AUD_bufferSound(sound->handle);
Modified: branches/soc-2011-pepper/source/blender/editors/sound/sound_ops.c
===================================================================
--- branches/soc-2011-pepper/source/blender/editors/sound/sound_ops.c 2011-08-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/source/blender/editors/sound/sound_ops.c 2011-08-11 11:41:24 UTC (rev 39301)
@@ -79,6 +79,13 @@
/******************** open sound operator ********************/
+static int open_cancel(bContext *UNUSED(C), wmOperator *op)
+{
+ MEM_freeN(op->customdata);
+ op->customdata= NULL;
+ return OPERATOR_CANCELLED;
+}
+
static void open_init(bContext *C, wmOperator *op)
{
PropertyPointerRNA *pprop;
@@ -95,9 +102,10 @@
PropertyPointerRNA *pprop;
PointerRNA idptr;
AUD_SoundInfo info;
+ Main *bmain = CTX_data_main(C);
RNA_string_get(op->ptr, "filepath", path);
- sound = sound_new_file(CTX_data_main(C), path);
+ sound = sound_new_file(bmain, path);
if(!op->customdata)
open_init(C, op);
@@ -117,6 +125,11 @@
return OPERATOR_CANCELLED;
}
+ if(RNA_boolean_get(op->ptr, "mono")) {
+ sound->flags |= SOUND_FLAGS_MONO;
+ sound_load(bmain, sound);
+ }
+
if (RNA_boolean_get(op->ptr, "cache")) {
sound_cache(sound);
}
@@ -172,6 +185,7 @@
/* api callbacks */
ot->exec= open_exec;
ot->invoke= open_invoke;
+ ot->cancel= open_cancel;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -179,8 +193,30 @@
/* properties */
WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH);
RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory.");
+ RNA_def_boolean(ot->srna, "mono", FALSE, "Mono", "Mixdown the sound to mono.");
}
+void SOUND_OT_open_mono(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Open Sound Mono";
+ ot->description= "Load a sound file as mono";
+ ot->idname= "SOUND_OT_open_mono";
+
+ /* api callbacks */
+ ot->exec= open_exec;
+ ot->invoke= open_invoke;
+ ot->cancel= open_cancel;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH);
+ RNA_def_boolean(ot->srna, "cache", FALSE, "Cache", "Cache the sound in memory.");
+ RNA_def_boolean(ot->srna, "mono", TRUE, "Mono", "Mixdown the sound to mono.");
+}
+
/******************** mixdown operator ********************/
static int mixdown_exec(bContext *C, wmOperator *op)
@@ -667,6 +703,7 @@
void ED_operatortypes_sound(void)
{
WM_operatortype_append(SOUND_OT_open);
+ WM_operatortype_append(SOUND_OT_open_mono);
WM_operatortype_append(SOUND_OT_mixdown);
WM_operatortype_append(SOUND_OT_pack);
WM_operatortype_append(SOUND_OT_unpack);
Modified: branches/soc-2011-pepper/source/blender/makesdna/DNA_sound_types.h
===================================================================
--- branches/soc-2011-pepper/source/blender/makesdna/DNA_sound_types.h 2011-08-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/source/blender/makesdna/DNA_sound_types.h 2011-08-11 11:41:24 UTC (rev 39301)
@@ -113,6 +113,7 @@
#define SOUND_FLAGS_3D (1 << 3) /* deprecated! used for sound actuator loading */
#define SOUND_FLAGS_CACHING (1 << 4)
+#define SOUND_FLAGS_MONO (1 << 5)
/* to DNA_sound_types.h*/
Modified: branches/soc-2011-pepper/source/blender/makesrna/intern/rna_sound.c
===================================================================
--- branches/soc-2011-pepper/source/blender/makesrna/intern/rna_sound.c 2011-08-11 09:40:14 UTC (rev 39300)
+++ branches/soc-2011-pepper/source/blender/makesrna/intern/rna_sound.c 2011-08-11 11:41:24 UTC (rev 39301)
@@ -41,7 +41,7 @@
#include "BKE_sound.h"
#include "BKE_context.h"
-static void rna_Sound_filepath_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
+static void rna_Sound_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
sound_load(bmain, (bSound*)ptr->data);
}
@@ -83,7 +83,7 @@
prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
RNA_def_property_string_sdna(prop, NULL, "name");
RNA_def_property_ui_text(prop, "File Path", "Sound sample file used by this Sound datablock");
- RNA_def_property_update(prop, 0, "rna_Sound_filepath_update");
+ RNA_def_property_update(prop, 0, "rna_Sound_update");
prop= RNA_def_property(srna, "packed_file", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "packedfile");
@@ -93,6 +93,11 @@
RNA_def_property_boolean_funcs(prop, "rna_Sound_caching_get", "rna_Sound_caching_set");
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list