== Sequencer ==
authorPeter Schlaile <peter@schlaile.de>
Sun, 30 May 2010 21:17:59 +0000 (21:17 +0000)
committerPeter Schlaile <peter@schlaile.de>
Sun, 30 May 2010 21:17:59 +0000 (21:17 +0000)
This makes volume range larger and adds an additional attenuation-variable to RNA,
which makes volume-changes in dezibel units possible.

release/scripts/ui/space_sequencer.py
source/blender/makesrna/intern/rna_sequencer.c

index c3f056b13945454a6df405767eb5561302b227d0..b94acf6f3ad4e88386c967b3fc9e4093a8d1f2e8 100644 (file)
@@ -457,7 +457,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel):
             row = layout.row(align=True)
             sub = row.row()
             sub.scale_x = 2.0
-           
+          
             if not context.screen.animation_playing:
                 sub.operator("screen.animation_play", text="", icon='PLAY')
             else:
@@ -666,6 +666,7 @@ class SEQUENCER_PT_sound(SequencerButtonsPanel):
         row.prop(strip.sound, "caching")
 
         layout.prop(strip, "volume")
+        layout.prop(strip, "attenuation")
 
         col = layout.column(align=True)
         col.label(text="Trim Duration:")
index bbcc1f8282613b794927c5658691b98a69d85fb5..f1f4a252c16b7938d989729d52737f928ba7079d 100644 (file)
 #include "MEM_guardedalloc.h"
 
 #include "WM_types.h"
+#include "BLI_math.h"
 
 #ifdef RNA_RUNTIME
 
+static float to_dB(float x)
+{
+       return logf(x * x + 1e-30f) * 4.34294480f;
+}
+
+static float from_dB(float x)
+{
+       return expf(x * 0.11512925f);
+}
+
 /* build a temp referene to the parent */
 static void meta_tmp_ref(Sequence *seq_par, Sequence *seq)
 {
@@ -393,6 +404,20 @@ static int rna_Sequence_proxy_filepath_length(PointerRNA *ptr)
        return strlen(path)+1;
 }
 
+static float rna_Sequence_attenuation_get(PointerRNA *ptr)
+{
+       Sequence *seq= (Sequence*)(ptr->data);
+
+       return to_dB(seq->volume);
+}
+
+static void rna_Sequence_attenuation_set(PointerRNA *ptr, float value)
+{
+       Sequence *seq= (Sequence*)(ptr->data);
+
+       seq->volume = from_dB(value);
+}
+
 
 /*static void rna_SoundSequence_filename_set(PointerRNA *ptr, const char *value)
 {
@@ -1045,10 +1070,17 @@ static void rna_def_sound(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "volume", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "volume");
-       RNA_def_property_range(prop, 0.0f, 2.0f);
+       RNA_def_property_range(prop, 0.0f, 100.0f);
        RNA_def_property_ui_text(prop, "Volume", "Playback volume of the sound");
        RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
 
+       prop= RNA_def_property(srna, "attenuation", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_range(prop, -100.0f, +40.0f);
+       RNA_def_property_ui_text(prop, "Attenuation/db", "Attenuation in dezibel");
+       RNA_def_property_float_funcs(prop, "rna_Sequence_attenuation_get", "rna_Sequence_attenuation_set", NULL); 
+
+       RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
+
        prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
        RNA_def_property_ui_text(prop, "File", "");
        RNA_def_property_string_funcs(prop, "rna_Sequence_filepath_get", "rna_Sequence_filepath_length",