RCT Help Documentation
Home
  • Getting Started
  • Script Metadata
  • Custom UI
  • Core API
  • Chart Class
  • Data Classes
  • Examples
  • Best Practices
Plugin Store
  • 简体中文
  • English
Home
  • Getting Started
  • Script Metadata
  • Custom UI
  • Core API
  • Chart Class
  • Data Classes
  • Examples
  • Best Practices
Plugin Store
  • 简体中文
  • English
  • API Reference

    • Home
    • Getting Started
    • Script Metadata
    • Custom UI Dialog
    • Core API
    • Chart Class
    • Data Classes
    • Example Scripts
    • Best Practices

Chart Class

The Chart class is the core class of the RCT API, representing complete chart data.

Properties

Basic Properties

chart.version      # int - Chart format version
chart.bpm          # List[BPM] - BPM change list
chart.speed        # List[Speed] - Speed change list
chart.notes        # List[Note] - Note list

Example:

from rct_api import get_current_chart

chart = get_current_chart()
print(f"Version: {chart.version}")
print(f"Number of BPMs: {len(chart.bpm)}")
print(f"Number of Speeds: {len(chart.speed)}")
print(f"Number of notes: {len(chart.notes)}")

Methods

sort()

Sort all notes by time.

Syntax

chart.sort()

Return Value

None

Description

  • Recommended to call after adding or modifying notes
  • Ensures notes are arranged in chronological order
  • Affects display and playback in the RCT editor

Example

from rct_api import get_current_chart, save_current_chart, Note

chart = get_current_chart()

# Add multiple notes
chart.add_note(Note.TAP, 3000, 90)
chart.add_note(Note.TAP, 1000, 45)
chart.add_note(Note.TAP, 2000, 180)

# Sort to ensure correct order
chart.sort()

save_current_chart(chart)

filter_notes_by_time()

Keep notes within the specified time range, delete notes outside the range.

Syntax

chart.filter_notes_by_time(min_time, max_time)

Parameters

ParameterTypeDescription
min_timefloatMinimum time (milliseconds)
max_timefloatMaximum time (milliseconds)

Return Value

None

Example

from rct_api import get_current_chart, save_current_chart

chart = get_current_chart()

# Keep only notes between 1000ms - 5000ms
original_count = len(chart.notes)
chart.filter_notes_by_time(1000, 5000)
new_count = len(chart.notes)

print(f"Deleted {original_count - new_count} notes")
save_current_chart(chart)

filter_notes_by_type()

Keep notes of specified types, delete other types.

Syntax

chart.filter_notes_by_type(types)

Parameters

ParameterTypeDescription
typesList[int]List of note types to keep

Return Value

None

Example

from rct_api import get_current_chart, save_current_chart, Note

chart = get_current_chart()

# Keep only Tap and Flick notes
chart.filter_notes_by_type([Note.TAP, Note.FLICK])

print(f"Kept {len(chart.notes)} notes")
save_current_chart(chart)

shift_time()

Shift the time of all notes, BPMs, and speeds by a specified offset.

Syntax

chart.shift_time(offset)

Parameters

ParameterTypeDescription
offsetfloatTime offset (milliseconds), positive to delay, negative to advance

Return Value

None

Example

from rct_api import get_current_chart, save_current_chart

chart = get_current_chart()

# Delay all content by 1 second
chart.shift_time(1000)

# Or advance by 0.5 seconds
# chart.shift_time(-500)

save_current_chart(chart)
print("Time shift completed")

add_note()

Add a new note to the chart.

Syntax

chart.add_note(type, time, degree, *extra)

Parameters

ParameterTypeDescription
typeintNote type (use constants like Note.TAP)
timefloatTime (milliseconds)
degreefloatAngle (degrees, 0-360)
*extravariesAdditional parameters based on note type

Return Value

None

Parameters for Different Note Types

Tap Note
chart.add_note(Note.TAP, time, degree)
Flick Note
chart.add_note(Note.FLICK, time, degree)
Catch Note
chart.add_note(Note.CATCH, time, degree)
Bomb Note
chart.add_note(Note.BOMB, time, degree)
Trail Note
chart.add_note(Note.TRAIL, time, degree, delta, prev_curv, next_curv)

Parameter descriptions:

  • degree: Starting angle
  • delta: Angle change
  • prev_curv: Previous curvature
  • next_curv: Next curvature
Rotate Note
chart.add_note(Note.ROTATE, time, degree, delta, prev_curv, next_curv)

Parameter descriptions:

  • degree: Starting angle
  • delta: Angle change
  • prev_curv: Previous curvature
  • next_curv: Next curvature
Slide Note
chart.add_note(Note.SLIDE, time, degree, slidetype, end_degree, snap, amount, prev_curv, next_curv)

Parameter descriptions:

  • degree: Starting angle
  • slidetype: Slide type
  • end_degree: Ending angle
  • snap: Snap parameter
  • amount: Amount parameter
  • prev_curv: Previous curvature
  • next_curv: Next curvature

Example

from rct_api import get_current_chart, save_current_chart, Note

chart = get_current_chart()

# Add Tap note
chart.add_note(Note.TAP, 1000, 45)

# Add Trail note (starting angle 0°, change 180°)
chart.add_note(Note.TRAIL, 2000, 0, 180, 0, 0)

# Add Slide note
chart.add_note(Note.SLIDE, 3000, 90, 1, 270, 4, 8, 0, 0)

chart.sort()
save_current_chart(chart)
print(f"Added 3 notes")

get_note_count_by_type()

Count the number of notes by type.

Syntax

counts = chart.get_note_count_by_type()

Return Value

Dictionary {note_type: count}, where key is note type and value is count.

Example

from rct_api import get_current_chart, Note

chart = get_current_chart()
counts = chart.get_note_count_by_type()

print("=== Note Statistics ===")
print(f"Tap: {counts.get(Note.TAP, 0)}")
print(f"Flick: {counts.get(Note.FLICK, 0)}")
print(f"Slide: {counts.get(Note.SLIDE, 0)}")
print(f"Trail: {counts.get(Note.TRAIL, 0)}")
print(f"Rotate: {counts.get(Note.ROTATE, 0)}")
print(f"Catch: {counts.get(Note.CATCH, 0)}")
print(f"Bomb: {counts.get(Note.BOMB, 0)}")

get_time_range()

Get the time range of the chart.

Syntax

min_time, max_time = chart.get_time_range()

Return Value

Tuple (min_time, max_time) containing minimum and maximum time (milliseconds).

Example

from rct_api import get_current_chart

chart = get_current_chart()
min_time, max_time = chart.get_time_range()

duration = max_time - min_time
print(f"Chart duration: {min_time}ms - {max_time}ms")
print(f"Total duration: {duration}ms ({duration/1000:.2f} seconds)")

find_distance_by_time()

Calculate the distance value at a specified time based on speed changes.

Syntax

distance = chart.find_distance_by_time(time)

Parameters

ParameterTypeDescription
timefloatTime (milliseconds)

Return Value

Float - Distance value

Example

from rct_api import get_current_chart

chart = get_current_chart()

# Calculate distance at 5000ms
distance = chart.find_distance_by_time(5000)
print(f"Distance at 5000ms: {distance}")

find_degree_by_time()

Interpolate the rotation angle at a specified time from Trail/Rotate notes.

Syntax

degree = chart.find_degree_by_time(time)

Parameters

ParameterTypeDescription
timefloatTime (milliseconds)

Return Value

Float - Angle (degrees)

Example

from rct_api import get_current_chart

chart = get_current_chart()

# Calculate rotation angle at 3500ms
degree = chart.find_degree_by_time(3500)
print(f"Angle at 3500ms: {degree}°")

Complete Example

Comprehensive Operation Example

# Description: Comprehensive Chart class method example

from rct_api import get_current_chart, save_current_chart, Note

def main():
    chart = get_current_chart()
    if not chart:
        print("Error: Unable to get chart")
        return
    
    # View basic information
    print(f"Version: {chart.version}")
    print(f"Number of notes: {len(chart.notes)}")
    
    # Get time range
    min_time, max_time = chart.get_time_range()
    print(f"Time range: {min_time}ms - {max_time}ms")
    
    # Count note types
    counts = chart.get_note_count_by_type()
    print("\n=== Note Statistics ===")
    for note_type, count in counts.items():
        print(f"Type {note_type}: {count} notes")
    
    # Add new notes
    chart.add_note(Note.TAP, 5000, 90)
    chart.add_note(Note.FLICK, 6000, 180)
    
    # Filter notes (keep only first half)
    midpoint = (min_time + max_time) / 2
    chart.filter_notes_by_time(min_time, midpoint)
    
    # Shift time
    chart.shift_time(1000)
    
    # Sort and save
    chart.sort()
    save_current_chart(chart)
    
    print(f"\nProcessing complete! Now have {len(chart.notes)} notes")

if __name__ == "__main__":
    main()
Prev
Core API
Next
Data Classes