0
$\begingroup$

Basically I have a lamp moving on the Z axis according to a sound baked, then unbaked F-Curve, the problem is it's moving the exact opposite way I need it to, and so I believe I need to invert the F-Curve in someway.

$\endgroup$

1 Answer 1

1
$\begingroup$

Bake to a prop, find the ramge. map to [0, 1]

In the code in

https://blender.stackexchange.com/a/39241/15543

I show how to get the minimum and maximum value of an fcurve. The range of the fcurve. (It is generally always the case that the minimum is 0 for baked fcurves). The range is A = max - min . This can also be done pretty much by eye, picking the maximum and minimum points and noting the values in graph editor..

For sound drivers, (which is very much on back-burner, there is an aubio version for 2.8 coming which bakes up to 10x quicker in my preliminary tests) I used these for control points on an fcurve envelope modifier to map the range to [0, 1] With the unit range, the curve can be amplified with a generator modifier, or a via a variable with A * fcurve.evaluate() the inverse is A * (1 - fcurve.evaluate(frame))

The last image of https://blender.stackexchange.com/a/39241/15543 shows a baked sound and its inverse as the amplitude is changed.

Here is a section of that image showing the envelope modifier.

enter image description here action frame range 1 to 44, fcurve has max 0.3 something, mapped to [0, 1] with envelope

Here is some code from sound drivers to add an envelope modifier. The min and max of the fcurve is the default min and max of the modifer. The envelope control points are added at each end of fcurve and map range to range [0, 1].

        action # the action
        fcurve # an fcurve from that action
        _min # calculated min of fcurve
        _max # calculated max of fcurve

        mods = [m for m in fcurve.modifiers if m.type == 'ENVELOPE']
        # remove mods (shouldn't be any)
        for m in mods:
            fcurve.modifiers.remove(m)
        # add a new one
        m = fcurve.modifiers.new(type='ENVELOPE')
        m.default_min = _min
        m.default_max = _max
        # add a control point at start end
        for f in action.frame_range:
            cp = m.control_points.add(f)
            cp.min = 0
            cp.max = 1

Recommend baking to some custom property to avoid having to bake sound for each animated property. Bake once drive with that.

How to bake multiple audio sounds to f curve?

Unbaked

If you have unbaked the fcurve you can simply select all the kfps of fcurve in graph editor and S Y-1 to invert using scale.

PS This is my little part of blender as a patch needed to be written to expose envelope modifier control points to the python API.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .