1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//! # Chart Processor
//!
//! ## Y Coordinate Definition
//!
//! - In the default 4/4 time signature, the length of "one measure" is 1.
//! - BMS: When the section length is the default value, each `Track` has a length of 1. The section length comes from the `#XXX02:V` message per measure, where `V` represents the multiple of the default length (e.g., `#00302:0.5` means the 3rd measure has half the default length). Cumulative y is linearly converted with this multiple.
//! - BMSON: `info.resolution` is the number of pulses corresponding to a quarter note (1/4), so one measure length is `4 * resolution` pulses; all position y is normalized to measure units through `pulses / (4 * resolution)`.
//! - Speed (default 1.0): Only affects display coordinates (e.g., `visible_notes` `distance_to_hit`), that is, scales the y difference proportionally; does not change time progression and BPM values, nor the actual duration of that measure.
//!
//! ## Values and Formulas
//!
//! ### Core Constants
//!
//! - `BASE_VELOCITY_FACTOR = 1/240`: Base velocity factor (Y/sec per BPM)
//!
//! ### Visible Range Configuration
//!
//! **`VisibleRangePerBpm` creation:**
//! ```text
//! visible_range_per_bpm = reaction_time_seconds * 240 / base_bpm
//! ```
//!
//! **Simplified visible range (for display):**
//! ```text
//! visible_y_range = current_bpm * visible_range_per_bpm
//! ```
//!
//! **Full visible window (includes speed and playback ratio):**
//! ```text
//! visible_window_y = (current_speed * playback_ratio / 240) * reaction_time * base_bpm
//! ```
//!
//! This ensures events stay in visible window for exactly `reaction_time * base_bpm / current_bpm` duration.
//!
//! ### Time Progression
//!
//! **Velocity (Y units per second):**
//! ```text
//! velocity = (current_bpm / 240) * current_speed * playback_ratio
//! ```
//!
//! **Time integration (`step_to` algorithm):**
//! ```text
//! delta_y = velocity * elapsed_time_secs
//! time_to_event = distance_y / velocity
//! ```
//!
//! ### Display Coordinates
//!
//! **Display ratio (0 = judgment line, 1 = appearance position):**
//! ```text
//! display_ratio = (event_y - current_y) / visible_window_y * current_scroll
//! ```
//!
//! The value of this type is only affected by: current Y, Y visible range, and current Speed, Scroll values.
//!
//! ### Reaction Time
//!
//! **Calculate reaction time from visible range per BPM:**
//! ```text
//! reaction_time = visible_range_per_bpm / playhead_speed
//! where playhead_speed = 1/240
//! ```
use ;
use PathBuf;
use crate;
use TimeSpan;
use FinF64;
use NonNegativeF64;
use PositiveF64;
use ;
/// Maximum value for `NonNegativeF64` when overflow occurs
pub const MAX_NON_NEGATIVE_F64: NonNegativeF64 = new_const;
/// Maximum value for `FinF64` when overflow occurs
pub const MAX_FIN_F64: FinF64 = new_const;
/// Default BPM value
pub const DEFAULT_BPM: PositiveF64 = new_const;
/// Default speed factor
pub const DEFAULT_SPEED: PositiveF64 = ONE;
/// Playable chart data containing all precomputed information.
///
/// This structure is immutable and ready for playback. It can be used to create
/// multiple player instances. Note that this structure does NOT contain playback
/// state - playback state is managed by `ChartPlayer`.