SpectroRender - simple spectrogram for AudioPlayers

By any means, this is not a versatile or much-customizable module.


What this module does is simple: it allows pre-existing visuals to be animated using AudioAnalyzers. I made it so it works with either GuiObjects or BaseParts.

2D audio note

To listen to 2D audio, you need to parent an AudioEmitter in the camera and manually connect AudioPlayer (assemblies) to it. Here’s a little code which does just that (place in StarterPlayerScripts):

local Camera = workspace.CurrentCamera
local AudioEmitter = Instance.new("AudioEmitter")
AudioEmitter.Parent = Camera
workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(function()
	if AudioEmitter then
		AudioEmitter.Parent = Camera
	end
end)

The API for this module is simple:

  • .new(ParentFrame,Analyzer,ForUI,CustomSortingAlgorithm)
    The constructor function which returns a Spectogram type, which is the renderer itself. ParentFrame can be anything, but it should contain either BaseParts or GuiObjects. Analyzer is the AudioAnalyzer which will be used to process the spectrum. ForUI is simply a boolean indicating whether the module will be used for parts or UI elements. CustomSortingAlgorithm is a custom sort function meant to sort the visual “frames”, and it is a replacement for the default table.sort() function. Only use this if needed.

For the Spectrogram:

  • :Render() which allows you to manually update the spectrogram visual.
  • :SetAutoRendering(Enabled) lets the module auto-:Render() the visual. Uses RunService.Heartbeat, compatible with both client and server contexts. However, it is recommended you use the client context to save performance.
  • :Destroy() which clears the Spectrogram from memory, but does NOT destroy the visual itself.

As mentioned, the module is simple and short, easy to explore and also typechecked. The interesting and really unexplainable part is in the “ConstructBins” module, a modified version from the official example place. If you have any ideas for improvements, please let me know.


Download

Model on the Creator Store
Sample place file showcasing the module (66.7 KB)