Skip to content

Commit 7bf038e

Browse files
committed
wip
1 parent bed0b4f commit 7bf038e

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

osu.Framework.Tests/Audio/TrackBassWithDecoupledClockTest.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Threading;
66
using System.Threading.Tasks;
7+
using ManagedBass;
78
using NUnit.Framework;
89
using osu.Framework.Audio.Track;
910
using 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

Comments
 (0)