A rating is a number the library shows for every chart: the difficulty. A mod never calculates it. A native calculator (Metron) does, on background workers, and the result is stored in a table that belongs to your mod. Your mod declares three things: where the numbers are stored (tables.register), how a calculator's result is presented (ratings.register), and when to calculate (ratings.backfill). The game's own ratings come from one such mod, pvng.ratings (content/mods/metron/main.ts), which is the best larger example.
This page assumes you have made a first mod.
A complete rating
This mod adds Quaver stars to the library: a table with one column, a rating with a colour scale and two panels, a filter, and the calls that fill the table. It also writes the stored stars of the chart being played on screen.
/// <reference path="../../../mods/sdk/modding.d.ts" />
// A difficulty rating for the library: Quaver stars, with a colour scale, two analysis
// panels and a library filter. The calculator is native (Metron); the mod only declares
// where the values are stored and how they are shown.
export default defineMod({
id: "rating-pack",
name: "Rating Pack",
version: "1.0.0",
apiVersion: 2,
author: "You",
description: "Quaver stars as a library rating, with panels, colours and a filter.",
setup() {
// The calculator's version is part of the declaration: read it, never copy it.
const calculator = metron.catalog().calculators.find((entry) => entry.id === "quaver-2025");
if (!calculator) return;
// 1. A table of this mod. The native calculation writes `stars` into it, one row per chart.
tables.register({
id: "quaver_rating",
columns: [{ name: "stars", kind: "number", indexed: true }],
});
// 2. The view the player picks in the library's rating menu.
ratings.register({
id: "quaver",
name: "Quaver · stars",
calculator: calculator.id,
unit: "★",
table: "quaver_rating",
column: "stars",
version: calculator.version,
// Data, never code: blue at 1 star, green at 3, red at 5 and beyond, mixed in sRGB.
colors: {
stops: [
{ at: 1, color: "#4fc0ff" },
{ at: 3, color: "#7cff4f" },
{ at: 5, color: "#ff4e6f" },
],
},
panels: [
{
kind: "metrics",
title: "Chart profile",
fields: [
{ label: "Stars", source: { kind: "column", column: "stars" }, unit: "★", decimals: 2 },
{ label: "Long notes", source: { kind: "chart", metric: "holdPercent" }, unit: "%" },
{ label: "Peak density", source: { kind: "chart", metric: "peakNps" }, unit: "NPS" },
],
},
{
kind: "timeline",
title: "Timeline",
series: [{ label: "Density", source: "density", unit: "NPS" }],
},
],
});
// 3. A filter on the same column: "Quaver · stars" in the library's search.
library.filters.register({
id: "quaver",
name: "Quaver · stars",
table: "quaver_rating",
column: "stars",
version: calculator.version,
unit: "★",
});
// 4. Nothing is calculated until the mod asks. `null` means the workers are busy: the
// next check catches up, since a backfill only looks at charts without a current row.
const rateAll = () => {
if (ratings.backfill({ id: "quaver" }) === null) log.warn("Rating workers are busy; the next check calculates it");
};
ctx.on("library.ready", rateAll);
ctx.on("library.chartsAdded", ({ chartIds, truncated }) => {
if (truncated) rateAll();
else ratings.backfill({ id: "quaver", charts: chartIds });
});
ctx.on("ratings.progress", (progress) => {
if (progress.finished && progress.error) log.warn(`${progress.id}: ${progress.error}`);
});
// 5. The stored value of the chart being played, for any HUD. `null` until it is rated.
ctx.on("game.songStart", () => {
const stars = metron.difficulty({ calculator: calculator.id });
hud.text({
id: "stars",
text: stars === null ? "" : `${stars.toFixed(2)} ★`,
layout: { x: 0.02, y: 0.04, anchor: "topLeft" },
style: { size: 0.025, color: "#ffffff" },
});
});
ctx.on("game.songEnd", () => hud.clear());
},
});
Copy the folder rating-pack into your mods folder (Mods page, Open folder). The library's rating menu now lists Quaver · stars. Pick it: the processing window shows a Calculating difficulty row, then the maps carry their stars. The rest of this page explains each part.
Tables
chartset and chart hold folders and difficulties; they have no star or MSD column. Your values go in a table of your own, declared with tables.register. There is one row per chart, removed with its chart, plus the columns you name.
tables.register({
id: "quaver_rating",
columns: [{ name: "stars", kind: "number", indexed: true }],
});
| Field | Rule |
|---|---|
id |
^[a-z][a-z0-9_]{0,31}$: lowercase letters, digits and underscores, starting with a letter. Unique in your mod. |
columns |
1 to 32 columns. |
column name |
The same pattern as id. chart_id, calc_version, chart_stamp, chart_size and error are reserved. |
column kind |
number or text. |
column indexed |
Optional. true lets the database index the column: set it on every column a filter or the difficulty sort reads. |
A mod registers at most 16 tables. Tables are isolated by mod: a rating, a filter or a tab cannot read another mod's table. A later version of your mod may add columns; an existing column never changes its type. A table is only filled by the native calculation of a rating that targets it, and only number columns are filled: a text column stays empty, so declare numbers.
tables.register is called from setup. Only mods register tables.
The rating declaration
ratings.register ties a calculator to a column of one of your tables and says how to show it.
| Field | Rule |
|---|---|
id |
1 to 32 characters among a-z, 0-9 and -, unique in your mod. The player's key is <modId>/<id> (rating-pack/quaver). |
name |
1 to 64 characters, shown in the library's rating menu. |
calculator |
A calculator id from metron.catalog(). |
unit |
1 to 16 characters after the value: ★, MSD. |
table, column |
A table of your mod and a number column of it. The calculator's main value goes there. |
version |
Must be the calculator's version (see calculators). |
panels |
Optional, at most 4: panels. |
colors |
Optional: a colour scale. |
patterns |
Optional, at most 12: pattern chips. |
A mod registers at most 16 ratings. ratings.register is called from setup, after the tables.register of its table.
Calculators
metron.catalog() returns the calculators the game offers: { calculators: [{ id, performance, version }] }. There are ten.
id |
Its difficulty | performance |
|---|---|---|
osu-2016 |
osu!mania stars, the 2016 version (the same values as osu-2018) |
no |
osu-2018 |
osu!mania stars, the 2018 version | pp |
osu-current |
osu!mania stars, the current version | no |
etterna-515 |
MinaCalc 527 MSD, with the seven skillsets | SSR |
quaver-2025 |
Quaver stars | no |
interlude-2025 |
Interlude stars | no |
daniel-2026 |
Daniel stars | no |
sunnyxxy-2024 |
SunnyXXY stars | no |
prism |
PrismCalc MSD converted to osu!mania stars: the stars Prism's pp are computed from | Prism pp |
prismcalc-1 |
PrismCalc: MinaCalc 527 with Prism's chordjack rework, MSD with the seven skillsets. The game's default rating | no |
version increases when a calculator's behaviour changes. A stored row from an older version is stale and is calculated again. Read it from the catalog, as the example does, and never copy a number: a rating whose version differs from the calculator's is refused (rating version must match the native calculator version). The shipped pvng.ratings registers eight of these (not osu-2018, whose difficulty osu-2016 already shows, and not prism).
Only the calculators that return seven skillsets (etterna-515 and prismcalc-1) fill more than the main column: see patterns.
Panels
panels is an ordered list of up to four analysis panels, shown in the library's Infos for the selected chart. A panel is data: the theme draws it, and a mod never supplies HTML, CSS or code. A value that is not available shows —, never a zero.
kind |
Shows | Fields |
|---|---|---|
metrics |
Values side by side | title, fields: 1 to 16 |
bars |
Values with comparison bars | title, fields: 1 to 16, optional max |
radar |
Named axes with filled bars | title, fields: 3 to 12, optional max |
timeline |
Series of the chart over time | title, series: 1 or 2 with different sources |
A title and a field label are 1 to 64 characters. A field has a source, a unit (0 to 16 characters, empty by default) and decimals (0 to 3, 1 by default). The source is one of:
{ kind: "column", column }: a number column of the rating's table, its main column included;{ kind: "chart", metric }: a real statistic of the chart, one ofnotes,holds,holdPercent(holds over notes, ×100; 0 for an empty chart),averageNps,peakNps,bpmMin,bpmMaxorduration(seconds). An analysis that is missing stays unavailable.
A timeline series is { label, source, unit } with source density or bpm; the values come from the chart analysis already made, so nothing is calculated on the interface.
max on bars and radar is a fixed scale, finite and in (0, 1000000]. Without it (or with null) the scale is automatic, with a maximum of at least 1. With max: 40, a value of 10 fills 25 % and any value of 40 or more fills 100 %. The number shown is never changed by the scale.
Colours
The colour of a difficulty is written nowhere in the interface: your rating declares it, as data. A rating without colors stays neutral, and an unavailable value is never coloured.
ratings.register({
id: "stars",
name: "Stars",
calculator: "quaver-2025",
unit: "★",
table: "quaver_rating",
column: "stars",
version: 1,
colors: {
scale: 1, // optional: the value is divided by `scale` before the stops are read
stops: [
{ at: 0, color: "#4290fb" },
{ at: 5, color: "warn" }, // a colour role of the active theme
{ at: 8, color: "#ffffff" },
],
},
});
stops: 1 to 16 points{ at, color }.atis finite, at most 1 000 000 in absolute value and strictly increasing. Between two stops the colour is mixed channel by channel in sRGB; beyond the ends, the nearest stop's colour applies.color:#rgbor#rrggbb(no transparency), or the name of a colour role of the active theme (accent,ok,warn…, the--pv-<role>tokens whose type iscolor). A role follows the theme when the player changes it. Anything else (red,rgb(…),var(--x)) is refused.scale: optional, finite, in(0, 1000000]. Values are divided by it, so the stops are written in that unit. The shipped MinaCalc ratings usescale: 4.5: a ramp written in osu! stars reads MSD ÷ 4.5.
A scale that is not valid (no stop, more than 16, a bad at, an order that does not increase, a refused colour, a bad scale) is dropped by itself: the rating registers, stays neutral, and your mod gets a warning that names the stop (rating stars: its colour scale was ignored, the rating stays neutral: stop 1: at must be greater than the previous stop's). An unknown property, in contrast, fails the whole declaration.
The colours apply to the map rows, the set markers, the selected map and every value, bar or radar point of the Infos panels.
Pattern chips
patterns lets the library name a chart's main pattern. Each entry points at a number column of the rating's table that scores one pattern:
| Field | Rule |
|---|---|
column |
A number column of the rating's table. Once per pattern. |
label |
The full name, 1 to 32 characters (Jumpstream). |
short |
The chip's text, 1 to 5 characters (js). |
color |
Optional: #rgb, #rrggbb or a colour role. Without it, the chip takes the difficulty's colour. |
The host takes the highest value above 0, and the second one when it is within 10 % of it, and shows the chips on the difficulty in the map list. Nothing is recalculated.
The values come from the calculator. For etterna-515 and prismcalc-1, the native calculation fills the main column and, in the same table, every number column whose name is one of these seven: stream, jumpstream, handstream, stamina, jackspeed, chordjack, technical. The other calculators fill the main column only.
const skills = ["stream", "jumpstream", "handstream", "stamina", "jackspeed", "chordjack", "technical"];
const calculator = metron.catalog().calculators.find((entry) => entry.id === "prismcalc-1");
if (calculator) {
tables.register({
id: "skills_rating",
columns: [{ name: "overall", kind: "number" }, ...skills.map((name) => ({ name, kind: "number" as const }))],
});
ratings.register({
id: "msd",
name: "PrismCalc · MSD",
calculator: calculator.id,
unit: "MSD",
table: "skills_rating",
column: "overall",
version: calculator.version,
patterns: [{ column: "jumpstream", label: "Jumpstream", short: "js", color: "#ff9f40" }],
panels: [
{
kind: "radar",
title: "Skillsets",
max: 40,
fields: skills.map((column) => ({ label: column, source: { kind: "column" as const, column }, unit: "MSD" })),
},
],
});
}
The complete mod, with the seven patterns and the filters, is the example of the library filters guide.
Calculating: ratings.backfill
Nothing is calculated until your mod asks. ratings.backfill({ id }) looks for the charts that have no current row (no row, another calculator version, or a chart file that changed) and queues them on the library's workers. With charts: number[] it looks at those charts only.
ctx.on("library.ready", () => {
ratings.backfill({ id: "quaver" });
});
ctx.on("library.chartsAdded", ({ chartIds, truncated }) => {
ratings.backfill(truncated ? { id: "quaver" } : { id: "quaver", charts: chartIds });
});
| Event | When | What to do |
|---|---|---|
library.ready |
After the interface and the mods have loaded; also on an explicit rescan and on the player's Recalculate ratings. | The global check: backfill every rating of the mod. |
library.chartAdd |
One per chart a scan added, with chartId. |
Rare: prefer the next event. |
library.chartsAdded |
A scan added charts (a pack was installed): chartIds (at most 8192) and truncated beyond. |
Backfill with charts: chartIds; the rest of the library is not looked at. When truncated, backfill everything. |
ratings.progress |
The requests of your mod only: requestId, id, done, total, failed, finished, error, ahead. |
React to the end of a request (finished). |
ratings.backfill returns a request number, or null when requests pile up (16 waiting per mod, 64 in all) or the workers refuse it. null is not a failure: the next check calculates what is missing. Asking for more than 8192 charts, an invalid chart id or an unknown rating id throws.
Do not draw a progress bar. The host publishes the last report of each request and the library's processing window shows it as a Calculating difficulty row, one line per rating, with the name you gave it, the time left, Waiting · n before (that is ahead), a pause while the player is in a play and, when a request fails, its message and a Retry button. ratings.progress is for your own logic.
Requests share the work. In each round the coordinator takes charts in turn from every queue, reads and decodes each chart once for all the ratings that wait for it, and writes each request's results in one batch. The calculation runs on a low-priority pool and never blocks the mods thread. A calculation that fails for one chart is stored as an error for it, shown —, and the others go on: no artificial value is made up.
Reading values during a play
const stars = metron.difficulty({ calculator: "quaver-2025" }); // number | null
const stored = game.song()?.ratings; // by calculator id
const chosen = game.settings()?.ratingSystem; // "<modId>/<id>" of the player's rating
metron.difficulty({ calculator }) returns the stored value of the chart being played, or null. It comes from the library, not from a new calculation, and it exists only for a calculator that some installed mod registers a rating for, once that chart has been rated. game.song()?.ratings holds all the values the library has for the chart, by calculator id. An unknown calculator id throws (unknown Metron calculator "x").
Performance: metron.performance
A performance is a score's value for a given accuracy: pp or SSR. Only three calculators have one: osu-2018 (pp), etterna-515 (SSR) and prism (Prism's pp). Nothing is derived from stars.
// `accuracy` is a fraction from 0 to 1, in the calculator's own score system.
const requestId = metron.performance({ calculator: "osu-2018", accuracy: 0.95 }); // number | null
ctx.on("metron.performanceResult", (result) => {
if (result.error) {
log.warn(result.error);
return;
}
hud.text({ id: "performance", text: `${(result.value ?? 0).toFixed(2)} ${result.unit}` });
});
The result arrives, to the requesting mod only, as metron.performanceResult: requestId, calculator, value, unit (pp or SSR) and error. A mod has 2 requests waiting at most (64 in all): beyond that the call returns null. A new chart invalidates the answers still on their way. The game thread and the mods thread never wait for the calculation.
The host does not convert the accuracy of the active judgement into an osu! or Etterna score: your mod gives the accuracy that fits the calculator.
When the game rates a score (the local leaderboard, the replay page), its Auto performance choice follows the judgement's accuracy rule: osuScoreV1 gives osu-2018 (pp), wife3 gives etterna-515 (SSR), the Prism set gives prism (pp), and every other set or custom preset has none. The player can pick any of the three for any judgement; a combination that does not use the calculator's own conventions is flagged nonstandard in the board. The online board is not affected: it always reads Prism plays.
In the library
- The rating menu lists every registered rating by
name, in registration order. The player's choice is the settingratingSystem, the key<modId>/<id>. The default ispvng.ratings/prismcalc-1. The player can hide a rating from the menu without disabling its mod. - Difficulty is shown for the chosen rating: the value and its unit on every difficulty, coloured by its
colors, with the pattern chips. The library's sort by difficulty and group by difficulty use the chosen rating's column. - Infos shows the chosen rating's
panelsfor the selected chart, at the playback rate the player picked. - Search: a library filter on the same column.
- Lifecycle: disabling or uninstalling a mod withdraws its ratings at once. If the chosen rating goes, the choice moves to PrismCalc (or the first rating left) and the player is told.
- Maps to play and the rate advice use the PrismCalc rating that declares patterns. Without a mod that declares it, they report no rating.
What you will see
A mistake in tables.register or ratings.register throws in setup and fails the mod's load. The messages are in English:
| Message | Cause |
|---|---|
table and column ids must use lowercase ASCII letters, digits and underscores (1–32 characters) |
An invalid table or column id. |
a mod table has 1–32 columns |
No column, or more than 32. |
duplicate or reserved mod column |
A repeated column, or chart_id, calc_version, chart_stamp, chart_size, error. |
a mod registers at most 16 uniquely named tables |
A seventeenth table, or the same id twice. |
tables.register is only available in a mod's setup |
Called later, or by a skin or a map script. |
rating table is not registered |
ratings.register before the tables.register of its table. |
rating must reference a registered numeric column of its mod |
A column that is missing, not a number, or in another table. |
unknown Metron calculator "x" |
A calculator that is not in the catalog. |
rating version must match the native calculator version |
A copied or stale version. |
rating id must be 1 to 32 characters among a-z, 0-9 and -, got "X" |
An invalid rating id. |
rating name must have 1 to 64 characters, got "" |
An empty or long name. |
rating unit must have 1 to 16 characters, got "" |
An empty or long unit. |
a rating has at most 4 panels |
A fifth panel. |
panel must have 3 to 12 fields |
The wrong number of fields (1 to 16 for metrics and bars). |
panel fields must reference registered numeric columns of the rating's table |
A column source that is not a number column of the table. |
panel field decimals must be between 0 and 3 |
decimals out of range. |
panel max must be finite and greater than 0, at most 1000000 |
A bad max. |
timeline must have 1 to 2 series / timeline series sources must be unique |
A timeline with 0 or 3 series, or twice the same source. |
a rating declares at most 12 patterns |
A thirteenth pattern. |
rating patterns must reference registered numeric columns of the rating's table |
A pattern on a missing or text column. |
rating pattern column x is declared twice |
Two patterns on one column. |
rating quaver is registered twice / a mod registers at most 16 ratings |
A repeated id, or a seventeenth rating. |
ratings.register is only available in a mod's setup |
Called later. |
And at run time:
| Message | Cause |
|---|---|
unknown registered rating |
ratings.backfill with an id that is not registered by this mod. |
too many charts in one scoped backfill / invalid chart id |
More than 8192 charts, or an id below 1. |
library workers are unavailable |
No library behind the host (a test, for instance). |
Metron has no performance calculator for quaver-2025 |
metron.performance with a calculator that has none. |
accuracy must be a fraction from 0 to 1 |
A percentage instead of a fraction. |
no decoded chart is playing |
metron.performance outside a play. |
Pitfalls
- Copying a calculator
versioninstead of reading it frommetron.catalog(): the declaration is refused as soon as the calculator changes. - Registering a rating in an event handler: the registries close once the mods have loaded.
- Declaring a
textcolumn and expecting values: only number columns are filled. - Expecting a skillset in a column with another name: only the seven names above are filled.
- Calling
ratings.backfillfor every chart of the library in a loop: one call per rating, andchartsfor a scoped check, is enough. - Asking
metron.difficultyfor a calculator no mod registers: it returnsnull. - Treating a percentage as the
accuracyofmetron.performance: it is a fraction.
See also
ratings.register,tables.register,ratings.backfill,metron.*in the SDK reference.- Library filters: search on your table's columns.
- Tabs and the local leaderboard: show your rating in a tab of the chart panel.
- Judgement sets: the accuracy rules behind the Auto performance.