Sound:
authorJoerg Mueller <nexyon@gmail.com>
Sun, 20 Sep 2009 17:55:03 +0000 (17:55 +0000)
committerJoerg Mueller <nexyon@gmail.com>
Sun, 20 Sep 2009 17:55:03 +0000 (17:55 +0000)
* Fixed mixdown volume being int instead of float
* Fixed audio muting for sequencer not working
* Added 3D listener settings with RNA (not working in GE yet)

source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/sound.c
source/blender/blenloader/intern/readfile.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_scene.c

index a9d7caaf5e0e9ee46fae4a0616ba29d1ce479e70..4de9ff3b6d92183fc9b3de72d3ec9022c7a03601 100644 (file)
@@ -421,6 +421,10 @@ Scene *add_scene(char *name)
        sce->jumpframe = 10;
        sce->r.ffcodecdata.audio_mixrate = 44100;
 
+       sce->audio.distance_model = 2.0;
+       sce->audio.doppler_factor = 1.0;
+       sce->audio.speed_of_sound = 343.3;
+
        strcpy(sce->r.backbuf, "//backbuf");
        strcpy(sce->r.pic, U.renderdir);
 
index fdf6283925ec216e6fcb906a503359f0875c78b7..c6c4a776faf1284700dbc24f1cb0d746bf8a5bae 100644 (file)
@@ -340,7 +340,7 @@ void sound_update_playing(struct bContext *C)
 
        for(handle = scene->sound_handles.first; handle; handle = handle->next)
        {
-               if(cfra < handle->startframe || cfra >= handle->endframe || handle->mute)
+               if(cfra < handle->startframe || cfra >= handle->endframe || handle->mute || (scene->audio.flag & AUDIO_MUTE))
                {
                        if(handle->state == AUD_STATUS_PLAYING)
                        {
index 2d612cffc7d3be1bdbcd594f35c2efc5ca94b928..78949d8bd8c764473b175b319e15baefd30caf1a 100644 (file)
@@ -9352,13 +9352,6 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                 */
                //do_versions_ipos_to_animato(main);
                
-               /* toolsettings */
-               for(scene= main->scene.first; scene; scene= scene->id.next)
-               {
-                       scene->r.ffcodecdata.audio_mixrate = scene->audio.mixrate;
-                       scene->r.ffcodecdata.audio_volume = scene->audio.main;
-               }
-               
                /* shader, composit and texture node trees have id.name empty, put something in
                 * to have them show in RNA viewer and accessible otherwise.
                 */
@@ -9714,6 +9707,18 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                }
                        }
                }
+
+               for(sce= main->scene.first; sce; sce= sce->id.next)
+               {
+                       if(sce->audio.main == 0.0)
+                               sce->audio.main = 1.0;
+
+                       sce->r.ffcodecdata.audio_mixrate = sce->audio.mixrate;
+                       sce->r.ffcodecdata.audio_volume = sce->audio.main;
+                       sce->audio.distance_model = 2.0;
+                       sce->audio.doppler_factor = 1.0;
+                       sce->audio.speed_of_sound = 343.3;
+               }
        }
 
        /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
index b41cd79b6d416c06b0f1cb6671a74c3a9c26dde9..5521f0e93155b385e4f19b110468231a623e6736 100644 (file)
@@ -94,7 +94,7 @@ typedef struct FFMpegCodecData {
        int video_bitrate;
        int audio_bitrate;
        int audio_mixrate;
-       int audio_volume;
+       float audio_volume;
        int gop_size;
        int flags;
 
@@ -110,8 +110,11 @@ typedef struct FFMpegCodecData {
 typedef struct AudioData {
        int mixrate; // 2.5: now in FFMpegCodecData: audio_mixrate
        float main; // 2.5: now in FFMpegCodecData: audio_volume
+       float speed_of_sound;
+       float doppler_factor;
+       int distance_model;
        short flag;
-       short pad[3];
+       short pad;
 } AudioData;
 
 typedef struct SceneRenderLayer {
index d6991a3a624bea5197cd3a9d3743d495156dcc64..ff8102a3111e74e4de4b2a6cd5b17d69c0b0924f 100644 (file)
@@ -1516,7 +1516,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
        prop= RNA_def_property(srna, "ffmpeg_audio_mixrate", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "ffcodecdata.audio_mixrate");
        RNA_def_property_range(prop, 8000, 192000);
-       RNA_def_property_ui_text(prop, "Sample", "Audio samplerate(samples/s)");
+       RNA_def_property_ui_text(prop, "Samplerate", "Audio samplerate(samples/s)");
        RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
 
        prop= RNA_def_property(srna, "ffmpeg_audio_volume", PROP_FLOAT, PROP_NONE);
@@ -1915,6 +1915,16 @@ void RNA_def_scene(BlenderRNA *brna)
        PropertyRNA *prop;
        FunctionRNA *func;
        
+       static EnumPropertyItem audio_distance_model_items[] = {
+               {0, "NONE", 0, "None", "No distance attenuation."},
+               {1, "INVERSE", 0, "Inverse", "Inverse distance model."},
+               {2, "INVERSE_CLAMPED", 0, "Inverse Clamped", "Inverse distance model with clamping."},
+               {3, "LINEAR", 0, "Linear", "Linear distance model."},
+               {4, "LINEAR_CLAMPED", 0, "Linear Clamped", "Linear distance model with clamping."},
+               {5, "EXPONENT", 0, "Exponent", "Exponent distance model."},
+               {6, "EXPONENT_CLAMPED", 0, "Exponent Clamped", "Exponent distance model with clamping."},
+               {0, NULL, 0, NULL, NULL}};
+
        /* Struct definition */
        srna= RNA_def_struct(brna, "Scene", "ID");
        RNA_def_struct_ui_text(srna, "Scene", "Scene consisting objects and defining time and render related settings.");
@@ -2074,17 +2084,35 @@ void RNA_def_scene(BlenderRNA *brna)
        /* Audio Settings */
        prop= RNA_def_property(srna, "mute_audio", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "audio.flag", AUDIO_MUTE);
-       RNA_def_property_ui_text(prop, "Mute Audio", "Play back of audio from Sequence Editor will be muted.");
+       RNA_def_property_ui_text(prop, "Audio Muted", "Play back of audio from Sequence Editor will be muted.");
        RNA_def_property_update(prop, NC_SCENE, NULL);
 
        prop= RNA_def_property(srna, "sync_audio", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "audio.flag", AUDIO_SYNC);
-       RNA_def_property_ui_text(prop, "Sync Audio", "Play back and sync with audio from Sequence Editor.");
+       RNA_def_property_ui_text(prop, "Audio Sync", "Play back and sync with audio from Sequence Editor.");
        RNA_def_property_update(prop, NC_SCENE, NULL);
 
        prop= RNA_def_property(srna, "scrub_audio", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "audio.flag", AUDIO_SCRUB);
-       RNA_def_property_ui_text(prop, "Scrub Audio", "Play audio from Sequence Editor while scrubbing.");
+       RNA_def_property_ui_text(prop, "Audio Scrubbing", "Play audio from Sequence Editor while scrubbing.");
+       RNA_def_property_update(prop, NC_SCENE, NULL);
+
+       prop= RNA_def_property(srna, "speed_of_sound", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "audio.speed_of_sound");
+       RNA_def_property_range(prop, 1.0f, FLT_MAX);
+       RNA_def_property_ui_text(prop, "Speed of Sound", "Speed of sound for doppler effect calculation.");
+       RNA_def_property_update(prop, NC_SCENE, NULL);
+
+       prop= RNA_def_property(srna, "doppler_factor", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "audio.doppler_factor");
+       RNA_def_property_range(prop, FLT_MIN, FLT_MAX);
+       RNA_def_property_ui_text(prop, "Doppler Factor", "Pitch factor for doppler effect calculation.");
+       RNA_def_property_update(prop, NC_SCENE, NULL);
+
+       prop= RNA_def_property(srna, "distance_model", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_bitflag_sdna(prop, NULL, "audio.distance_model");
+       RNA_def_property_enum_items(prop, audio_distance_model_items);
+       RNA_def_property_ui_text(prop, "Distance Model", "Distance model for distance attenuation calculation.");
        RNA_def_property_update(prop, NC_SCENE, NULL);
 
        /* Game Settings */