zzzzv.SPMRating 1.2.0

dotnet add package zzzzv.SPMRating --version 1.2.0
                    
NuGet\Install-Package zzzzv.SPMRating -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="zzzzv.SPMRating" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="zzzzv.SPMRating" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="zzzzv.SPMRating" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add zzzzv.SPMRating --version 1.2.0
                    
#r "nuget: zzzzv.SPMRating, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package zzzzv.SPMRating@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=zzzzv.SPMRating&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=zzzzv.SPMRating&version=1.2.0
                    
Install as a Cake Tool

SPMRating.Net

性能提示:本移植没有做性能优化,单线程(非并行)运行并不比 Python 原版快。若需要吞吐量,请调用方自行并行。

SPM Rating —— osu!mania 难度模型的非官方 C# 移植。

算法、模型参数(detail / compact)与调校全部来自 Python 参考实现 spm_rating;本项目只做移植。

  • .NET 8,无第三方依赖
  • 与 Python 参考实现对同一张谱的相对偏差 < 1e-9(实测 ~1e-13)
  • 只支持 4K / 6K / 7K

用法

using SPMRating;

var data = ManiaData.FromFile(@"chart.osu");

double raw = SPMCalculator.Calculate(data);          // detail 模型,原速
double dt  = SPMCalculator.Calculate(data.DT());     // DT = rate 1.5
double ht  = SPMCalculator.Calculate(data.HT());     // HT = rate 0.75

SPMResult result = SPMCalculator.CalculateDetailed(data);
// result.RawScore / result.ReferenceScore / result.KeyCount / result.Heads / result.LnHeads

double any = SPMCalculator.CalculateAtRate(data, 1.1);   // 任意倍率

也可以跳过文件解析,直接给音符:

var data = ManiaData.FromNotes(
    new[]
    {
        new Note(key: 3, head: 1000.0, tail: -1.0),    // tail < 0 表示单点
        new Note(key: 5, head: 1100.0, tail: 1800.0),  // 长条
    },
    keyCount: 7,
    od: 8.0);

HT / DT

HT() = rate 0.75,DT() = rate 1.5,语义与 Python 的 rate_file(..., rate=r) 一致:时间按 t / rate 缩放,OD 走 rate_od,缩放后出现非整数毫秒时按 clock 相位加权平均(不是截断)。

键数

只支持 4K / 6K / 7K。其它键数(含 8K、9K、10K)抛 NotSupportedException,不会返回未标定的数字。

仓库结构

SPMRating                核心库(NuGet 包 zzzzv.SPMRating,包内 README 直接引用本文件)
SPMRating.Tests          xUnit 回归测试,golden 数据由 Python 参考实现生成
tools/                   校验、基准与 osu!.db 审计命令行

版权与致谢

模型、参数与算法归 SPM Rating 作者所有;其架构基于 sunnyxxy/Star-Rating-Rebirth。本仓库仅为 C# 移植实现。 本仓库的移植代码以 MIT 许可发布,见 LICENSE。osu! 是 ppy 的商标。

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 0 11/4/2026