0 votes

I am getting this particular runtime error
enter image description here

heres my audio bus layout
enter image description here

and heres my script

var definition = 6
var total_w = 400
var total_h = 200

var min_freq = 20
var max_freq = 20000

var max_db = -16
var min_db = -55

export(float) var accel = 10
var histogram = []

onready var spectrum

func _ready():

    var bgm_bus_id = AudioServer.get_bus_index('Background Music')
    spectrum = AudioServer.get_bus_effect(bgm_bus_id, 0)


func _process(delta):


    var freq = min_freq
    var interval = (max_freq - min_freq) / definition

    for i in range(definition):

        var freqrange_low = float(freq - min_freq) / float(max_freq - min_freq)
        freqrange_low = freqrange_low * freqrange_low * freqrange_low * freqrange_low
        freqrange_low = lerp(min_freq, max_freq, freqrange_low)

        freq += interval

        var freqrange_high = float(freq - min_freq) / float(max_freq - min_freq)
        freqrange_high = freqrange_high * freqrange_high * freqrange_high * freqrange_high
        freqrange_high = lerp(min_freq, max_freq, freqrange_high)

        var mag = spectrum.get_magnitude_for_frequency_range(freqrange_low, freqrange_high)
        mag = linear2db(mag.length())
        mag = (mag - min_db) / (max_db - min_db)

        mag += 0.3 * (freq - min_freq) / (max_freq - min_freq)
        mag = clamp(mag, 0.05, 1)

        histogram[i] = 0.1 + lerp(histogram[i], mag, accel * delta)

    print(histogram)
Godot version Godot_v3.4.2-stable_win64
in Engine by (58 points)

1 Answer

0 votes

I don't know the use-case for get_bus_effect() but it looks like you are trying to use get_bus_effect_instance(), which is strangely close to each other name wise.

by (923 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.