Skip to content

Commit

Permalink
better timing
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfloogle committed Nov 15, 2023
1 parent 8aca107 commit 6599a15
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/common/vb_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ void sound_thread() {
int shutoff_divider = 0;
int clk1_divider = 0;
int envelope_divider = 0;
u64 lastTime = svcGetSystemTick();
while (true) {
svcWaitSynchronization(nothingEvent, 960000);
u64 newTime = svcGetSystemTick();
s64 waitNanos = 960000 - 2000 * (newTime - lastTime) / CPU_TICKS_PER_USEC;
if (waitNanos > 0)
svcSleepThread(waitNanos / 2);
lastTime = newTime;
// do clk0
if (--shutoff_divider >= 0) continue;
shutoff_divider += 4;
Expand Down

0 comments on commit 6599a15

Please sign in to comment.