LoadSense Pro provides a comprehensive audio system for creating immersive loading experiences through its data-driven music configuration. The system supports multiple tracks, crossfading, shuffle modes, and automatic audio management throughout the loading process.
The music integration in LoadSense Pro is built around the UMusicConfigDataAsset, which provides designers complete control over audio behavior without touching code. The system automatically handles:
The foundation of LoadSense Pro’s audio system. Configure all music behavior through this Data Asset.
File Location: Source/LoadSensePro/Public/Data/MusicConfigDataAsset.h
// Copyright Seven-Mountains-Labs, Tim Koepsel - 2024 All Rights Reserved.
UCLASS(BlueprintType)
class LOADSENSEPRO_API UMusicConfigDataAsset : public UDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Music")
TArray<USoundBase*> Tracks;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Music")
bool bLoop = true;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Music")
bool bShuffle = false;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Music")
float FadeDuration = 1.5f;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Music")
bool bCrossfade = false;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Music")
float Volume = 0.8f;
};
LoadSense Pro manages audio through the subsystem’s ActiveMusicComponent, ensuring proper lifecycle management and preventing audio conflicts during level transitions.
| Property | Type | Default | Description |
|---|---|---|---|
| Tracks | TArray<USoundBase*> |
Empty | Collection of audio tracks for loading screen |
| Volume | float |
0.8 |
Master volume level (0.0 - 1.0) |
| bLoop | bool |
true |
Whether to loop the current track |
| FadeDuration | float |
1.5 |
Duration for fade in/out effects |
| Property | Type | Default | Description |
|---|---|---|---|
| bShuffle | bool |
false |
Randomize track selection |
| bCrossfade | bool |
false |
Enable smooth track transitions |
PlayLoadingMusic() called when loading screen startsStopLoadingMusic() with fade-out during screen termination// Start music playback with fade-in effect
void ULoadingScreenSubsystem::PlayLoadingMusic()
{
if (!CurrentLoadingData || !CurrentLoadingData->MusicConfig)
return;
const UMusicConfigDataAsset* MusicConfig = CurrentLoadingData->MusicConfig;
// Track selection logic
USoundBase* SelectedTrack = MusicConfig->Tracks[0];
if (MusicConfig->bShuffle && MusicConfig->Tracks.Num() > 1)
{
int32 RandomIndex = FMath::RandRange(0, MusicConfig->Tracks.Num() - 1);
SelectedTrack = MusicConfig->Tracks[RandomIndex];
}
// Spawn audio component with configuration
ActiveMusicComponent = UGameplayStatics::SpawnSound2D(
this, SelectedTrack, MusicConfig->Volume, 1.0f, 0.0f,
nullptr, MusicConfig->bLoop
);
// Apply fade-in effect
if (IsValid(ActiveMusicComponent))
{
ActiveMusicComponent->FadeIn(3.0f, MusicConfig->Volume, 0.0f);
}
}
MusicConfig_MainMenu)Basic Setup:
Tracks: [YourMusicTrack1, YourMusicTrack2]
Volume: 0.8
bLoop: true
bShuffle: false
FadeDuration: 2.0
Advanced Setup with Crossfade:
Tracks: [AmbientTrack1, AmbientTrack2, AmbientTrack3]
Volume: 0.7
bLoop: true
bShuffle: true
bCrossfade: true
FadeDuration: 3.0
In your LoadingScreenDataAsset:
MusicConfig: MusicConfig_MainMenu
LoadSense Pro supports all Unreal Engine audio formats:
| Setting | Recommendation | Reason |
|---|---|---|
| Sample Rate | 44.1 kHz | Standard game audio rate |
| Bit Depth | 16-bit | Optimal size/quality balance |
| Channels | Stereo | Full spatial audio experience |
| Duration | 30-180 seconds | Matches typical loading times |
// Recommended Sound Wave settings
Compression Quality: 40-60
Loading Behavior: ESoundWaveLoadingBehavior::InlineElastic
LoadSense Pro automatically handles audio component lifecycle:
void ULoadingScreenSubsystem::StopLoadingMusic()
{
if (IsValid(ActiveMusicComponent))
{
// Graceful fade-out before cleanup
ActiveMusicComponent->FadeOut(1.0f, 0.0f);
ActiveMusicComponent = nullptr;
}
}
InlineElastic loading for seamless playback// Example: Creating themed playlists
TArray<USoundBase*> AmbientTracks = {
LoadObject<USoundBase>(nullptr, TEXT("/Game/Audio/Loading/Ambient_Forest")),
LoadObject<USoundBase>(nullptr, TEXT("/Game/Audio/Loading/Ambient_Ocean")),
LoadObject<USoundBase>(nullptr, TEXT("/Game/Audio/Loading/Ambient_Mountain"))
};
While the MusicConfig provides base volume, you can implement dynamic adjustments:
// Example: Fade music during voice-over
if (IsValid(ActiveMusicComponent))
{
ActiveMusicComponent->SetVolumeMultiplier(0.3f); // Duck volume
}
Extend the system for context-aware music selection:
// Example: Time-based track selection
USoundBase* GetContextualTrack(const UMusicConfigDataAsset* Config)
{
FDateTime CurrentTime = FDateTime::Now();
int32 Hour = CurrentTime.GetHour();
// Morning tracks (6-12)
if (Hour >= 6 && Hour < 12)
return Config->Tracks[0];
// Evening tracks (18-24)
else if (Hour >= 18)
return Config->Tracks[2];
// Default track
else
return Config->Tracks[1];
}
// Create and configure music asset in Blueprint/C++
UMusicConfigDataAsset* MusicConfig = CreateDefaultSubobject<UMusicConfigDataAsset>(TEXT("MusicConfig"));
MusicConfig->Tracks.Add(YourMusicAsset);
MusicConfig->Volume = 0.8f;
MusicConfig->bLoop = true;
// Assign to loading screen data asset
LoadingScreenData->MusicConfig = MusicConfig;
LoadSense Pro’s music system is fully exposed to Blueprints:
// Blueprint-callable functions available
UFUNCTION(BlueprintCallable, Category = "LoadSense Pro")
void SetMusicVolume(float NewVolume);
UFUNCTION(BlueprintCallable, Category = "LoadSense Pro")
void SkipToNextTrack();
No Audio Playback
MusicConfig is assigned to LoadingScreenDataAssetTracks array contains valid USoundBase referencesAudio Cuts Off
FadeDuration for smoother transitionsbLoop is enabled for continuous playbackPerformance Hitches
ESoundWaveLoadingBehavior::InlineElastic// Enable audio logging
UE_LOG(LogLoadingScreen, Log, TEXT("Started loading music: %s"), *SelectedTrack->GetName());
// Check component validity
if (!IsValid(ActiveMusicComponent))
{
UE_LOG(LogLoadingScreen, Warning, TEXT("ActiveMusicComponent is invalid"));
}
Loading_Ambient_Forest)See Also: Getting Started | API Reference | Examples