How do I detect pitches in my microphone?

roblox has released the audio API, and with it comes a plethora of new features! this includes an AudioAnalyzer. what the AudioAnalyzer lets you do is detect volume and pitch changes in sounds. amazing, so i can detect volume and pitch from my microphone! one small issue… it doesn’t work. in my setup, i have this code:

local rep = game:GetService("ReplicatedStorage")
local analyzers = rep:WaitForChild("Analyzers")

local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
	local audio_device_input = player:WaitForChild("AudioDeviceInput")
	local analyzer = Instance.new("AudioAnalyzer")
	analyzer.Name = `{player.Name}'s Analyzer`
	analyzer.Parent = analyzers
	
	local wire = Instance.new("Wire")
	wire.SourceInstance = audio_device_input
	wire.TargetInstance = analyzer
	wire.Parent = analyzer
end)

i tried to just grab the analyzer and use the :GetSpectrum() method to return the frequencies (pitches). but it didn’t work? after some digging i found this:


“If any of the analyzer’s inputs come from an AudioDeviceInput, this method returns an empty array”. huh.

so i guess my two questions are:

  • why can i not use an audiodeviceinput?
  • are there are alternatives?

thanks for reading :wink:

This is my most anticipated feature on Roblox :3

Roblox is already planning to implement this feature in probably early/mid 2025. My speculation on why it’s not out right now is that pitch detection is quite expensive I guess. Considering how Roblox runs on every devices from PC, mobile phones, consoles, to VR. Roblox just need some time to idk research and then code it so it supports for every hardware bla bla bla.

I am hoping for this feature to release very soon.

No there are no alternatives unfortunately.

1 Like

ah, shame…

thank you for the input and this will be marked as the solution!

I’ll update this page if anything is introduced or rolled out. thanks!

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