@@ -82,16 +82,16 @@ public void GetFromJson_V2BpmInfo()
8282 [ Test ]
8383 public void GetFromJson_V4AudioData ( )
8484 {
85- var bpmInfo = V4AudioData . GetFromJson ( JSON . Parse ( audioDataJson ) ) ;
85+ var bpmInfo = V4AudioData . GetFromJson ( JSON . Parse ( audioDataJson ) ) ;
8686
87- AssertCommonGetFromJson ( bpmInfo ) ;
88-
89- Assert . AreEqual ( "4.0.0" , bpmInfo . Version ) ;
87+ AssertCommonGetFromJson ( bpmInfo ) ;
88+
89+ Assert . AreEqual ( "4.0.0" , bpmInfo . Version ) ;
9090
91- Assert . AreEqual ( 1 , bpmInfo . LufsRegions . Count ) ;
92- Assert . AreEqual ( 0 , bpmInfo . LufsRegions [ 0 ] . StartSampleIndex ) ;
93- Assert . AreEqual ( 882000 , bpmInfo . LufsRegions [ 0 ] . EndSampleIndex ) ;
94- Assert . AreEqual ( 3.1f , bpmInfo . LufsRegions [ 0 ] . Loudness ) ;
91+ Assert . AreEqual ( 1 , bpmInfo . LufsRegions . Count ) ;
92+ Assert . AreEqual ( 0 , bpmInfo . LufsRegions [ 0 ] . StartSampleIndex ) ;
93+ Assert . AreEqual ( 882000 , bpmInfo . LufsRegions [ 0 ] . EndSampleIndex ) ;
94+ Assert . AreEqual ( 3.1f , bpmInfo . LufsRegions [ 0 ] . Loudness ) ;
9595 }
9696
9797 private void AssertCommonGetFromJson ( BaseBpmInfo bpmInfo )
@@ -162,13 +162,17 @@ public void GetBpmInfoRegions()
162162 var songBpm = 60f ;
163163 var audioFrequency = 44100 ;
164164 var audiosamples = 44100 * 20 ;
165- var bpmEvents = new List < BaseBpmEvent >
165+ var difficulty = new BaseDifficulty
166166 {
167- new ( ) { JsonTime = 0 , Bpm = 60 } ,
168- new ( ) { JsonTime = 10 , Bpm = 120 }
167+ BpmEvents = new List < BaseBpmEvent >
168+ {
169+ new ( ) { JsonTime = 0 , Bpm = 60 } ,
170+ new ( ) { JsonTime = 10 , Bpm = 120 }
171+ }
169172 } ;
173+ difficulty . BootstrapBpmEvents ( songBpm ) ;
170174
171- var regions = BaseBpmInfo . GetBpmInfoRegions ( bpmEvents , songBpm , audiosamples , audioFrequency ) ;
175+ var regions = BaseBpmInfo . GetBpmInfoRegions ( difficulty . BpmEvents , songBpm , audiosamples , audioFrequency ) ;
172176 Assert . AreEqual ( 2 , regions . Count ) ;
173177
174178 Assert . AreEqual ( 0f , regions [ 0 ] . StartBeat ) ;
@@ -205,27 +209,41 @@ public void ConversionDoesNotIntroduceDriftOverTime()
205209 var songBpm = 60f ;
206210 var audioFrequency = 44100 ;
207211 var audiosamples = 44100 * 20 ;
208-
209- var initialBpmEvents = new List < BaseBpmEvent >
212+
213+ var initialDifficulty = new BaseDifficulty
210214 {
211- new ( ) { JsonTime = 0 , Bpm = 60 } ,
212- new ( ) { JsonTime = 10 , Bpm = 120 }
215+ BpmEvents = new List < BaseBpmEvent >
216+ {
217+ new ( ) { JsonTime = 0 , Bpm = 60 } ,
218+ new ( ) { JsonTime = 10 , Bpm = 120 }
219+ }
213220 } ;
221+ initialDifficulty . BootstrapBpmEvents ( songBpm ) ;
222+
223+ var initialBpmEvents = initialDifficulty . BpmEvents ;
214224 var initialRegions = BaseBpmInfo . GetBpmInfoRegions ( initialBpmEvents , songBpm , audiosamples , audioFrequency ) ;
215225
216226 // Loop conversion to and from a bunch of times
217- List < BaseBpmEvent > bpmEvents = new List < BaseBpmEvent >
227+ var difficulty = new BaseDifficulty
218228 {
219- new ( ) { JsonTime = 0 , Bpm = 60 } ,
220- new ( ) { JsonTime = 10 , Bpm = 120 }
229+ BpmEvents = new List < BaseBpmEvent >
230+ {
231+ new ( ) { JsonTime = 0 , Bpm = 60 } ,
232+ new ( ) { JsonTime = 10 , Bpm = 120 }
233+ }
221234 } ;
235+ difficulty . BootstrapBpmEvents ( songBpm ) ;
236+
222237 List < BpmInfoBpmRegion > regions = new List < BpmInfoBpmRegion > ( ) ;
238+
223239 for ( var i = 0 ; i < 100 ; i ++ )
224240 {
225- regions = BaseBpmInfo . GetBpmInfoRegions ( bpmEvents , songBpm , audiosamples , audioFrequency ) ;
226- bpmEvents = BaseBpmInfo . GetBpmEvents ( regions , audioFrequency ) ;
241+ regions = BaseBpmInfo . GetBpmInfoRegions ( difficulty . BpmEvents , songBpm , audiosamples , audioFrequency ) ;
242+ difficulty . BpmEvents = BaseBpmInfo . GetBpmEvents ( regions , audioFrequency ) ;
243+ difficulty . BootstrapBpmEvents ( songBpm ) ;
227244 }
228-
245+ var bpmEvents = difficulty . BpmEvents ;
246+
229247 // Compare bpm events
230248 Assert . AreEqual ( initialBpmEvents . Count , bpmEvents . Count ) ;
231249
0 commit comments