Navigation
API > API/Plugins > API/Plugins/HarmonixMetasound
A read-only view into a music source's time.
UMusicClock does not own or control playback. It observes an IMusicSource and provides:
- Current/previous musical position (FMidiSongPos)
- Tempo, time signature, BPM queries
- Beat/bar/section event broadcasting
- Song map delegation for time conversions
A single UMusicClock represents a single time stream with no ECalibratedMusicTimebase parameter. For calibrated offsets (experienced, video render, etc.) use UOffsetMusicSource feeding into a separate UMusicClock.
| Name | UMusicClock |
| Type | class |
| Header File | /Engine/Plugins/Runtime/Harmonix/Source/HarmonixMetasound/Public/HarmonixMetasound/MusicClock/MusicClock.h |
| Include Path | #include "HarmonixMetasound/MusicClock/MusicClock.h" |
Syntax
UCLASS (MinimalAPI, BlueprintType)
class UMusicClock : public UObject
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UMusicClock
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UMusicClock() |
HarmonixMetasound/MusicClock/MusicClock.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| BarEvent | FMusicClockBarEvent | HarmonixMetasound/MusicClock/MusicClock.h |
|
|
| BeatEvent | FMusicClockBeatEvent | HarmonixMetasound/MusicClock/MusicClock.h |
|
|
| PlayStateEvent | FMusicClockPlayStateEvent | HarmonixMetasound/MusicClock/MusicClock.h |
|
|
| SectionEvent | FMusicClockSectionEvent | HarmonixMetasound/MusicClock/MusicClock.h |
|
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
float GetBarsIncludingCountIn() |
Fractional total bars from the beginning, including count-in. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetBeatsIncludingCountIn() |
Fractional total beats from the beginning, including count-in. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetCurrentBarsPerSecond() |
Current bars per second, accounting for tempo, time signature, and speed. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetCurrentBeatsPerMinute() |
Current BPM in true beats (not quarter notes). | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetCurrentBeatsPerSecond() |
Current beats per second, accounting for tempo, time signature, and speed. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetCurrentClockAdvanceRate() |
Current playback speed multiplier from the source. | HarmonixMetasound/MusicClock/MusicClock.h |
|
int32 GetCurrentSectionIndex() |
Index of the current section in the section map. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetCurrentSectionLengthMs() |
Length of the current section in milliseconds. | HarmonixMetasound/MusicClock/MusicClock.h |
|
FString GetCurrentSectionName() |
Name of the current song section (from MIDI section markers). | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetCurrentSectionStartMs() |
Start time of the current section in milliseconds. | HarmonixMetasound/MusicClock/MusicClock.h |
|
const FMidiSongPos & GetCurrentSongPos() |
Get the current musical position for this frame. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetCurrentTempo() |
Current tempo in MIDI quarter notes per minute. | HarmonixMetasound/MusicClock/MusicClock.h |
|
void GetCurrentTimeSignature
(
int& OutNumerator, |
Get the current time signature as numerator and denominator. | HarmonixMetasound/MusicClock/MusicClock.h |
|
| Get the current musical timestamp (Bar + Beat). | HarmonixMetasound/MusicClock/MusicClock.h |
|
|
float GetDeltaBar() |
Fractional bars advanced this frame. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetDeltaBeat() |
Fractional beats advanced this frame. | HarmonixMetasound/MusicClock/MusicClock.h |
|
FString GetDisplayName() |
HarmonixMetasound/MusicClock/MusicClock.h | ||
float GetDistanceFromCurrentBar() |
Fractional distance past the most recent bar (0.0 = exactly on bar). | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetDistanceFromCurrentBeat () |
- Beat/Bar Distance - All distance values are fractional: 0.0 = on the beat/bar, 0.5 = halfway to the next. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetDistanceToClosestBar() |
Fractional distance to the closest bar (past or future), always <= 0.5. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetDistanceToClosestBeat() |
Fractional distance to the closest beat (past or future), always <= 0.5. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetDistanceToNextBar() |
Fractional distance until the next bar. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetDistanceToNextBeat() |
Fractional distance until the next beat (0.0 = exactly on next beat). | HarmonixMetasound/MusicClock/MusicClock.h |
|
const FMidiSongPos & GetPreviousSongPos() |
Get the previous frame's musical position. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetSecondsFromBarOne() |
Time from Bar 1 Beat 1 (the classic "start of the song"), excluding count-in/pickup. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetSecondsIncludingCountIn() |
Time from the beginning of the authored music content, including count-in/pickup bars. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetSongLengthMs() |
Total length of the song in milliseconds. | HarmonixMetasound/MusicClock/MusicClock.h |
|
float GetSongRemainingMs() |
Remaining time until the end of the song in milliseconds. | HarmonixMetasound/MusicClock/MusicClock.h |
|
TScriptInterface< IMusicSource > GetSource() |
Get the source this clock is bound to. | HarmonixMetasound/MusicClock/MusicClock.h |
|
bool LoopedThisFrame() |
Whether the source crossed a loop boundary this frame. | HarmonixMetasound/MusicClock/MusicClock.h |
|
bool SeekedThisFrame() |
Whether the source performed a non-contiguous time jump this frame. | HarmonixMetasound/MusicClock/MusicClock.h |
|
void SetSource
(
const TScriptInterface< IMusicSource >& InSource |
Bind this clock to a music source. The clock becomes a read-only view into that source. | HarmonixMetasound/MusicClock/MusicClock.h |
|
TOptional< FVector > TryGetAudioSourceLocation() |
Get the world-space location of the audio source, if available. | HarmonixMetasound/MusicClock/MusicClock.h |
|
Public Virtual
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual float GetLoopLengthMs() |
Length of loop region in ms. Only meaningful if IsLooping(). | HarmonixMetasound/MusicClock/MusicClock.h |
|
virtual float GetLoopStartMs() |
Start of loop region in ms. Only meaningful if IsLooping(). | HarmonixMetasound/MusicClock/MusicClock.h |
|
virtual const ISongMapEvaluator * GetSongMaps() |
Get the song maps from the bound source, for time<->beat conversions. | HarmonixMetasound/MusicClock/MusicClock.h | |
virtual EMusicClockState GetState() |
Get the current clock state (Stopped, Paused, Running). | HarmonixMetasound/MusicClock/MusicClock.h |
|
virtual bool IsLooping() |
Whether the source is looping. | HarmonixMetasound/MusicClock/MusicClock.h |
|
virtual void UpdateForGameFrame () |
Update the clock for the current game frame. | HarmonixMetasound/MusicClock/MusicClock.h |
Overridden from UObject
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void BeginDestroy() |
HarmonixMetasound/MusicClock/MusicClock.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void BroadcastSongPosChanges() |
Broadcast beat, bar, and section events if thresholds were crossed this frame. | HarmonixMetasound/MusicClock/MusicClock.h | |
IMusicSource * GetValidSource() |
Get the source if still alive, or nullptr. | HarmonixMetasound/MusicClock/MusicClock.h | |
void UpdatePlaybackRate
(
const FMidiSongPos& SongPos, |
Update cached tempo, time signature, and derived rates when the song position changes. | HarmonixMetasound/MusicClock/MusicClock.h |