@@ -15,8 +15,8 @@ use crate::{
1515 event:: { NoteMarks , Pitch , Tempo , Ticks , TimeSignature , Tuning , ValidationError , Velocity } ,
1616 fretboard:: { self , assign_inferred_positions, FingeringWeights } ,
1717 score:: {
18- AtomEvent , AtomNote , EventGroup , EventGroupKind , ImportWarning , LossReport , MasterBar ,
19- RepeatMarker , Score , SourceMeta , Track as ScoreTrack , Voice ,
18+ index_from_ordinal , AtomEvent , AtomNote , EventGroup , EventGroupKind , ImportWarning ,
19+ LossReport , MasterBar , RepeatMarker , Score , SourceMeta , Track as ScoreTrack , Voice ,
2020 } ,
2121 slice:: TickRange ,
2222} ;
@@ -345,7 +345,7 @@ fn abs_to_delta(
345345/// other tempo converts to its nearest in-range value and records a
346346/// [`ImportWarning::TempoApproximated`] on `loss` (S16 Phase 4-pre A: an
347347/// approximation is a reported fact, never a silent rounding).
348- fn tempo_to_micros ( tempo : Tempo , bar_index : usize , loss : & mut LossReport ) -> u32 {
348+ fn tempo_to_micros ( tempo : Tempo , bar_index : u64 , loss : & mut LossReport ) -> u32 {
349349 let max_u24 = u32:: from ( u24:: max_value ( ) ) ;
350350 if let Some ( exact) = tempo. to_micros_per_quarter_exact ( ) {
351351 if ( 1 ..=max_u24) . contains ( & exact) {
@@ -513,7 +513,7 @@ fn build_master_bars(
513513 . map_err ( |_| MidiError :: TickOverflow ) ?;
514514
515515 master_bars. push ( MasterBar {
516- index,
516+ index : index_from_ordinal ( index ) ,
517517 tick_range,
518518 time_signature : sig,
519519 tempo,
@@ -545,7 +545,7 @@ fn build_score_track(
545545 let mut loss = LossReport :: new ( ) ;
546546 let name = name_result. unwrap_or_else ( |( ) | {
547547 loss. add ( ImportWarning :: TrackNameInvalidUtf8 {
548- track_index : raw_idx,
548+ track_index : index_from_ordinal ( raw_idx) ,
549549 } ) ;
550550 None
551551 } ) ;
@@ -829,6 +829,7 @@ mod tests {
829829 bar_ticks, build_master_bars, build_score_meta_track, export_score, import_score,
830830 tempo_to_micros, MidiError , Ppqn ,
831831 } ;
832+ use crate :: score:: index_from_ordinal;
832833 use crate :: {
833834 event:: { NoteMarks , Pitch , Tempo , Ticks , TimeSignature , Tuning , Velocity } ,
834835 score:: {
@@ -893,7 +894,7 @@ mod tests {
893894 // different exact tempo — projected again (clean), no second event.
894895 let tempo_same_mpq = Tempo :: from_micros_per_quarter ( 495_868 ) . expect ( "495 868 µs is valid" ) ;
895896 let bar = |index : usize , tempo : Tempo | MasterBar {
896- index,
897+ index : index_from_ordinal ( index ) ,
897898 tick_range : TickRange :: new (
898899 Ticks ( u32:: try_from ( index) . expect ( "small" ) * 1920 ) ,
899900 Ticks ( ( u32:: try_from ( index) . expect ( "small" ) + 1 ) * 1920 ) ,
@@ -953,7 +954,7 @@ mod tests {
953954 ) ;
954955
955956 let bar = |index : usize , tempo : Tempo | MasterBar {
956- index,
957+ index : index_from_ordinal ( index ) ,
957958 tick_range : TickRange :: new (
958959 Ticks ( u32:: try_from ( index) . expect ( "small" ) * 1920 ) ,
959960 Ticks ( ( u32:: try_from ( index) . expect ( "small" ) + 1 ) * 1920 ) ,
0 commit comments