rgchart
A library for parsing and writing charts for various rhythm games. It supports cross-platform usage including Web and Node.js environments via WebAssembly (WASM).
Table of Contents
Rust Usage
Installation
Add this to your Cargo.toml:
[]
= "0.0.13"
Or run:
API Reference
Parsing Charts
use parse;
// Parse an osu! chart from string to a generic mania chart
let osu_chart = from_osu_generic.expect;
// Parse a Stepmania chart from string to a generic mania chart
let sm_chart = from_sm_generic.expect;
// Parse a Quaver chart from string to a generic mania chart
let qua_chart = from_qua_generic.expect;
// Parse a fluXis chart from string to a generic mania chart
let fsc_chart = from_fsc_generic.expect;
to parse charts in their original structures:
use FscFile;
use OsuFile;
use QuaFile;
// Parse an osu! chart from string
let osu_chart = from_str.expect;
// Parse a Quaver chart from string
let qua_chart = from_str.expect;
// Parse a fluXis chart from string
let fsc_chart = from_str.expect;
Writing Charts
use parse;
use write;
use GenericManiaChart;
let chart: GenericManiaChart = from_osu_generic.expect;
// Write from generic mania chart to to osu! format
let osu_string = to_osu_generic;
// Write from generic mania chart to Stepmania format
let sm_string = to_sm_generic;
// Write from generic mania chart to Quaver format
let qua_string = to_qua_generic;
// Write from generic mania chart to fluXis format
let fsc_string = To_fsc_generic;
to write charts from their original structures:
use FscFile;
use OsuFile;
use QuaFile;
// Write from OsuFile to to osu! format
let osu_string = osu_chart.to_str_mania;
// assuming you don't have a soundbank
let osu_string = osu_chart.to_str_mania_no_soundbank;
// other modes for osu!, it will interprete the hit objects values as is for the mode you're writing to.
let osu_string = osu_chart.to_str;
// or
let osu_string = osu_chart.to_str_standard;
let osu_string = osu_chart.to_str_taiko;
let osu_string = osu_chart.to_str_catch;
// Write from QuaFile to Quaver format
let qua_string = qua_chart.to_str.expect;
// Write from FscFile to fluXis format
let fsc_string = fsc_chart.to_str.expect;
as of now you can't parse/write Sm files in their original structures.
Generic Mania Chart Structure
The GenericManiaChart contains all the relevant chart information:
The Metadata contains all the metadata related information about a specific chart, a lot of all of these can be empty:
The ChartInfo contains all the gameplay information about a specific chart:
The TimingPoints contains all the timing information such as bpm changes and sv:
The HitObjects struct contains all the hitobject information:
Here is how sounds are handled for Mania.
SoundBank contains all the sounds effects as well as a lookup for samples, it's done this way to be compatible with Quaver.
JavaScript/TypeScript Usage
Installation
For Node.js:
For web projects:
or
npm install @r2o3/rgchart-browser
then use as an ES module
API Reference
Initialization
// For ES modules
import * as rgchart from '@r2o3/rgchart'; // or if not on node use the path to rgchart.js
// or alternatively
const rgchart = await import
// For CommonJS
const rgchart = require;
you may need to do await rgchart.default() after importing if you've imported it in a script tag (with type="module") or you get an error like Uncaught TypeError: Cannot read properties of undefined (reading '__wbindgen_malloc')
As of now you can't parse/write using the original structures in JS/TS, will be supported in the near future.
Parsing Charts
// Parse an osu! chart from string to a generic mania chart
const OsuChart = rgchart.;
// Parse a Stepmania chart from string to a generic mania chart
const SmChart = rgchart.;
// Parse a Quaver chart from string to a generic mania chart
const QuaChart = rgchart.;
// Parse a fluXis chart from string to a generic mania chart
const FscChart = rgchart.;
Writing Charts
// write from generic mania chart to osu! format
const osuString = rgchart.;
// write from generic mania chart to Stepmania format
const smString = rgchart.;
// write from generic mania chart to Quaver format
const quaString = rgchart.;
// write from generic mania chart to fluXis format
const fscString = rgchart.;
TypeScript Types
The core chart library is written in Rust, but most types in the WASM bindings are generated for TypeScript.
Building
Rust Library
WASM Bindings
- Install wasm-pack:
[!IMPORTANT]
It's really recommended to have wasm-opt installed and added to path for the wasm build.
- Build the package:
- This will build it for both node and browser and the output will be in
dist-webanddist-nodedirectory.
License
RGC uses the MIT License for all its sibiling projects. See LICENSE for more information