1212
1313pub use macroquad:: color:: Color ;
1414
15- pub const NOTE_WIDTH_RATIO_BASE : f32 = 0.13175016 ;
16- pub const HEIGHT_RATIO : f32 = 0.83175 ;
15+ pub const NOTE_WIDTH_RATIO_BASE : f64 = 0.13175016 ;
16+ pub const HEIGHT_RATIO : f64 = 0.83175 ;
1717
18- pub const EPS : f32 = 1e-5 ;
18+ pub const EPS : f64 = 1e-5 ;
1919
2020pub type Point = nalgebra:: Point2 < f32 > ;
2121pub type Vector = nalgebra:: Vector2 < f32 > ;
@@ -95,16 +95,16 @@ impl Default for Triple {
9595}
9696
9797impl Triple {
98- pub fn beats ( & self ) -> f32 {
99- self . 0 as f32 + self . 1 as f32 / self . 2 as f32
98+ pub fn beats ( & self ) -> f64 {
99+ self . 0 as f64 + self . 1 as f64 / self . 2 as f64
100100 }
101101}
102102
103103#[ derive( Default ) ] // the default is a dummy
104104pub struct BpmList {
105105 /// (beats, time, bpm)
106106 /// time in seconds
107- elements : Vec < ( f32 , f32 , f32 ) > ,
107+ elements : Vec < ( f64 , f64 , f64 ) > ,
108108 /// cursor for searching, value is the index of `elements`
109109 cursor : usize ,
110110}
@@ -113,11 +113,11 @@ impl BpmList {
113113 /// Create a new BpmList from a list of (beats, bpm) pairs
114114 ///
115115 /// Basically just calculate the time for each pair(key frame)
116- pub fn new ( ranges : Vec < ( f32 , f32 ) > ) -> Self {
116+ pub fn new ( ranges : Vec < ( f64 , f64 ) > ) -> Self {
117117 let mut elements = Vec :: new ( ) ;
118118 let mut time = 0.0 ;
119119 let mut last_beats = 0.0 ;
120- let mut last_bpm: Option < f32 > = None ;
120+ let mut last_bpm: Option < f64 > = None ;
121121 for ( now_beats, bpm) in ranges {
122122 if let Some ( bpm) = last_bpm {
123123 time += ( now_beats - last_beats) * ( 60. / bpm) ;
@@ -130,7 +130,7 @@ impl BpmList {
130130 }
131131
132132 /// Get the time in seconds for a given beats
133- pub fn time_beats ( & mut self , beats : f32 ) -> f32 {
133+ pub fn time_beats ( & mut self , beats : f64 ) -> f64 {
134134 while let Some ( kf) = self . elements . get ( self . cursor + 1 ) {
135135 if kf. 0 > beats {
136136 break ;
@@ -145,12 +145,12 @@ impl BpmList {
145145 }
146146
147147 /// Get the time in seconds for a given `i + n / d`
148- pub fn time ( & mut self , triple : & Triple ) -> f32 {
148+ pub fn time ( & mut self , triple : & Triple ) -> f64 {
149149 self . time_beats ( triple. beats ( ) )
150150 }
151151
152152 /// Get the beat coordinate for a given time in seconds
153- pub fn beat ( & mut self , time : f32 ) -> f32 {
153+ pub fn beat ( & mut self , time : f64 ) -> f64 {
154154 while let Some ( kf) = self . elements . get ( self . cursor + 1 ) {
155155 if kf. 1 > time {
156156 break ;
0 commit comments