Bake Sound F-Curve / Driver Animation

28 March 2016 04:36
Hi all.
I'm trying to bake a sound to an object, and then use that data for multiple drivers responsible for transforming the object.

Among my needs for driver animation are these:
Shape Key
Value Node (Materials)
Logic Editor Variable

So far I have been unsuccessful in using the drivers. I was able to get the desired transformative animation using Bake Action, and was able to animate the shape keys using the Vertex Animation Bake option. However this is not really feasible. Especially due to the fact that it increases the file size if multiple objects are animated.
I have seen in example files, that shape keys have drivers to slider controlled by the user.
Is it possible to use drivers as links to already baked data? and do not require user interaction?

For example:
– Bake sound to the z location of an object
– Use that f-curve as a driver for value node in materials, logic node variable (number input), shape key, etc

Thank you in advance

Edit: I have tried baking everything, vertex animation and regular transformations, with XYZ rot animated, and 4 different shapekeys on a default Sphere. The resulting BIN file is 200 mbs! Is there anyway to dynamically use the sample data and update shapekeys and transformations at runtime? I really think Drivers can be a huge improvement to B4W. Thank you again

Edit 2: Alternatively is it possible to use WebAudioAPI and fft to animate different parameters?

22 April 2016 13:31
Posting this here in case somone runs in to the same problem. "props" are custom properties baked in cycles.

function get_prop(obj, prop ,frame){
    switch(prop) {
    case 0:
        return obj.actions[0].fcurves['["prop"]'][0]._pierced_points[frame];
    case 1:
        return obj.actions[0].fcurves['["prop1"]'][0]._pierced_points[frame];
    case 2:
        return obj.actions[0].fcurves['["prop2"]'][0]._pierced_points[frame];
    case 3:
        return obj.actions[0].fcurves['["prop3"]'][0]._pierced_points[frame];
    case 4:
        return obj.actions[0].fcurves['["prop4"]'][0]._pierced_points[frame];
    case 5:
        return obj.actions[0].fcurves['["prop5"]'][0]._pierced_points[frame];
    case 6:
        return obj.actions[0].fcurves['["prop6"]'][0]._pierced_points[frame];
    case 7:
        return obj.actions[0].fcurves['["prop7"]'][0]._pierced_points[frame];

function setup_anim() {
    var elapsed = m_ctl.create_timeline_sensor();
    var sens_array = [elapsed];
    var logic = function(s) {return (s[0])};

    function anim_cb(obj, id, pulse) {

        var time = m_ctl.get_sensor_value(obj, id, 0);
        var timeToFrame = parseInt(m_anim.get_frame(properties, 0), 10);
        var prop    = get_prop(properties, 0 ,timeToFrame);
        var prop1   = get_prop(properties, 1 ,timeToFrame);
        var prop2   = get_prop(properties, 2 ,timeToFrame);
        var prop3   = get_prop(properties, 3 ,timeToFrame);
        var prop4   = get_prop(properties, 4 ,timeToFrame);
        var prop5   = get_prop(properties, 5 ,timeToFrame);
        var prop6   = get_prop(properties, 6 ,timeToFrame);
        var prop7   = get_prop(properties, 7 ,timeToFrame);
        m_geom.set_shape_key_value(sphere, "dispOne", prop);
        m_geom.set_shape_key_value(sphere, "dispFour", prop3);
        m_geom.set_shape_key_value(sphere, "defTwo", prop1);
        m_geom.set_shape_key_value(sphere, "defThree", prop2+prop7);
        m_trans.set_rotation_euler(sphere, prop1, prop2, prop3);

    m_ctl.create_sensor_manifold(properties, "ANIM", m_ctl.CT_CONTINUOUS,
                sens_array, logic, anim_cb);

Size of bin file is now 700kbs :)
Please register or log in to leave a reply.