RhythmBase.Addition
1.0.5
dotnet add package RhythmBase.Addition --version 1.0.5
NuGet\Install-Package RhythmBase.Addition -Version 1.0.5
<PackageReference Include="RhythmBase.Addition" Version="1.0.5" />
<PackageVersion Include="RhythmBase.Addition" Version="1.0.5" />
<PackageReference Include="RhythmBase.Addition" />
paket add RhythmBase.Addition --version 1.0.5
#r "nuget: RhythmBase.Addition, 1.0.5"
#:package RhythmBase.Addition@1.0.5
#addin nuget:?package=RhythmBase.Addition&version=1.0.5
#tool nuget:?package=RhythmBase.Addition&version=1.0.5
RhythmBase.Addition
Additional tools for RhythmBase, focused on rhythm-game level development and audio analysis.
Features
- AssetManager: Asset management for RhythmBase.
- WaveDataUtils: Read wave data from audio files, including Mel spectrogram, spectral flux, BPM candidates, and first-tick detection.
- TempoDetector: Onset-based BPM detection with:
- global BPM candidates with offsets and fitness values;
- variable-tempo detection using a joint BPM + phase Viterbi tracker;
- per-segment BPM, offset, and fitness output;
- phase-continuous segments, with a zero relative offset mode for chart generation.
- SpriteSheetCanvas: Build sprite sheets from images of different sizes.
- ParticleGenerator: Create and manage particle effects.
- DecorationPool: Reuse frequently shown or hidden decorations.
- RDExpressionBuilder: Build Rhythm Doctor expressions with IDE completion and simple automatic simplification.
- PerspectiveBuilder: Helpers for perspective decorations.
Requirements
- .NET 8.0
- RhythmBase
Installation
dotnet add package RhythmBase.Addition
Quick Start
Read audio and detect BPM
using RhythmBase.Global.Utils;
using RhythmBase.Global.Utils.Tempo;
var (bpm, firstTickSeconds) = WaveDataUtils.Process("song.ogg");
Console.WriteLine($"BPM: {bpm}, first tick: {firstTickSeconds}s");
Inspect global BPM candidates
using TempoDetector detector = new(sampleRate, monoSamples);
detector.Execute();
foreach (TempoResult candidate in detector.Results)
{
Console.WriteLine(
$"BPM={candidate.Bpm:F3}, " +
$"offset={candidate.Offset:F4}, " +
$"fitness={candidate.Fitness:F4}");
}
Results can contain more than one candidate. Candidates are sorted by fitness and may include metrical alternatives such as half-time or double-time interpretations.
Detect variable tempo
using TempoDetector detector = new(sampleRate, monoSamples);
detector.Config.VariableTempoZeroRelativeOffset = true;
List<TempoSegment> segments = detector.DetectVariableTempo();
foreach (TempoSegment segment in segments)
{
Console.WriteLine(
$"[{segment.StartSeconds:F2}, {segment.EndSeconds:F2}] " +
$"BPM={segment.Bpm:F3}, offset={segment.Offset:F4}, " +
$"fitness={segment.Fitness:F3}");
}
The variable-tempo detector:
- runs onset detection once for the whole track;
- scores local BPM/phase hypotheses;
- tracks the best BPM and phase path with Viterbi;
- falls back to a single global BPM when the constant-tempo model is sufficient;
- emits
TempoSegmententries with global start/end times and offsets.
By default, VariableTempoZeroRelativeOffset is enabled. For every segment after the first, the returned offset is anchored to the segment start, so the relative offset is 0.
Useful configuration:
detector.Config.MinBpm = 40.0;
detector.Config.MaxBpm = 240.0;
detector.Config.VariableTempoWindowSeconds = 12.0;
detector.Config.VariableTempoFrameSeconds = 1.0;
detector.Config.VariableTempoPhaseBins = 8;
detector.Config.VariableTempoPhasePenalty = 1.0;
detector.Config.VariableTempoZeroRelativeOffset = true;
License
RhythmBase.Addition is licensed under the GNU Lesser General Public License v3.0. See LICENSE.txt.
Related Projects
- RhythmBase - Core library for rhythm-game level manipulation.
RhythmBase.Addition(中文)
为 RhythmBase 提供额外工具,主要用于音游关卡开发和音频分析。
功能
- AssetManager:RhythmBase 的资源管理工具。
- WaveDataUtils:读取音频波形数据,包括 Mel 频谱、谱通量、BPM 候选和首拍检测。
- TempoDetector:基于 onset 的 BPM 检测:
- 输出全局 BPM 候选、offset 和 fitness;
- 使用 BPM + 相位联合 Viterbi 进行变速检测;
- 输出每个分段的 BPM、offset 和 fitness;
- 支持相位连续分段,并支持为谱面生成提供的“后续分段相对 offset 为 0”模式。
- SpriteSheetCanvas:将不同尺寸的图片合并为精灵图。
- ParticleGenerator:创建和管理粒子特效。
- DecorationPool:管理频繁显示/隐藏的可复用装饰。
- RDExpressionBuilder:借助 IDE 智能提示构建 Rhythm Doctor 表达式,并支持简单的自动化简。
- PerspectiveBuilder:构建带透视效果的装饰。
环境要求
- .NET 8.0
- RhythmBase
安装
dotnet add package RhythmBase.Addition
快速开始
读取音频并检测 BPM
using RhythmBase.Global.Utils;
using RhythmBase.Global.Utils.Tempo;
var (bpm, firstTickSeconds) = WaveDataUtils.Process("song.ogg");
Console.WriteLine($"BPM: {bpm}, first tick: {firstTickSeconds}s");
查看全局 BPM 候选
using TempoDetector detector = new(sampleRate, monoSamples);
detector.Execute();
foreach (TempoResult candidate in detector.Results)
{
Console.WriteLine(
$"BPM={candidate.Bpm:F3}, " +
$"offset={candidate.Offset:F4}, " +
$"fitness={candidate.Fitness:F4}");
}
Results 可能包含多个候选,按 fitness 排序,可能同时包含半速、倍速等节拍解释。
检测变速
using TempoDetector detector = new(sampleRate, monoSamples);
detector.Config.VariableTempoZeroRelativeOffset = true;
List<TempoSegment> segments = detector.DetectVariableTempo();
foreach (TempoSegment segment in segments)
{
Console.WriteLine(
$"[{segment.StartSeconds:F2}, {segment.EndSeconds:F2}] " +
$"BPM={segment.Bpm:F3}, offset={segment.Offset:F4}, " +
$"fitness={segment.Fitness:F3}");
}
变速检测流程:
- 全曲只做一次 onset 检测;
- 对局部 BPM/相位假设评分;
- 使用 Viterbi 跟踪最优 BPM 和相位路径;
- 当常数 BPM 模型已经足够时,自动回退为单段结果;
- 输出带全局起止时间和 offset 的
TempoSegment。
默认启用 VariableTempoZeroRelativeOffset。从第二段开始,返回的 offset 会锚定到分段起点,因此相对 offset 为 0。
常用配置:
detector.Config.MinBpm = 40.0;
detector.Config.MaxBpm = 240.0;
detector.Config.VariableTempoWindowSeconds = 12.0;
detector.Config.VariableTempoFrameSeconds = 1.0;
detector.Config.VariableTempoPhaseBins = 8;
detector.Config.VariableTempoPhasePenalty = 1.0;
detector.Config.VariableTempoZeroRelativeOffset = true;
许可证
RhythmBase.Addition 使用 GNU Lesser General Public License v3.0 许可证。详见 LICENSE.txt。
相关项目
- RhythmBase - 音游关卡操作核心库。
| Product | Versions 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. |
-
net8.0
- Brc (>= 1.0.0)
- MathNet.Numerics (>= 5.0.0)
- NAudio (>= 2.3.0)
- NAudio.Vorbis (>= 1.5.0)
- PrimitiveSharp.Core (>= 1.0.3)
- RhythmBase.RhythmDoctor (>= 1.0.5)
- SkiaSharp (>= 3.119.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.0.5: Added improved BPM detection and variable-tempo tracking; added package README and license.