Skip to content

Instantly share code, notes, and snippets.

@zeffii
Forked from anonymous/funksticks.py
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/e7fde0640b0c28dc4aa2 to your computer and use it in GitHub Desktop.
Save zeffii/e7fde0640b0c28dc4aa2 to your computer and use it in GitHub Desktop.
import bpy
rows = 5
columns = 5
# fp = r"C:\Gannon\Blender\Sounds\Music\Batty McFadden.mp3"
fp = "/home/zeffii/SOUND/Demo Tracks- 1999/09 After the Landing.mp3"
def spiral(X, Y):
scn = bpy.context.scene
x = y = 0
dx = 0
dy = -1
number_of_iterations = max(X, Y)**2
for i in range(number_of_iterations):
if (-X / 2 < x <= X / 2) and (-Y / 2 < y <= Y / 2):
bpy.ops.mesh.primitive_cube_add(location=(x, y, 1))
obj = bpy.context.active_object
scn.cursor_location = obj.location
scn.cursor_location.z -= 1
bpy.ops.object.origin_set(type="ORIGIN_CURSOR")
obj.scale = (0.5, 0.5, 7)
bpy.ops.object.transform_apply(scale=True)
bpy.ops.anim.keyframe_insert_menu(type='Scaling')
action = obj.animation_data.action
action.fcurves[0].lock = True
action.fcurves[1].lock = True
bpy.context.area.type = 'GRAPH_EDITOR'
step = 20000 / (rows * columns)
print('baking {0} of {1}'.format((i + 1), number_of_iterations))
bpy.ops.graph.sound_bake(filepath=fp, low=(i * step), high=(i * step + step))
action.fcurves[2].lock = True
if x == y or (x < 0 and x == -y) or (x > 0 and x == (1 - y)):
dx, dy = -dy, dx
x, y = (x + dx), (y + dy)
print('done!')
spiral(rows, columns)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment