Voice chat stuff: why is effect coming out as null

Godot Version

4.4.1

Question

i cant figure out how to fix an error im trying to create a voice chat for a game and i know practically nothing about it.
to be more precise the error says “Cannot call method ‘get_frames_available’ on a null value”

Code

extends Node



@onready var input: AudioStreamPlayer
var index : int
var effect : AudioEffectCapture
var playback : AudioStreamGeneratorPlayback
@export var outPath : NodePath
var inputThreshhold = 0.005



func _ready():
	pass



func setupAudio(id):
	input = $input
	set_multiplayer_authority(id)
	#if is_multiplayer_authority():
	input.stream = AudioStreamMicrophone.new()
	input.play()
	index = AudioServer.get_bus_index("Record")
	effect = AudioServer.get_bus_effect(index, 0)

	playback = get_node(outPath).get_stream_playback()



func _process(delta):
	if is_multiplayer_authority():
		processMic()
	pass



func processMic():
	var sterioData : PackedVector2Array = effect.get_buffer(effect.get_frames_available())
	
	if sterioData.size() > 0:
		
		var data = PackedFloat32Array()
		data.resize(sterioData.size())
		var maxAmplitude := 0.0
		
		for i in range(sterioData.size()):
			var value = (sterioData[i].x + sterioData[i].y) / 2
			maxAmplitude = max(value, maxAmplitude)
			data[i] = value
		if maxAmplitude < inputThreshhold:
			return
		
		print(data)
		

When do you run the setupAudio function?

here i think.

extends Node2D

@export var Charecter : PackedScene



func _ready():
	var s = Charecter.instantiate()
	add_child(s)
	s.get_node("AudioManager").setupAudio(multiplayer.get_unique_id())

	pass

You may have even larger character spawning problems then. Do you have players replicating and controlled correctly?

I notice the script doesn’t include any multiplayer functionality/connted signals, Is there a MultiplayerSpawner node relating to this? A MultiplayerSpawner does not configure the newly replicated child, and setupAudio is not being called in a replicated way.

forget it sorry im giving up. i dont understand what you just said