Overview
The audio visualization system in Friday Night Funkin’ provides real-time visual feedback for audio playback. It includes spectral analysis, waveform rendering, and character-specific visualizations like A-Bot’s reactive display. Location:funkin.audio.visualize
Components
VisShit
Core utility class for audio buffer access and FFT analysis.Properties
The sound to visualize.
Whether the audio buffer has been successfully accessed.
Raw audio sample data as 16-bit integers.
Sample rate of the audio in Hz.
Total number of audio samples.
Constructor
The FlxSound instance to analyze.
Methods
checkAndSetBuffer
getCurAud
The audio data array.
Sample index to read.
Object containing
left, right, and balanced audio channel values (-1.0 to 1.0).funnyFFT
Array of audio samples to analyze.
Sample skip rate for optimization.
2D array of frequency power values over time.
PolygonSpectogram
Real-time waveform visualization using polygon mesh rendering.Properties
The VisShit instance providing audio data.
Visualization mode:
STATIC, UPDATED, or FREQUENCIES.Height of the visualization in pixels.
Length of audio to visualize in seconds for real-time mode.
Time offset for real-time visualization start position.
Visualization detail multiplier. Higher values = more vertices.
Line thickness for waveform rendering.
Horizontal amplitude of the waveform.
Constructor
The sound to visualize.
Color of the waveform.
Height of the visualization.
Detail level multiplier.
Methods
setSound
The new sound to visualize.
generateSection
Start time in milliseconds.
Duration to visualize in seconds.
checkAndSetBuffer
ABotVis
A-Bot character’s reactive audio visualizer with animated bars.Properties
The sound being visualized.
The spectral analyzer instance for frequency analysis.
Constructor
The sound to visualize.
Whether to use pixel art graphics (
true) or HD graphics (false).Methods
initAnalyzer
- 7 frequency bars
- Frequency range: 10 Hz to 22,000 Hz
- dB range: -65 to -25
- Optimized FFT settings per platform
dumpSound
Constants
Number of frequency visualization bars.
Type Definitions
CurAudioInfo
Left channel value (-1.0 to 1.0).
Right channel value (-1.0 to 1.0).
Average of both channels (-1.0 to 1.0).
VISTYPE
STATIC- One-time generationUPDATED- Real-time following playbackFREQUENCIES- Frequency-based visualization
Example Usage
Basic Waveform Visualization
Static Section Visualization
A-Bot Reactive Visualizer
Custom FFT Analysis
Real-time Waveform with Custom Settings
Multi-track Visualization
Performance Considerations
- Buffer Access:
checkAndSetBuffer()only works while sound is playing - Detail Level: Higher
detailvalues create more vertices, impacting performance - FFT Size: Native platforms use smaller FFT (256) vs HTML5 for optimization
- Real-time Updates:
UPDATEDmode regenerates visualization every frame - Memory: Call
dumpSound()on ABotVis when done to free resources
Platform Notes
- HTML5: Uses optimized browser FFT APIs
- Native: Uses custom FFT implementation with reduced FFT size (256)
- Audio Buffer: Only accessible while sound is actively playing
- Sample Rate: Defaults to 44100 Hz, detected from audio file
Advanced: Spectral Analysis
The ABotVis component usesSpectralAnalyzer from funkin.vis.dsp with these settings:
