Judge_Engine
Use this page to connect playback and input timing, map devices to gameplay rails, load chart notes, configure hit/miss windows, and receive judge signals. The synchronized-clock and worker contracts are collected at the end.
What Judge Connects
The Judge Engine compares authored note timing with live input timing. It needs:
a valid core data line from an initialized player
a valid input data line from a configured input module
one or more device-to-rail mappings
use and miss timing rules
note objects extracted from a track
The wrapper entry point is PDJE_Judge_Module. Input and judge wrappers are build-conditional; verify that the target plugin exports them before loading a scene that depends on them.
Required Startup Order
Initialize PDJE_Wrapper and a player for the target track.
Initialize and configure PDJE_Input_Module.
Call AddDataLines(input, core).
Register standard and/or MIDI rails.
Call SetRule(…).
Call SetNotes(core, track_title).
Connect judge signals.
Call StartJudge().
Start input capture and playback.
Stop playback, input, and judge explicitly during shutdown.
Complete Godot Flow
@onready var core: PDJE_Wrapper = $PDJE_Wrapper
@onready var input: PDJE_Input_Module = $PDJE_Input_Module
@onready var judge: PDJE_Judge_Module = $PDJE_Judge_Module
var player: PlayerWrapper
func start_gameplay() -> bool:
if not core.InitEngine("user://pdje/rootdb"):
return false
if not core.InitPlayer(
PDJE_Wrapper.HYBRID_RENDER,
"track-title",
480):
return false
player = core.GetPlayer()
if player == null:
return false
if not input.Init():
return false
var selected_standard: Array = []
for device in input.GetDevs():
if device["type"] == "KEYBOARD":
selected_standard.push_back(device)
var selected_midi: Array = input.GetMIDIDevs()
if not input.Config(selected_standard, selected_midi):
return false
if not judge.AddDataLines(input, core):
return false
for device in selected_standard:
if not judge.DeviceAdd(device, InputLine.A, 0, 1):
return false
for port_name in selected_midi:
if not judge.MIDI_DeviceAdd(
port_name,
2,
"NOTE_ON",
1,
48,
0):
return false
judge.SetRule(60000, 61000, 1, 3, false) # use/miss us, loop sleeps ms
if not judge.SetNotes(core, "track-title"):
return false
judge.pdje_judge_miss_signal.connect(_on_judge_miss)
judge.pdje_judge_use_signal.connect(_on_judge_use)
judge.pdje_judge_custom_mouse_parse_signal.connect(_on_custom_mouse)
if not judge.StartJudge():
return false
if not input.Run():
judge.EndJudge()
return false
if not player.Activate():
input.Kill()
judge.EndJudge()
return false
return true
Rail Mapping
A rail is the logical gameplay destination shared by an input mapping and the RailID stored in editor note rows.
Standard input mapping:
judge.DeviceAdd(
device_dictionary,
InputLine.A,
0,
1)
Arguments are one dictionary from GetDevs(), a bound InputLine key/mouse code, a microsecond offset, and the target rail id.
MIDI mapping:
judge.MIDI_DeviceAdd(
"Port Name",
2,
"NOTE_ON",
1,
48,
0)
Arguments are port name, rail id, input type, MIDI channel, note position, and microsecond offset. The current Judge wrapper accepts exactly NOTE_ON, NOTE_OFF, and POLY_PRESSURE for input_type; unsupported strings make MIDI_DeviceAdd() return false. PITCH_BEND, CONTROL_CHANGE, and AFTERTOUCH are still emitted by Input_Engine for game code. Those three types cannot be registered as Judge rails through this method. Judge consumes the native input data line directly, so do not forward an InputLine signal into the Judge wrapper.
Timing Rules
judge.SetRule(
use_range_half_us,
miss_range_half_us,
use_loop_sleep_ms,
miss_loop_sleep_ms,
enable_custom_mouse_signal)
Use and miss ranges are half-window sizes in microseconds. Sleep values control worker-loop pacing in milliseconds; they are not judgment resolution. Choose ranges from gameplay design and measured device/audio latency rather than the audio callback size alone.
Load Notes
SetNotes(core, track_title) asks the initialized PDJE_Wrapper to extract note rows from the selected track. It must run after the core player/data line exists and before StartJudge().
Rail ids in those note rows must match the ids used by DeviceAdd() or MIDI_DeviceAdd(). Use Editor_Workflows to author rows and Editor_Format for their exact fields.
Signals
Signal |
Payload |
|---|---|
pdje_judge_miss_signal |
missed_list, a dictionary grouped by rail id. |
pdje_judge_use_signal |
rail_id, is_pressed, is_late, and time_diff. |
pdje_judge_custom_mouse_parse_signal |
microsecond, found_events, rail_id, x, y, and axis enum. |
func _on_judge_miss(missed_list: Dictionary) -> void:
for rail_id in missed_list:
print("miss rail=", rail_id, " notes=", missed_list[rail_id])
func _on_judge_use(
rail_id: String,
is_pressed: bool,
is_late: bool,
time_diff: String) -> void:
print(rail_id, is_pressed, is_late, time_diff)
func _on_custom_mouse(
microsecond,
found_events,
rail_id,
x,
y,
axis_enum) -> void:
print(microsecond, found_events, rail_id, x, y, axis_enum)
missed_list maps decimal-string rail ids to arrays of note dictionaries with TYPE, DETAIL, ISDOWN, MICROSECOND, FIRST, SECOND, and THIRD. MICROSECOND, like rail_id and time_diff in the other signals, is exposed as a decimal string. found_events uses the same note fields and adds USED. The custom mouse signal’s axis_enum is the native mouse-axis enum converted to an integer.
Shutdown
Stop producers before releasing their wrappers:
func stop_gameplay() -> void:
if player != null:
player.Deactivate()
input.Kill()
judge.EndJudge()
After player or input reconstruction, call AddDataLines() again. Old data lines are non-owning and no longer valid.
Start Failures
StartJudge() returns false and logs an error when any prerequisite is missing:
core data line
input data line with the required standard-input arena
event rule
rail mapping
note objects
Adding rails does not create notes. SetNotes() and at least one matching rail are both required.
Contributor Timing And Execution Model
Native judge is split between PDJE_JUDGE::JUDGE, its Judge_Init bundle, rail storage, input preprocessing, matching, and callback worker queues.
Key invariants:
Core audio timing and input events use a synchronized monotonic, microsecond-oriented timebase.
Audio sample rate and callback size affect scheduling and latency, but do not determine the finest judgment resolution. The configured use/miss half-windows are expressed in microseconds.
SetInputLine() currently accepts a line only when its standard-input arena is non-null, even when MIDI mappings are present.
Start() validates the complete initialization bundle before starting worker threads.
Wrapper signals are deferred into Godot; callback work should remain light.
AxisModel is not a complete public gameplay feature in the current Core.
Primary source anchors:
Native symbol lookup:
-
class JUDGE
Judge controller that owns initialization data and the event loop.
-
class Judge_Init
Judge module initializer holding data lines, rules, and notes.
-
struct EVENT_RULE
Global hit window configuration in microseconds.