44using System ;
55using System . Threading ;
66using System . Threading . Tasks ;
7+ using ManagedBass ;
78using NUnit . Framework ;
89using osu . Framework . Audio . Track ;
910using osu . Framework . Timing ;
@@ -19,7 +20,7 @@ public class TrackBassWithDecoupledClockTest
1920 [ Test ]
2021 public void TestSomething ( )
2122 {
22- var stopwatch = new StopwatchClock ( true ) ;
23+ var stopwatch = new StopwatchClock ( ) ;
2324
2425 bass = new BassTestComponents ( ) ;
2526 track = bass . GetTrack ( ) ;
@@ -29,28 +30,37 @@ public void TestSomething()
2930 while ( true )
3031 {
3132 bass . Update ( ) ;
32- await Task . Delay ( 1 ) . ConfigureAwait ( false ) ;
33+ // await Task.Delay(1).ConfigureAwait(false);
3334 }
3435 } ) ;
3536
36- const double track_start_time = - 1000 ;
37+ const double track_start_time = - 20000 ;
3738 const double elapsed_per_frame = 1 ;
3839 const double sync_lenience = 5 ;
3940
4041 var decoupling = new DecouplingFramedClock ( track ) ;
42+
4143 decoupling . Seek ( track_start_time ) ;
42- decoupling . Start ( ) ;
44+ stopwatch . Seek ( track_start_time ) ;
4345
44- double startInRealTime = stopwatch . CurrentTime ;
46+ stopwatch . Start ( ) ;
47+ decoupling . Start ( ) ;
4548
4649 while ( decoupling . CurrentTime < 1000 )
4750 {
4851 decoupling . ProcessFrame ( ) ;
4952
50- double realtime = stopwatch . CurrentTime - startInRealTime + track_start_time ;
53+ //if (stopwatch.CurrentTime > -5)
54+ {
55+ Console . WriteLine ( $ "realtime: { stopwatch . CurrentTime : N2} ") ;
56+ Console . WriteLine ( $ "decouple: { decoupling . CurrentTime : N2} ") ;
57+ Console . WriteLine ( $ "drift : { Math . Abs ( decoupling . CurrentTime - stopwatch . CurrentTime ) : N2} ") ;
58+ Console . WriteLine ( $ "track : { track . CurrentTime : N2} ") ;
59+ Console . WriteLine ( ) ;
60+ }
5161
52- if ( Math . Abs ( realtime - decoupling . CurrentTime ) >= sync_lenience )
53- Assert . Fail ( $ "Decoupled clock desynchronised from real time. decoupled:{ decoupling . CurrentTime : 0.000} , realtime:{ realtime : 0.000} ") ;
62+ if ( Math . Abs ( stopwatch . CurrentTime - decoupling . CurrentTime ) >= sync_lenience )
63+ Assert . Fail ( $ "Decoupled clock desynchronised from real time. decoupled:{ decoupling . CurrentTime : 0.000} , realtime:{ stopwatch . CurrentTime : 0.000} ") ;
5464
5565 Thread . Sleep ( ( int ) elapsed_per_frame ) ;
5666 }
0 commit comments