Created
April 2, 2016 19:15
-
-
Save manoj-nandakumar/4096c6400b1258a72ffdb987b09d7f74 to your computer and use it in GitHub Desktop.
Audio Visualizer Script for Blender
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Audio visualisation script | |
# | |
#Feel free to modify this script to suit your needs | |
import bpy | |
#Iterate through however many bars you want | |
for i in range(0, 64): | |
#Add a plane and set it's origin to one of its edges | |
bpy.ops.mesh.primitive_plane_add(location = ((i + (i*0.5)), 0, 0)) | |
bpy.context.scene.cursor_location = bpy.context.active_object.location | |
bpy.context.scene.cursor_location.y -= 1 | |
bpy.ops.object.origin_set(type='ORIGIN_CURSOR') | |
#Scale the plane on the x and y axis, then apply the transformation | |
bpy.context.active_object.scale.x = 0.5 | |
bpy.context.active_object.scale.y = 20 | |
bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) | |
#Insert a scaling keyframe and lock the x and z axis | |
bpy.ops.anim.keyframe_insert_menu(type='Scaling') | |
bpy.context.active_object.animation_data.action.fcurves[0].lock = True | |
bpy.context.active_object.animation_data.action.fcurves[2].lock = True | |
#Set the window context to the graph editor | |
bpy.context.area.type = 'GRAPH_EDITOR' | |
#Expression to determine the frequency range of the bars | |
l = i**2 + 20 | |
h = (i+1)**2 + 20 | |
print(str(i) + ' ' + str(l) + ' ' + str(h)) | |
#Bake that range of frequencies to the current plane (along the y axis) | |
bpy.ops.graph.sound_bake(filepath=r'C:\YOUR_PATH_HERE', low = (l), high = (h)) | |
#Lock the y axis | |
bpy.context.active_object.animation_data.action.fcurves[1].lock = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not working here