unreal.MusicClock

class unreal.MusicClock(outer: Object | None = None, name: Name | str = 'None')

Bases: Object

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.

C++ Source:

  • Plugin: Harmonix

  • Module: HarmonixMetasound

  • File: MusicClock.h

Editor Properties: (see get_editor_property/set_editor_property)

  • bar_event (MusicClockBarEvent): [Read-Write]

  • beat_event (MusicClockBeatEvent): [Read-Write] —- Events —-

  • play_state_event (MusicClockPlayStateEvent): [Read-Write]

  • section_event (MusicClockSectionEvent): [Read-Write]

property bar_event: MusicClockBarEvent

[Read-Write]

Type:

(MusicClockBarEvent)

property beat_event: MusicClockBeatEvent

[Read-Write] —- Events —-

Type:

(MusicClockBeatEvent)

get_bars_including_count_in() float

Fractional total bars from the beginning, including count-in.

Return type:

float

get_beats_including_count_in() float

Fractional total beats from the beginning, including count-in.

Return type:

float

get_current_bars_per_second() float

Current bars per second, accounting for tempo, time signature, and speed.

Return type:

float

get_current_beats_per_minute() float

Current BPM in true beats (not quarter notes).

Return type:

float

get_current_beats_per_second() float

Current beats per second, accounting for tempo, time signature, and speed.

Return type:

float

get_current_clock_advance_rate() float

Current playback speed multiplier from the source.

Return type:

float

get_current_section_index() int32

Index of the current section in the section map.

Return type:

int32

get_current_section_length_ms() float

Length of the current section in milliseconds.

Return type:

float

get_current_section_name() str

Name of the current song section (from MIDI section markers).

Return type:

str

get_current_section_start_ms() float

Start time of the current section in milliseconds.

Return type:

float

get_current_song_pos() MidiSongPos

Get the current musical position for this frame.

Return type:

MidiSongPos

get_current_tempo() float

Current tempo in MIDI quarter notes per minute.

Return type:

float

get_current_time_signature() -> (out_numerator=int32, out_denominator=int32)

Get the current time signature as numerator and denominator.

Returns:

out_numerator (int32):

out_denominator (int32):

Return type:

tuple

get_current_timestamp() MusicTimestamp

Get the current musical timestamp (Bar + Beat). Bar 1, Beat 1.0 is the beginning of the song after count-in.

Return type:

MusicTimestamp

get_delta_bar() float

Fractional bars advanced this frame.

Return type:

float

get_delta_beat() float

Fractional beats advanced this frame.

Return type:

float

get_distance_from_current_bar() float

Fractional distance past the most recent bar (0.0 = exactly on bar).

Return type:

float

get_distance_from_current_beat() float

Fractional distance past the most recent beat (0.0 = exactly on beat).

Return type:

float

get_distance_to_closest_bar() float

Fractional distance to the closest bar (past or future), always <= 0.5.

Return type:

float

get_distance_to_closest_beat() float

Fractional distance to the closest beat (past or future), always <= 0.5.

Return type:

float

get_distance_to_next_bar() float

Fractional distance until the next bar.

Return type:

float

get_distance_to_next_beat() float

Fractional distance until the next beat (0.0 = exactly on next beat).

Return type:

float

get_loop_length_ms() float

Length of loop region in ms. Only meaningful if IsLooping().

Return type:

float

get_loop_start_ms() float

Start of loop region in ms. Only meaningful if IsLooping().

Return type:

float

get_previous_song_pos() MidiSongPos

Get the previous frame’s musical position.

Return type:

MidiSongPos

get_seconds_from_bar_one() float

Time from Bar 1 Beat 1 (the classic “start of the song”), excluding count-in/pickup.

Return type:

float

get_seconds_including_count_in() float

Time from the beginning of the authored music content, including count-in/pickup bars.

Return type:

float

get_song_length_ms() float

Total length of the song in milliseconds.

Return type:

float

get_song_remaining_ms() float

Remaining time until the end of the song in milliseconds.

Return type:

float

get_source() MusicSource

Get the source this clock is bound to.

Return type:

MusicSource

get_state() MusicClockState

Get the current clock state (Stopped, Paused, Running).

Return type:

MusicClockState

is_looping() bool

Whether the source is looping.

Return type:

bool

looped_this_frame() bool

Whether the source crossed a loop boundary this frame.

Return type:

bool

property play_state_event: MusicClockPlayStateEvent

[Read-Write]

Type:

(MusicClockPlayStateEvent)

property section_event: MusicClockSectionEvent

[Read-Write]

Type:

(MusicClockSectionEvent)

seeked_this_frame() bool

Whether the source performed a non-contiguous time jump this frame.

Return type:

bool

set_source(source) None

Bind this clock to a music source. The clock becomes a read-only view into that source.

Parameters:

source (MusicSource)

try_get_audio_source_location() Vector | None

Get the world-space location of the audio source, if available.

Return type:

Optional[Vector]