Skip to main content

API Reference

Everything is available from Blueprints under the category Elys Persistent Music.

Two ways to reach the same functions:

  • the Persistent Music function library — the nodes resolve the subsystem for you and do nothing outside of play;
  • the Persistent Music Subsystem itself — Get Persistent Music, or Get Game Instance Subsystem → Persistent Music Subsystem — needed to bind the events.

Playback​

Play Music​

PinTypeDefaultMeaning
MusicSound Base—The track to play. Sound Wave, Sound Cue or MetaSound Source.
Fade In TimeFloat-1Seconds. -1 uses the project default.
VolumeFloat-11 is the asset volume. -1 uses the project default.
b LoopBooltrueRestart the track when it ends. Assets that already loop are untouched.
End Notice TimeFloat-1Seconds before the end at which On Music Ending fires. -1 uses the project default, 0 never fires it.

Starts the global track. Calling it with the track already playing does nothing (the volume is still applied), so the node is safe in the Begin Play of every level. Calling it with a different track fades over to it.

Switch Music​

PinTypeDefaultMeaning
New MusicSound Base—The track to fade to.
Crossfade TimeFloat-1Seconds. -1 uses the project default crossfade.
End Notice TimeFloat-1Seconds before the end at which On Music Ending fires, for the new track.

Crossfades from the current track to another one. Passing the track already playing does nothing. If nothing is playing, the new track fades in.

Stop Music​

PinTypeDefaultMeaning
Fade Out TimeFloat-1Seconds. -1 uses the project default, 0 cuts immediately.

Fades the music out and stops it. The state is Fading Out until the fade completes, then Stopped, and On Music Stopped fires.

Pause Music / Resume Music​

No parameters. Pause holds the track where it is; Resume continues from the same position. Pausing does not count as playback time.

Volume​

Set Music Volume​

PinTypeDefaultMeaning
VolumeFloat—1 is the unmodified asset volume. 0 is silent.
Fade TimeFloat0.25Seconds to reach the new volume. 0 applies it immediately.

The volume is kept across tracks and level changes.

Get Music Volume​

Returns the current volume. Returns 0 outside of play.

State​

NodeReturnsMeaning
Is Music PlayingBoolTrue while a track plays, fade in and crossfade included.
Is Music PausedBoolTrue while a track is loaded but paused. (Subsystem only.)
Get Current MusicSound BaseThe track playing or paused, or None.
Get Music StateMusic StateStopped, Playing, Paused or Fading Out.
Get Persistent MusicSubsystemThe subsystem, or None outside of play.

Music State​

ValueMeaning
StoppedNothing is playing.
PlayingA track is playing, including during a fade in or crossfade.
PausedA track is loaded and paused.
Fading OutStop Music was called and the fade is still running.

Events​

Available on the subsystem (Get Persistent Music → Bind Event to…).

EventPayloadFires when
On Music EndingMusic (Sound Base), Time Remaining (Float)The current track is about to end, End Notice Time seconds before it does. Never fires for a track that loops forever, since it has no end.
On Music Stopped—The music stops, at the end of a fade out or immediately on a hard stop.

Time Remaining is the playback actually left, which is shorter than the requested notice when the notice is longer than the track. Feed it straight into the crossfade time of Switch Music to chain tracks with no gap.

Bind them from something that outlives the level, such as your Game Instance.

Project settings​

Project Settings → Plugins → Elys Persistent Music (saved in DefaultGame.ini).

SettingDefaultMeaning
Default Volume1.0Volume used when Play Music receives -1.
Default Fade In Time1.0Fade used when Play Music receives -1.
Default Fade Out Time1.0Fade used when Stop Music receives -1.
Default Crossfade Time2.0Crossfade used when Switch Music receives -1.
Default End Notice Time5.0Notice used when Play Music or Switch Music receives -1. 0 disables the event.
Music Sound ClassnoneSound Class applied to the music component.
Restore Music After Level LoadtrueRestart the track at its position if a map change dropped it.

C++​

The runtime module is ElysPersistentMusic.

#include "ERP_PersistentMusicSubsystem.h"

if (UERP_PersistentMusicSubsystem* Music = GetGameInstance()->GetSubsystem<UERP_PersistentMusicSubsystem>())
{
Music->PlayMusic(ExplorationTheme, /*FadeInTime=*/ 2.0f);
Music->SwitchMusic(CombatTheme, /*CrossfadeTime=*/ 1.5f, /*EndNoticeTime=*/ 8.0f);
Music->OnMusicEnding.AddDynamic(this, &AMyActor::HandleMusicEnding);
Music->SetMusicVolume(0.6f, /*FadeTime=*/ 0.5f);
}

Public headers: ERP_PersistentMusicSubsystem.h, ERP_PersistentMusicLibrary.h, ERP_PersistentMusicSettings.h, ERP_PersistentMusicTypes.h. Log category: LogElysPersistentMusic.