I used this guide to create an audio visualization using the audio frequency spectrum. I compared mine to the monstercat rainmeter addon. for some reason mine is far more smoothed out. it seems to have less detail. I’ve tried using flac encoded songs, but they end up looking exactly the same in my audio visualization as the mp3 versions of the same song. might this be a limitation of blender, or might it be my code?
the upper part is mine and the lower is the monstercat one.
here’s my code:
import bpy
import pprint
for i in range(0, 40):
bpy.ops.mesh.primitive_cube_add(radius=1, view_align=False, enter_editmode=False, location=((i/2)-15.75, 0, 0))
ob = bpy.context.active_object
#sets origin to bottom of object
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')
ob.scale = (0.2, 1.0 + ((i**2)/800), 0.2)
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 = (((1.2**(i+0))*9.44) + 20)
h = (((1.2**(i+1))*9.44) + 20)
#Bake that range of frequencies to the current plane (along the y axis)
bpy.ops.graph.sound_bake(filepath=r'C:\Users\andga\Desktop\Garrett\Music\Cake - Love You Madly.mp3', low = (l), high = (h))
#Lock the y axis
bpy.context.active_object.animation_data.action.fcurves[1].lock = True
mat = bpy.data.materials["white"]
ob.data.materials.append(mat)
print("L(",l,") H(",h,")")
[SOLVED]
I needed to reduce the “attack”
change this
bpy.ops.graph.sound_bake(filepath=r’C:\Users\andga\Desktop\Garrett\Music\Cake - Love You Madly.mp3’, low = (l), high = (h), release = 1.3)
to this
bpy.ops.graph.sound_bake(filepath=r’C:\Users\andga\Desktop\Garrett\Music\Cake - Love You Madly.mp3’, low = (l), high = (h), attack = 0.0001, release = 1.3)