This is a data structure managing information about the current song. This structure is created when the game starts, and includes all the data from the metadata.json file. It also includes the chart data, but only when this is the currently loaded song.

It also receives script events; scripted classes which extend this class can be used to perform custom gameplay behaviors only on specific songs.

Static variables

@:value("Unknown")staticfinalread onlyDEFAULT_ARTIST:String = "Unknown"

The default value for the song's artist

@:value(null)staticfinalread onlyDEFAULT_DIVISIONS:Null<Int> = null

The default value for the song's divisions

@:value(false)staticfinalread onlyDEFAULT_LOOPED:Bool = false

The default value for whether the song loops.

@:value(1.0)staticfinalread onlyDEFAULT_SCROLLSPEED:Float = 1.0

The default value for the song's scroll speed.

@:value("Unknown")staticfinalread onlyDEFAULT_SONGNAME:String = "Unknown"

The default value for the song's name

@:value("mainStage")staticfinalread onlyDEFAULT_STAGE:String = "mainStage"

The default value for the song's playable stage.

@:value(SongTimeFormat.MILLISECONDS)staticfinalread onlyDEFAULT_TIMEFORMAT:SongTimeFormat = SongTimeFormat.MILLISECONDS

The default value for the song's time format

Static methods

@:value({ validScore : false, includeScript : true })staticbuildRaw(songId:String, metadata:Array<SongMetadata>, variation:String, charts:Map<String, SongChartData>, includeScript:Bool = true, validScore:Bool = false):Song

Build a song from existing metadata rather than loading it from the assets folder. Used by the Chart Editor.

Parameters:

songId

The ID of the song.

metadata

The metadata of the song.

variations

The list of variations this song has.

charts

The chart data for each variation.

includeScript

Whether to initialize the scripted class tied to the song, if it exists.

validScore

Whether the song is elegible for highscores.

Returns:

The constructed song object.

Constructor

new(id:String, ?params:Null<SongParams>)

Parameters:

id

The ID of the song to load.

targetVariation

The variation to load, optional.

Variables

final_data:Null<SongMetadata>

read onlycharter:String

The artist of the song.

finalid:String

read onlysongArtist:String

The artist of the song.

read onlysongName:String

The readable name of the song.

@:value(true)validScore:Bool = true

Set to false if the song was edited in the charter and should not be saved as a high score.

@:value(null)variation:Null<String> = null

read onlyvariations:Array<String>

The list of variations a song has.

Methods

@:value({ force : false })cacheCharts(force:Bool = false):Void

Parse and cache the chart for all difficulties of this song.

Parameters:

force

Whether to forcibly clear the list of charts first.

clearCharts():Void

Purge the cached chart data for each difficulty/variation of this song.

destroy():Void

getAlbumId(diffId:String, variation:String):String

Input a difficulty ID and a variation ID, and get the album ID.

Parameters:

diffId
variation

Returns:

String

getBaseInstrumentalId(difficultyId:String, variationId:String):String

getDifficulty(?diffId:String, ?variation:String, ?variations:Array<String>):Null<SongDifficulty>

Retrieve the metadata for a specific difficulty, including the chart if it is loaded.

Parameters:

diffId

The difficulty ID, such as easy or hard.

variation

The variation ID to fetch the difficulty for. Or you can use variations.

variations

A list of variations to fetch the difficulty for. Looks for the first variation that exists.

Returns:

The difficulty data.

getFirstValidVariation(?diffId:String, ?currentCharacter:PlayableCharacter, ?possibleVariations:Array<String>):Null<String>

Returns the first valid variation that matches both the difficulty id, and the current character / possible input variations

Parameters:

diffId
currentCharacter
possibleVariations

Returns:

Null

getRawMetadata():Array<SongMetadata>

Retrieve a list of the raw metadata for the song.

Returns:

The metadata JSON objects for the song's variations.

getStickerPackId(diffId:String, variation:String):Null<String>

getVariationsByCharacter(?char:PlayableCharacter):Array<String>

Given that this character is selected in the Freeplay menu, which variations should be available?

Parameters:

char

The playable character to query.

Returns:

An array of available variations.

getVariationsByCharacterId(?charId:String):Array<String>

Nearly the same thing as getVariationsByCharacter, but takes a character ID instead.

Parameters:

charId

Returns:

Array

See also:

  • getVariationsByCharacter

hasDifficulty(diffId:String, ?variationId:String, ?variationIds:Array<String>):Bool

isDifficultyVisible(diffId:String, variationId:String):Bool

isSongNew(currentDifficulty:String, currentVariation:String):Bool

listAlbums(variation:String):Map<String, String>

List the album IDs for each variation of the song.

Returns:

A map of variation IDs to album IDs.

listAltInstrumentalIds(difficultyId:String, variationId:String):Array<String>

Return the list of available alternate instrumentals. Scripts can override this, fun.

Parameters:

variationId
null

difficultyId

@:value({ showHidden : false, showLocked : false })listDifficulties(?variationId:String, ?variationIds:Array<String>, showLocked:Bool = false, showHidden:Bool = false):Array<String>

List all the difficulties in this song.

Parameters:

variationId

Optionally filter by a single variation.

variationIds

Optionally filter by multiple variations.

showLocked

Include charts which are not unlocked

showHidden

Include charts which are not accessible to the player.

Returns:

The list of difficulties.

listSuffixedDifficulties(variationIds:Array<String>, ?showLocked:Bool, ?showHidden:Bool):Array<String>

Deprecated:

This function is deprecated, Funkin no longer uses suffixed difficulties.

TODO: This line of code makes me sad, but you can't really fix it without a breaking migration.

Returns:

easy, erect, normal-pico, etc.

onCreate(event:ScriptEvent):Void

onResume(event:ScriptEvent):Void

toString():String