Audio Viz

I am trying to play with this Audio Viz from blendercookie, but I am having problems with the code, which is as follows…

import bpy

rows = 5
columns = 5

r = 0
c = 0

def spiral(X, Y):
x = y = 0
dx = 0
dy = -1
for i in range(max(X, Y)**2):
if (-X/2 < x <= X/2) and (-Y/2 < y <= Y/2):
bpy.ops.mesh.primitive_cube_add(location=(x, y, 0))
bpy.context.scene.cursor_location = bpy.context.active_object.location
bpy.context.scene.cursor_location.z -= 1
bpy.ops.object.origin_set(type = ‘ORIGIN_CURSOR’)
bpy.context.active_object.scale.x = 0.5
bpy.context.active_object.scale.y = 0.5
bpy.context.active_object.scale.z = 5

        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[1].lock = True

        bpy.context.area.type = 'GRAPH_EDITOR'

        step = 20000/ (rows*columns)

        bpy.ops.sound_bake(filepath=r"C:/Users/James/Desktop/Angular Momentum.mp3", low=i*step, high=i*step + step)

        bpy.context.active_object.animation_data.action.fcurves[2].lock = True

    if x == y or (x &lt; 0 and x == -y) or (x &gt; 0 and x == 1-y):
        dx, dy = -dy, dx
    x, y = x+dx, y+dy

spiral(rows, columns)

I keep getting an error that states:

Traceback…line 45 in <module> and line 34 in spiral…TypeError ‘BPyOpsSubMod’ object is not callable

OK, I am new to python and have no clue what this is. I have played with the indents and spelling and other, but for the life of me cannot get it to work.

Line 34 is where the sound file is identified
Line 45 is the last line.

Can someone help? Please? Thank you

bpy.ops.sound_bake(filepath=r"C:/Users/James/Desktop/Angular Momentum.mp3", low=istep, high=istep + step)


bpy.ops.graph.sound_bake(filepath=“C:/Users/James/Desktop/Angular Momentum.mp3”, low=istep, high=istep + step)

2 errors, you added an ‘r’ before your quoted file path. And its bpy.ops.graph.sound_bake


I grabbed the script from in your OP. If you have trouble baking the mp3 file you may need to use some audio program to convert it to a single channel wav. You also mentioned about using another object than the cube. My suggestion there is to use group instances and animate the z scale of the empty.

import bpy

def spiral(context, X, Y, groupname, filepath):
    group =
    if group is None:
        print("No Group %s" % groupname)
        return False
    step = 16000/ (X * Y)
    x = y = 0
    dx = 0
    dy = -1
    area = context.area.type
    bpy.context.area.type = 'GRAPH_EDITOR'
    for i in range(max(X, Y)**2):
        if (-X/2 &lt; x &lt;= X/2) and (-Y/2 &lt; y &lt;= Y/2):
            bpy.ops.object.group_instance_add('EXEC_DEFAULT', group="Group")
            ob = context.active_object
            ob.location = x, y, 0
            ob.keyframe_insert('scale', index=2)
            bpy.ops.graph.sound_bake(filepath=filepath, low=i*step, high=i*step + step)

        if x == y or (x &lt; 0 and x == -y) or (x &gt; 0 and x == 1-y):
            dx, dy = -dy, dx
        x, y = x+dx, y+dy
    context.area.type = area

# test call.. I have a speaker with sound file attached

filepath =["Speaker"].data.sound.filepath
spiral(bpy.context, 5, 5, "Group", filepath)

@paraponera When an “r” or “R” prefix is present, a character following a backslash is included in the string without change, and all backslashes are left in the string.

@batFinger the pastbin url is mine from another post, and I was able to figure it out (thread is marked SOLVED) although probably not very elegantly. However, thank you for both the correction on “r” vs “R” (it just jumped out at me from the OP’s post and I wasn’t aware of this behavior), and for the code snippet. I’ll test your Python out. Thank you kindly for the advice!

EDIT: yup, the code definitely works. Added my single mesh to a group named “Group”, included my mp3, and had immediate positive results. Now its going to take me some time to digest the code further, but thank you for some working reference to kick around.

I am curious though what the Speaker does (locational audio I assume)? I added a speaker object with the default “Speaker” name to my scene and I get an error:

AttributeError: ‘NoneType’ object has no attribute ‘filepath’

Where line 33 reporting the error is:

filepath =[“Speaker”].data.sound.filepath

I guess I’m less interested in the error and more curious what you were doing with this speaker object.