USC Analyzer
A Python library for analyzing USC (Universal Sekai Chart) files.
Features
- Parse USC files - Load and validate USC chart files with Pydantic models
- Analyze charts - Get detailed statistics about notes, BPM, and chart metadata
- Validate structure - Check for common issues in USC files
- CLI tool - Command-line interface for quick analysis
- Type-safe - Full type hints and Pydantic validation
Installation
pip install usc-analyzer
Quick Start
Python API
from usc_analyzer import USCAnalyzer
# Load and analyze a USC file
analyzer = USCAnalyzer.from_file("chart.usc")
# Get note statistics
stats = analyzer.analyze_notes()
print(f"Total notes: {stats.total_notes}")
print(f"Single notes: {stats.total_single}")
print(f"Slides: {stats.slides}")
print(f"Flicks: {stats.total_flick}")
# Get chart information
info = analyzer.analyze_chart()
print(f"BPM: {info.initial_bpm}")
print(f"Duration: {info.duration_beats} beats")
# Validate the file
issues = analyzer.validate()
if issues:
for issue in issues:
print(f"Warning: {issue}")
# Print full summary
print(analyzer.summary())
CLI Tool
# Show summary of a chart
usc-analyze chart.usc
# Show detailed note statistics
usc-analyze chart.usc --notes
# Show chart information
usc-analyze chart.usc --chart
# Validate the file
usc-analyze chart.usc --validate
# Show BPM changes
usc-analyze chart.usc --bpm
# Output as JSON
usc-analyze chart.usc --json
USC File Format
USC (Universal Sekai Chart) files are JSON-based chart files for rhythm games. They contain:
- Notes: Single notes (tap, flick, trace), damage notes
- Slides: Long notes with multiple connection points
- Guides: Visual guide lines
- BPM: Tempo changes
- Time Scale Groups: Note speed control
For detailed format specification, see USC.md.
API Reference
USCAnalyzer
Main analyzer class for USC files.
# Load from file
analyzer = USCAnalyzer.from_file("chart.usc")
# Load from dict
analyzer = USCAnalyzer.from_dict(data)
# Load from JSON string
analyzer = USCAnalyzer.from_json(json_str)
Methods
analyze_notes() -> NoteStatistics- Get detailed note statisticsanalyze_chart() -> ChartInfo- Get chart metadataget_bpm_changes() -> list[BPM]- Get all BPM changesget_time_scale_groups() -> list[TimeScaleGroup]- Get time scale groupsvalidate() -> list[str]- Validate file structuresummary() -> str- Generate a summary report
Data Classes
NoteStatistics
Contains detailed note counts:
total_notes- Total playable notestotal_single- Single notes (tap, flick, trace)normal_tap,critical_tap- Tap notesnormal_trace,critical_trace- Trace notestotal_flick- Flick notesdamage_notes- Damage notesslides- Slide/long notesguides- Guide notes
ChartInfo
Contains chart metadata:
version- USC file versionoffset- Time offsetinitial_bpm- Starting BPMbpm_changes- Number of BPM changesmin_bpm,max_bpm- BPM rangetime_scale_groups- Number of time scale groupsmin_beat,max_beat- Chart beat rangeduration_beats,duration_ticks- Chart duration
Utility Functions
from usc_analyzer import beat_to_tick, tick_to_beat, compare_beats_tick
# Convert between beats and ticks
tick = beat_to_tick(1.5) # 1.5 beats -> 720 ticks
beat = tick_to_beat(720) # 720 ticks -> 1.5 beats
# Compare beats using tick conversion (recommended)
if compare_beats_tick(beat1, beat2):
print("Beats are equal")
Development
Setup
# Clone the repository
git clone https://github.com/yourusername/usc-analyzer.git
cd usc-analyzer
# Install dependencies
pip install -e ".[dev]"
Running Tests
pytest
Code Formatting
# Format with black
black .
# Lint with ruff
ruff check .
# Type check with mypy
mypy usc_analyzer
License
MIT License - see LICENSE for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Links
Metadata
Release files for usc-analyzer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| usc_analyzer-0.1.0.tar.gz | 10.3 kB | Without provenance | Details for usc_analyzer-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| usc_analyzer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for usc_analyzer-0.1.0-py3-none-any.whl |
Total release size: 22.3 kB
Release files / usc_analyzer-0.1.0.tar.gz
| Download URL | usc_analyzer-0.1.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7a32968d9ec940d9e3fa24773c72f3efc4cde7e10948491ce68fc867c6a497a
|
|
BLAKE2b-256 checksum How to use checksums |
c8b7a1202e35119648df892d407714ac10e104779c9be8ebeee379c2abf7d6d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.2","id":"zara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / usc_analyzer-0.1.0-py3-none-any.whl
| Download URL | usc_analyzer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8476baeab4f0470c613cc0cf5454dabb7fc6626b4f9f2f50a810e12142eb9994
|
|
BLAKE2b-256 checksum How to use checksums |
c5b753e404ff6796bcf1cf64f14cb179f8c8508251312b4cec627f6e073f1339
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.2","id":"zara","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for usc-analyzer 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.