Editor_Workflows

Use this page to create or reopen editor projects, mutate typed rows, inspect history, render authored data, push it to the root database, and preview a track. Exact field meanings and protected authoring tables remain in Editor_Format; native ownership and source references are collected at the end.

What The Editor Owns

The editor is a major PDJE subsystem rather than a playback helper. It owns:

  • project-local music metadata and timeline working files

  • typed music, mix, note, and key-value rows

  • Git-backed edit history and semantic diff operations

  • validation and conversion into root-DB-ready payloads

  • explicit push operations to the root database

  • preview playback created from editor-authored content

Project-local editing, rendering, root-DB persistence, and preview playback are different stages. A successful local mutation is not automatically persisted to the root database.

Initialize An Editor Project

Initialize the root engine first, then initialize the editor with author identity and a writable project path.

@onready var engine: PDJE_Wrapper = $PDJE_Wrapper
var editor: EditorWrapper

func open_editor() -> bool:
    if not engine.InitEngine("user://pdje/rootdb"):
        return false

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

    editor = engine.GetEditor()
    return editor != null

InitEditor() prepares the project supplied to PDJE_Wrapper. EditorWrapper does not expose the native Open() overload as a separate Godot call. To work with another editor project, close the current editor and initialize the desired project path.

Call engine.CloseEditor() only after every EditorWrapper and preview player that depends on it is no longer used. DESTROY_PROJECT() is destructive and is not part of normal shutdown.

Configure Music Metadata

ConfigNewMusic(name, composer, music_path, first_bar) registers music metadata in the editor project. The path must identify an audio asset that the runtime can later decode.

if not editor.ConfigNewMusic(
        "song-title",
        "composer",
        "res://audio/song.wav",
        "0"):
    push_error("Music configuration failed")

The bound Godot method is EditMusicFirstBar(title, first_bar). Despite that legacy binding name, it updates the music entry’s first-beat PCM-frame offset, which aligns decoded audio with authored musical time; see Editor_Format.

Typed Mutation Workflow

Godot mutations use PDJE_EDITOR_ARG. Create a fresh instance for exactly one row, initialize it with the matching method, then pass it to AddLine() or deleteLine().

Initializer

Row represented

InitMixArg(…)

Playback, music-control, and FX automation timeline row.

InitNoteArg(…)

Rhythm-game note and rail row.

InitMusicArg(…)

Music BPM timeline row.

InitKeyValueArg(key, value)

Project-scoped auxiliary key/value row.

InitMixArg(type, details, ID, first, second, third, beat, subBeat, separate, Ebeat, EsubBeat, Eseparate) is positional. type and details use the PDJE_EDITOR_ARG enums; ID distinguishes rows; first through third have type-specific meanings from the Mix Data Table; and the final six integers are the start and end beat-grid tuples. GDScript does not use C++ parameter names to reorder this call.

One-Row Lifetime Rule

PDJE_EDITOR_ARG is a one-shot carrier. Do not call another initializer on an instance that has already been used. The wrapper stores optional typed payloads and a use flag on the same object; reuse can expose stale or partial state after an invalid initializer call.

var filter_row := PDJE_EDITOR_ARG.new()
filter_row.InitMixArg(
    PDJE_EDITOR_ARG.FILTER,
    PDJE_EDITOR_ARG.LOW,
    1,
    "0",
    "5000,1000,2000,3000,4000,5000,5500,6000",
    "",
    0, 0, 1,
    16, 0, 1)

if not editor.AddLine(filter_row):
    push_error("Mix row was rejected")

# A second row always receives a new carrier.
var note_row := PDJE_EDITOR_ARG.new()
note_row.InitNoteArg(
    "tap",
    0,
    "", "", "",
    4, 0, 1,
    4, 0, 1,
    1)
editor.AddLine(note_row)

The start tuple (beat, subBeat, separate) and end tuple (Ebeat, EsubBeat, Eseparate) define an event span. RailID on a note must match the logical rail configured in Judge_Engine.

Delete And Read Back Rows

Pass another fully initialized row to deleteLine(arg, skip_type, skip_detail). For mix rows, true makes matching ignore that field: skip_type ignores type, and skip_detail ignores details. The flags do not alter note, music, or key/value matching. A positive return is the number removed, zero means no match (or an uninitialized carrier), and a negative value reports a wrapper or save failure.

var filter_to_remove := PDJE_EDITOR_ARG.new()
filter_to_remove.InitMixArg(
    PDJE_EDITOR_ARG.FILTER,
    PDJE_EDITOR_ARG.LOW,
    1,
    "0",
    "5000,1000,2000,3000,4000,5000,5500,6000",
    "",
    0, 0, 1,
    16, 0, 1)

var removed: int = editor.deleteLine(filter_to_remove, false, false)
if removed <= 0:
    push_warning("No matching mix row was removed")

var all_rows: Dictionary = editor.getAll()
print(all_rows)

The wrapper also exposes getMixDatas(), getMusicBpmDatas(), getNoteDatas(), and getKeyValueDatas() to refresh individual internal collections before getAll() returns their Godot dictionaries.

The exact row columns, enum values, JSON keys, interpolation selectors, and EightPointValues contract are preserved in Editor_Format. Effect argument names are in FX_ARGS.

History And Time Travel

Editor history is split into four wrapper flags:

  • EditorWrapper.NOTE

  • EditorWrapper.KV

  • EditorWrapper.MIX

  • EditorWrapper.MUSIC

Undo(), Redo(), and GetLogWithJSONGraph() require music_name only with EditorWrapper.MUSIC; pass “” for NOTE, KV, and MIX. Undo(), Redo(), and Go() return the literal string “OK” on success and a diagnostic string on failure. Their return values are statuses, not commit OIDs.

editor.UpdateLog()

var graph_json: String = editor.GetLogWithJSONGraph(
    EditorWrapper.MIX,
    "")
var graph = JSON.parse_string(graph_json)

var undo_status: String = editor.Undo(EditorWrapper.MIX, "")
var redo_status: String = editor.Redo(EditorWrapper.MIX, "")
if undo_status != "OK" or redo_status != "OK":
    push_warning("History move failed")

if typeof(graph) == TYPE_DICTIONARY and graph.has("LINE"):
    var line_entries: Array = graph["LINE"]
    if not line_entries.is_empty():
        var target_oid: String = line_entries[0]["OID"]
        var go_status: String = editor.Go(EditorWrapper.MIX, target_oid)
        if go_status != "OK":
            push_warning(go_status)

UpdateLog() returns “OK” after refreshing all four histories. Then GetLogWithJSONGraph() returns a JSON string whose LINE entries identify line heads and whose LOGS entries describe commits with OID, predecessor, author, email, and timestamp fields. Treat a non-JSON diagnostic or empty JSON as failure.

GetDiff(flag, music_name, from_oid, to_oid) returns a Dictionary describing semantic additions and removals between two commits. Use OIDs from the same editor timeline and provide music_name for music history.

var diff: Dictionary = editor.GetDiff(
    EditorWrapper.MIX,
    "",
    old_oid,
    new_oid)

if diff.is_empty():
    push_warning("Diff failed or contains no semantic changes")

Render And Push

Rendering validates and converts project-local rows into payloads ready for the root database. Pushing performs the separate persistence step.

var render_message: String = editor.render("track-title")
if render_message != "RENDER COMPLETE":
    push_error(render_message)
    return

if not editor.pushTrackToRootDB("track-title"):
    push_error("Track push failed")

if not editor.pushToRootDB("song-title", "composer"):
    push_error("Music push failed")

Do not push when render reports a lint or conversion failure. Track push and music push are separate operations because the root database stores distinct payload families.

Preview Authored Content

demoPlayInit(frame_buffer_size, track_title) creates a PlayerWrapper from editor-authored content. Preview does not imply that content was pushed to the root database.

var preview: PlayerWrapper = editor.demoPlayInit(480, "track-title")
if preview != null and preview.Activate():
    # Audition the editor result.
    preview.Deactivate()

Release the preview before closing or destroying its editor project.

Destructive Project Removal

DESTROY_PROJECT() permanently removes the current editor project. There is no normal undo guarantee for this operation. Require explicit user confirmation and display the returned status string.

func destroy_editor_project_after_confirmation() -> void:
    var result: String = editor.DESTROY_PROJECT()
    print(result)
    editor = null
    engine.CloseEditor()

Contributor Model And Source Anchors

The wrapper projects template-heavy native editor families into a single PDJE_EDITOR_ARG carrier and integer history flags. Contributors must preserve these boundaries:

  • The project directory is a Git-backed working state, not the root database.

  • AddLine() and deleteLine() mutate typed project-local timelines.

  • render() validates and translates JSON working sets into native root-DB payloads.

  • pushTrackToRootDB() and pushToRootDB() perform explicit persistence.

  • History OIDs are scoped to their timeline; music history also has a music-name dimension.

  • Preview player lifetime is bounded by the editor and engine that created it.

Primary source anchors:

Native symbol lookup:

class editorObject

The main editor object for managing project data.

This class provides a high-level interface for interacting with the editor, including file I/O, version control, and data rendering.

bool editorObject::render(const UNSANITIZED &trackTitle, litedb &ROOTDB, UNSANITIZED &lint_msg)

Renders the project data to the root database.

Parameters:
  • trackTitle – The unsanitized title of the track to render.

  • ROOTDB – The root database to render to.

Returns:

true if the rendering was successful, false otherwise.

For exact native overloads, use Class editorObject after reading this workflow and Editor_Format.