Changed clock to use performance.now()

This commit is contained in:
2023-11-24 22:22:17 +02:00
parent f3ddb39ab6
commit 69c24f6a15
4 changed files with 21 additions and 45 deletions

View File

@ -213,7 +213,7 @@ export class UserAPI {
/**
* @returns the current AudioContext time (wall clock)
*/
return this.app.audioContext.currentTime;
return this.app.clock.lastPulseAt;
};
public play = (): void => {
@ -1595,7 +1595,7 @@ export class UserAPI {
* @returns A sine wave between -1 and 1
*/
return (
(Math.sin(this.app.clock.ctx.currentTime * Math.PI * 2 * freq) + offset) *
(Math.sin(this.app.clock.lastPulseAt * Math.PI * 2 * freq) + offset) *
times
);
};
@ -1625,7 +1625,7 @@ export class UserAPI {
* @see noise
*/
return (
(((this.app.clock.ctx.currentTime * freq) % 1) * 2 - 1 + offset) * times
(((this.app.clock.lastPulseAt * freq) % 1) * 2 - 1 + offset) * times
);
};