Skip to main content

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

FlxSound
The sound to visualize.
Bool
Whether the audio buffer has been successfully accessed.
Int16Array
Raw audio sample data as 16-bit integers.
Int
default:"44100"
Sample rate of the audio in Hz.
Int
Total number of audio samples.

Constructor

FlxSound
required
The FlxSound instance to analyze.

Methods

checkAndSetBuffer
Attempts to access the audio buffer from the playing sound. Must be called while the sound is playing.
getCurAud
Extracts audio information at a specific sample index.
Int16Array
required
The audio data array.
Int
required
Sample index to read.
CurAudioInfo
Object containing left, right, and balanced audio channel values (-1.0 to 1.0).
funnyFFT
Performs Fast Fourier Transform analysis on audio samples.
Array<Float>
required
Array of audio samples to analyze.
Int
default:"1"
Sample skip rate for optimization.
Array<Array<Float>>
2D array of frequency power values over time.

PolygonSpectogram

Real-time waveform visualization using polygon mesh rendering.

Properties

VisShit
The VisShit instance providing audio data.
VISTYPE
default:"UPDATED"
Visualization mode: STATIC, UPDATED, or FREQUENCIES.
Float
default:"FlxG.height"
Height of the visualization in pixels.
Float
default:"0.2"
Length of audio to visualize in seconds for real-time mode.
Float
default:"0"
Time offset for real-time visualization start position.
Float
default:"1"
Visualization detail multiplier. Higher values = more vertices.
Float
default:"2"
Line thickness for waveform rendering.
Int
default:"100"
Horizontal amplitude of the waveform.

Constructor

FlxSound
The sound to visualize.
FlxColor
default:"FlxColor.WHITE"
Color of the waveform.
Float
default:"720"
Height of the visualization.
Float
default:"1"
Detail level multiplier.

Methods

setSound
Sets or changes the sound to visualize.
FlxSound
required
The new sound to visualize.
generateSection
Generates a static waveform visualization for a specific section of audio.
Float
default:"0"
Start time in milliseconds.
Float
default:"1"
Duration to visualize in seconds.
checkAndSetBuffer
Initializes the audio buffer for visualization. Automatically called during update.

ABotVis

A-Bot character’s reactive audio visualizer with animated bars.

Properties

Null<FlxSound>
The sound being visualized.
Null<SpectralAnalyzer>
The spectral analyzer instance for frequency analysis.

Constructor

FlxSound
required
The sound to visualize.
Bool
required
Whether to use pixel art graphics (true) or HD graphics (false).

Methods

initAnalyzer
Initializes the spectral analyzer with A-Bot specific tuning. Must be called after the sound starts playing. Analyzer Configuration:
  • 7 frequency bars
  • Frequency range: 10 Hz to 22,000 Hz
  • dB range: -65 to -25
  • Optimized FFT settings per platform
dumpSound
Clears the sound and analyzer references to free memory.

Constants

Int
Number of frequency visualization bars.

Type Definitions

CurAudioInfo

Audio channel information at a specific sample:
Float
Left channel value (-1.0 to 1.0).
Float
Right channel value (-1.0 to 1.0).
Float
Average of both channels (-1.0 to 1.0).

VISTYPE

Visualization rendering modes:
  • STATIC - One-time generation
  • UPDATED - Real-time following playback
  • FREQUENCIES - 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 detail values create more vertices, impacting performance
  • FFT Size: Native platforms use smaller FFT (256) vs HTML5 for optimization
  • Real-time Updates: UPDATED mode 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 uses SpectralAnalyzer from funkin.vis.dsp with these settings:
These values are tuned for music visualization and can be adjusted for different visual effects or audio types.