Core_Engine

The Core Engine owns the root database, creates the runtime player, exposes the editor, and provides live playback state to UI and judge integrations. This page covers its complete Godot workflow; native ownership and source references are collected at the end.

Godot Classes

Class

Responsibility

PDJE_Wrapper

Godot Node that owns the native engine and exposes search, playback, editor, note extraction, and core-line access.

PlayerWrapper

RefCounted playback controller returned by GetPlayer().

MusPanelWrapper

Manual/hybrid music loading, cueing, enablement, BPM, and unload control.

FXWrapper

Effect enablement and access to an FXArgWrapper.

FXArgWrapper

Lists and sets exact case-sensitive runtime FX arguments.

EditorWrapper

Editor project mutation, history, preview, render, and root-DB push.

CoreLine

Safe Godot accessors over current playback state.

Initialize The Engine

Create one PDJE_Wrapper and keep it alive for every player, editor, MIR, and judge object that refers to it. InitEngine() returns false when the database root cannot be initialized.

@onready var engine: PDJE_Wrapper = $PDJE_Wrapper

func _ready() -> void:
    if not engine.InitEngine("user://pdje/rootdb"):
        push_error("PDJE root database initialization failed")
        return

Use user:// for writable game data. Use a deployed absolute path only when your application deliberately stores the database outside the Godot user data directory.

Search Music And Tracks

SearchMusic(title, composer, bpm) returns an Array of music dictionaries. Empty strings disable the corresponding text filter, and a negative BPM skips the BPM filter. SearchTrack(title) returns matching track dictionaries.

var music: Array = engine.SearchMusic("song-title", "composer", -1.0)
var tracks: Array = engine.SearchTrack("track-title")

if tracks.is_empty():
    push_warning("Track was not found")
    return

GetPCMFromMusicData(music_data) accepts one music dictionary returned by SearchMusic() and returns a Dictionary with these keys:

  • pcm — decoded interleaved stereo samples as PackedFloat32Array

  • channel_count — 2 on success and 0 on failure

  • pcm_length — total interleaved sample count on success

  • musicPath — the path copied from the input dictionary

The wrapper does not return a sample-rate field. The current native decoder path used here produces 48 kHz PCM, but consumers should not invent a dictionary key for it. Treat an empty pcm array or zero channel_count as failure.

var matches: Array = engine.SearchMusic("song-title", "composer", -1.0)
if matches.is_empty():
    return

var decoded: Dictionary = engine.GetPCMFromMusicData(matches[0])
var pcm: PackedFloat32Array = decoded["pcm"]
var channel_count: int = decoded["channel_count"]
if pcm.is_empty() or channel_count == 0:
    push_error("PCM decode failed")
    return

var frame_count: int = pcm.size() / channel_count

Playback Flow

InitPlayer(mode, track_title, frame_buffer_size) uses the track title, not a native track object. The available modes are:

Mode

Use

PDJE_Wrapper.FULL_PRE_RENDER

Pre-rendered track playback.

PDJE_Wrapper.HYBRID_RENDER

Pre-rendered playback plus manual music and FX panels.

PDJE_Wrapper.FULL_MANUAL_RENDER

Manual player without a searched-track constructor payload.

These constants are bound directly on PDJE_Wrapper; they are not members of EnumWrapper. EnumWrapper contains only the runtime FX values documented in FX_ARGS.

if not engine.InitPlayer(
        PDJE_Wrapper.HYBRID_RENDER,
        "track-title",
        480):
    push_error("Player initialization failed")
    return

var player: PlayerWrapper = engine.GetPlayer()
if player == null:
    push_error("Player handle is unavailable")
    return

if not player.Activate():
    push_error("Playback activation failed")
    return

print(player.GetConsumedFrames())
player.ChangeCursorPos("24000")

# Later, during controlled shutdown:
player.Deactivate()
engine.ResetPlayer()

PlayerWrapper exposes:

  • Activate() and Deactivate() for playback state.

  • ChangeCursorPos(frame_position) accepts a base-10 PCM frame index encoded as a String; for example, “24000” seeks to frame 24000. It returns false when no native player exists. Supply digits only because invalid numeric text is rejected by the wrapper conversion.

  • GetConsumedFrames() returns the consumed PCM-frame count as a decimal String; an empty string means the native player is unavailable.

  • GetStatus() is a retained deprecated binding that returns only “This is Deprecated Function.”. There is no replacement state-query method: check the result of Activate()/Deactivate() at the transition, and use GetConsumedFrames() or a current CoreLine cursor for observable progress.

  • GetMusicControlPanel() returns the manual music panel.

  • GetFXControlPanel() returns the player’s main FX panel. To control FX for a loaded music handle, call getFXHandle(title) on MusPanelWrapper as shown below.

A PlayerWrapper, panel, or CoreLine becomes stale after ResetPlayer() or a new player initialization. Reacquire every dependent wrapper.

Manual Music Control

Manual music control is intended for HYBRID_RENDER and FULL_MANUAL_RENDER. Check every returned handle and method result.

var music_panel: MusPanelWrapper = player.GetMusicControlPanel()
if music_panel == null:
    push_error("This player has no manual music panel")
    return

var loaded_count: int = music_panel.LoadMusic("song-title", "composer", -1.0)
if loaded_count <= 0:
    push_error("No matching music was loaded")
    return

music_panel.SetMusic("song-title", true)
music_panel.CueMusic("song-title", "0")
music_panel.ChangeBpm("song-title", 132.0, 128.0)

for loaded_music in music_panel.GetLoadedMusicList():
    print(loaded_music)

# Stop and remove it when no longer needed.
music_panel.SetMusic("song-title", false)
music_panel.UnloadMusic("song-title")

Runtime FX Control

An FXWrapper controls one music handle’s effect panel. Argument names are case-sensitive and differ by effect. Always obtain the accepted list through GetFXArgKeys() or FX_ARGS rather than inventing a spelling. EnumWrapper is a globally registered Godot enum holder for the 13 runtime FX values; it is separate from the player-mode constants on PDJE_Wrapper.

var fx_panel: FXWrapper = music_panel.getFXHandle("song-title")
if fx_panel == null:
    return

if not fx_panel.FX_ON_OFF(EnumWrapper.ECHO, true):
    push_error("Could not enable echo")
    return

var args: FXArgWrapper = fx_panel.GetArgSetter()
if args == null:
    return

for key in args.GetFXArgKeys(EnumWrapper.ECHO):
    print(key)

args.SetFXArg(EnumWrapper.ECHO, "EchoDryWet", 0.5)
print(fx_panel.CheckFXOn())

FX_ON_OFF() returns false only when the wrapper has no internal panel; after it forwards a valid enum to the native panel it returns true. CheckFXOn() reports whether any effect in that panel is currently enabled, not whether the last requested effect alone is enabled.

Editor Entry

The editor is a separate authoring lifecycle owned by the same engine. InitEditor() requires author identity and a project path because editor history is Git-backed.

if not engine.InitEditor(
        "Author Name",
        "author@example.com",
        "user://pdje/editor-project"):
    push_error("Editor initialization failed")
    return

var editor: EditorWrapper = engine.GetEditor()
if editor == null:
    return

editor.ConfigNewMusic(
    "song-title",
    "composer",
    "res://audio/song.wav",
    "0")

# Close only after editor wrappers and preview players are no longer used.
engine.CloseEditor()

Continue with Editor_Workflows for mutation, history, render, push, and preview. The data fields and protected authoring tables are in Editor_Format.

Core Data Line

After the player exists, PullOutCoreLine() returns a CoreLine with Godot accessors for the live playback state.

var core_line: CoreLine = engine.PullOutCoreLine()
if core_line != null:
    print(core_line.GetUsedFrame())
    print(core_line.GetNowCursor())
    print(core_line.GetMaxCursor())
    var rendered_frames := core_line.GetPreRenderedFrames()

Reacquire the line after player reset or replacement. See Data_Lines for ownership, threading, and judge integration rules.

Contributor Model And Source Anchors

The Godot objects above are ownership-safe projections of native concepts:

  • PDJE_Wrapper owns an optional native PDJE facade.

  • PDJE owns the root DB handle plus shared audioPlayer and editorObject instances.

  • PlayerWrapper keeps a native player reference and a non-owning engine reference so music lookup can reach the root DB.

  • Panel wrappers are valid only while their player and native panel exist.

  • CoreLine projects non-owning live data and therefore follows the producing player’s lifetime.

Primary source anchors:

Native symbol lookup:

enum PLAY_MODE

the play mode you can use this to initialize the player(music handler) to use fx control in real time, do not use Full pre render.

Values:

enumerator FULL_PRE_RENDER
enumerator HYBRID_RENDER
enumerator FULL_MANUAL_RENDER
class PDJE

the main Interface of this Engine PDJE gets music data and track data from database. from that datas, you can activate music player and you can get a music player handler. with this player handler, you can control music’s mixing in real time.

to-use

  1. make PDJE object

  2. call SearchTrack

  3. call InitPlayer

  4. use player. this is handler.

digraph PDJE_Interface_Tree{ PDJE -> Search_Tools; PDJE -> Player; Player -> Player_ON_OFF; Player -> FXController; Player -> MusicController; FXController -> FX_ON_OFF; FXController -> FX_arg_setter; FX_arg_setter -> change_FX_value; MusicController -> Load_Music; MusicController -> Unload_Music; MusicController -> ON_OFF_Music; MusicController -> Cue_Music; MusicController -> FXController; }

bool PDJE::InitPlayer(PLAY_MODE mode, trackdata &td, const unsigned int FrameBufferSize)

this inits the music handler. the music handler called a “player” it initializes the player

Parameters:
  • mode – the play modes. you can choose “FULL_PRE_RENDER”, “HYBRID_RENDER”, “FULL_MANUAL_RENDER”

  • td – the track data. you can get this from SearchTrack()

  • FrameBufferSize – the buffersize. in this project, it uses 48000 samplerate. if you use 48 as a value, in theory, it calls mixing function 1000 times per second.

Returns:

true no error

Returns:

false error

bool PDJE::InitEditor(const DONT_SANITIZE &auth_name, const DONT_SANITIZE &auth_email, const DONT_SANITIZE &projectRoot)

Initializes the editor.

Parameters:
  • auth_name – The author’s name for Git commits.

  • auth_email – The author’s email for Git commits.

  • projectRoot – The root directory of the editor project.

Returns:

true if the editor was initialized successfully, false otherwise.

PDJE_CORE_DATA_LINE PDJE::PullOutDataLine()