Need help with the new Audio Analyzer (Audio API)

I am trying to make it so that the system can detect the RmsLevel of an Audio Analyzer to get the loudness of a player’s input.
The issue is that the Audio Analyzer works and changes its RmsLevel value but for some reason the scripts return 0. I have tried changing the scripts, making them local and server sided but nothing has worked so far.

This is the main script for creating the Wires and an Audio Analyzer:

game.Players.PlayerAdded:Connect(function(plr)
	local mic = plr:FindFirstChild("AudioDeviceInput") or Instance.new("AudioDeviceInput", plr)
	mic.Player = plr

	local audio = plr.PlayerGui:WaitForChild("ScreamDb"):WaitForChild("Audio")
	
	local analyzer = Instance.new("AudioAnalyzer")
	analyzer.Parent = audio
	
	--local fader = Instance.new("AudioFader")
	--fader.Parent = audio

	local AnalyzerWire = Instance.new("Wire")
	AnalyzerWire.Parent = audio.Wires

	AnalyzerWire.SourceInstance = mic
	AnalyzerWire.TargetInstance = analyzer

	while task.wait(0.5) do
		print(analyzer.PeakLevel, analyzer.RmsLevel)
	end

end)

Sorry for the low quality, but the Audio Analyzer’s value is changing meanwhile the output is 0.

I thought of connecting the Wire straight from the input to the analyzer because I don’t want other players interrupting a player’s speech (by using Audio Emitters) unless it’s important.

If anyone understands the new Audio API I really hope you can find out what the problem is :pray:

Are you testing from the client or server?

I was testing this from the server, the script I posted is handling all this from the server side.

Working with AudioAnalyzer and AudioDeviceInput are weird in studio. Have you tried deleting the the analyzer in real-time on the server to see if the script is actually reading from there?

AudioAnalyzers only work on the client-side, which is why the server Script returns 0 even when the RmsLevel is greater than 0 when viewing it from the perspective of the client.

This was confirmed by the Roblox Staff Member who posted the announcement thread for the new Audio API; they also highlighted a workaround that can be used if you’d still like to be able to reference the RmsLevel on the server-side:

2 Likes

Thank you so much! It works on the client side, I never knew it wasn’t server-sided. I really appreciate your help! :pray:

1 Like

Thanks for your help, but it seems the issue was because Audio Analyzers are only client-sided.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.