unreal.MusicClock¶
- class unreal.MusicClock(outer: Object | None = None, name: Name | str = 'None')¶
Bases:
ObjectA 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:
- property beat_event: MusicClockBeatEvent¶
[Read-Write] —- Events —-
- Type:
- get_bars_including_count_in() float¶
Fractional total bars from the beginning, including count-in.
- Return type:
- get_beats_including_count_in() float¶
Fractional total beats from the beginning, including count-in.
- Return type:
- get_current_bars_per_second() float¶
Current bars per second, accounting for tempo, time signature, and speed.
- Return type:
- get_current_beats_per_second() float¶
Current beats per second, accounting for tempo, time signature, and speed.
- Return type:
- get_current_clock_advance_rate() float¶
Current playback speed multiplier from the source.
- Return type:
- get_current_section_index() int32¶
Index of the current section in the section map.
- Return type:
int32
- get_current_section_name() str¶
Name of the current song section (from MIDI section markers).
- Return type:
- get_current_section_start_ms() float¶
Start time of the current section in milliseconds.
- Return type:
- get_current_song_pos() MidiSongPos¶
Get the current musical position for this frame.
- Return type:
- 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:
- get_distance_from_current_bar() float¶
Fractional distance past the most recent bar (0.0 = exactly on bar).
- Return type:
- get_distance_from_current_beat() float¶
Fractional distance past the most recent beat (0.0 = exactly on beat).
- Return type:
- get_distance_to_closest_bar() float¶
Fractional distance to the closest bar (past or future), always <= 0.5.
- Return type:
- get_distance_to_closest_beat() float¶
Fractional distance to the closest beat (past or future), always <= 0.5.
- Return type:
- get_distance_to_next_beat() float¶
Fractional distance until the next beat (0.0 = exactly on next beat).
- Return type:
- get_loop_length_ms() float¶
Length of loop region in ms. Only meaningful if IsLooping().
- Return type:
- get_previous_song_pos() MidiSongPos¶
Get the previous frame’s musical position.
- Return type:
- get_seconds_from_bar_one() float¶
Time from Bar 1 Beat 1 (the classic “start of the song”), excluding count-in/pickup.
- Return type:
- get_seconds_including_count_in() float¶
Time from the beginning of the authored music content, including count-in/pickup bars.
- Return type:
- get_song_remaining_ms() float¶
Remaining time until the end of the song in milliseconds.
- Return type:
- get_source() MusicSource¶
Get the source this clock is bound to.
- Return type:
- get_state() MusicClockState¶
Get the current clock state (Stopped, Paused, Running).
- Return type:
- property play_state_event: MusicClockPlayStateEvent¶
[Read-Write]
- Type:
- property section_event: MusicClockSectionEvent¶
[Read-Write]
- Type:
- seeked_this_frame() bool¶
Whether the source performed a non-contiguous time jump this frame.
- Return type:
- set_source(source) None¶
Bind this clock to a music source. The clock becomes a read-only view into that source.
- Parameters:
source (MusicSource)