hi, these days there have been a couple of threads about baking sound to f-curves, mainly because of some popular site’s tutorial on this… I played with the feature some time ago, and wrote this little scripts to get keyframes or even a 3d curve from the baked one… maybe someone finds them useful
> first script will create a new action & f-curve with plenty of keyframes there to play with, you can then copy paste keyframes or assign the new action to the object
> second script will add curve objects with the shape of your baked f-curves to the scene
select the curves in fc editor so the script is able to know what to work on…
there may be better ways of resampling the baked curve, but I could’t find any at the moment
#####################################
# unbake ¿? f-curve to a new action #
#####################################
import bpy
obj = bpy.context.object
for c in obj.animation_data.action.fcurves:
if c.sampled_points and c.select:
obj.animation_data.action = bpy.data.actions.new(name='Lot_of_Keys')
fcu = obj.animation_data.action.fcurves.new(data_path=c.data_path, index=c.array_index)
sam = c.sampled_points
fcu.keyframe_points.add(len(sam))
for i in range(len(sam)):
w = fcu.keyframe_points[i]
w.co = w.handle_left = w.handle_right = sam[i].co
###################################
# unbake ¿? f-curve to a 3d curve #
###################################
import bpy
obj = bpy.context.object
xscale = 0.1
zscale = 5
for c in obj.animation_data.action.fcurves:
if c.sampled_points and c.select:
sam = c.sampled_points
cu = bpy.data.curves.new('path','CURVE')
cu.dimensions = '3D'
spline = cu.splines.new('BEZIER')
spline.bezier_points.add(len(sam)-1)
curva = bpy.data.objects.new('curve',cu)
bpy.context.scene.objects.link(curva)
for i in range(len(sam)):
w = spline.bezier_points[i]
coords = (xscale*sam[i].co[0],0,zscale*sam[i].co[1])
w.co = w.handle_left = w.handle_right = coords
2.7x > https://www.dropbox.com/s/cd8ufiauilh85hj/unbake.py?dl=1
2.8x > https://www.dropbox.com/s/ydmyxzcmpw97tpt/unbake_280.py?dl=1