MinaCalc Rust Bindings
Safe and ergonomic Rust bindings for the MinaCalc rhythm game difficulty calculator. This crate provides high-level Rust APIs for calculating difficulty scores in rhythm games like StepMania and Etterna.
Features
- Core Difficulty Calculation: Calculate MSD (MinaCalc Skill Difficulty) scores for rhythm game charts
- Multi-rate Support: Get difficulty scores for music rates from 0.7x to 2.0x
- Pattern Analysis: Analyze specific skillsets like stream, jumpstream, handstream, stamina, and more
- Thread-safe: Multi-threaded calculator pool for high-performance applications
- ROX Integration: Parse and analyze rhythm game chart files using the rhythm-open-exchange format
- Utility Functions: Helper functions for pattern analysis and difficulty comparison
- HashMap Conversion: Easy conversion to HashMap format for flexible data handling
Prerequisites
- Rust: Edition 2021 or later
- C++ Compiler: C++17 compatible compiler (MSVC on Windows, GCC/Clang on Unix)
- Build Tools:
ccandbindgen(automatically handled by Cargo)
Installation
Add this to your Cargo.toml:
[]
= "0.3.2"
Feature Flags
The crate supports several optional features:
[]
= { = "0.3.0", = ["hashmap", "thread", "rox", "utils"] }
hashmap(default): Provides HashMap conversion for MSD resultsthread: Provides thread-safe calculator poolrox: Provides chart parsing via rhythm-open-exchange (supports .sm, .osu, .rox formats)utils: Provides utility functions for pattern analysis
Quick Start
Basic Usage
use ;
HashMap Conversion
use ;
Chart File Analysis with ROX
use ;
use PathBuf;
Pattern Analysis with Utils
use ;
Thread-safe Calculator Pool
use ;
API Reference
Core Types
Calc: Main calculator instanceNote: Represents a note in a rhythm game chartAllRates: Contains MSD scores for all music rates (0.7x to 2.0x)SkillsetScores: Individual skillset scores (stream, jumpstream, etc.)
Skillsets
The calculator provides scores for these skillsets:
- Overall: General difficulty rating
- Stream: Consecutive note patterns
- Jumpstream: Jump patterns in streams
- Handstream: Two-handed patterns
- Stamina: Endurance requirements
- Jackspeed: Jack pattern speed
- Chordjack: Chord jack patterns
- Technical: Technical complexity
Music Rates
Scores are calculated for 14 different music rates:
- 0.7x, 0.8x, 0.9x, 1.0x, 1.1x, 1.2x, 1.3x, 1.4x, 1.5x, 1.6x, 1.7x, 1.8x, 1.9x, 2.0x
Examples
The crate includes several examples demonstrating different use cases:
basic_usage: Basic MSD calculationrox: Chart file analysis with ROXutils_example: Pattern analysis utilities
Run examples with:
# Basic usage
# ROX chart analysis (requires rox feature)
# Utils example (requires utils feature)
Error Handling
The crate uses custom error types for different failure modes:
MinaCalcError: General calculation errorsRoxError: Chart file parsing errors
All functions return Result<T, E> for proper error handling.
Thread Safety
The Calc type is not Send or Sync by default. For multi-threaded applications, use the CalcPool from the thread feature, which provides a thread-safe pool of calculator instances.
Performance
- Single-threaded: Optimized for single-threaded applications
- Multi-threaded: Use
CalcPoolfor concurrent calculations - Memory: Efficient memory usage with minimal allocations
- Caching: Calculator instances can be reused for multiple calculations
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- MinaCalc: The original C++ difficulty calculator
- Etterna: The rhythm game that inspired this project
- Rust Community: For the excellent tooling and ecosystem
Changelog
v0.3.1
- Added C# bindings (
bindings/csharp) - Added Python bindings (
bindings/python) - Added
apifeature for FFI exports (file path and string content support) - Added GitHub Actions release workflow (PyPI, Crates.io, NuGet)
v0.3.0
- Removed deprecated
osufeature (useroxinstead for chart parsing) - Updated rhythm-open-exchange dependency
- Updated MinaCalc to 515 version
v0.2.1
- Added
utilsfeature with pattern analysis functions
v0.2.0
- Added
roxfeature for universal chart parsing - Added
threadfeature for thread-safe calculator pools - Improved HashMap conversion utilities
- Enhanced documentation and examples
- Improved type naming (
AllRatesinstead ofMsdForAllRates) - Enhanced error handling and documentation
- Fixed namespace conflicts in bindings
v0.1.0
- Initial release with basic MSD calculation
- Core calculator functionality
- Basic Rust bindings for MinaCalc