I'm making an audio visualizer which I want to render from the command line. Unfortunately the bpy.ops.graph.sound_bake()
function seems only to work from the GUI.
I've found various tutorials, but they all use the gui to create the animation. They always require this fix
bpy.context.area.type = 'GRAPH_EDITOR'
to set the correct context for bpy.ops.graph.sound_bake()
to work. This works for scripts run from the gui, but when a script is started from he command line bpy.context.area
is undefined.
For materials I already found that instead of
bpy.ops.material.new()
I should use
mat = bpy.data.materials.new("")
to avoid problems with the context. I have not been able how to work out how to do something similar with sounds.
It seems in scripting, using bpy.ops.*
can easily give problems with the context, as these function might check the mouse position for some reason, etc. and there would/should be alternative functions. I have no clue on how to find those alternatives. So far I found them by chance, but I have not been able to find an alternative for bpy.ops.graph.sound_bake()
How can I bake an mp3 to an fcurve and apply that curve to an object, in a script?