From 53c5c0f0457dac7ca9eeffa5778ca3119755d87e Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 1 May 2021 16:55:08 +0200 Subject: [PATCH] add a latencyHint to improve audio playback --- htdocs/lib/AudioEngine.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/lib/AudioEngine.js b/htdocs/lib/AudioEngine.js index 5c6415b..8a3df67 100644 --- a/htdocs/lib/AudioEngine.js +++ b/htdocs/lib/AudioEngine.js @@ -41,7 +41,7 @@ AudioEngine.prototype.buildAudioContext = function() { var goodRates = [48000, 44100, 96000] // let the browser chose the sample rate, if it is good, use it - var ctx = new ctxClass(); + var ctx = new ctxClass({latencyHint: 'playback'}); if (goodRates.indexOf(ctx.sampleRate) >= 0) { return ctx; } @@ -49,7 +49,7 @@ AudioEngine.prototype.buildAudioContext = function() { // if that didn't work, try if any of the good rates work if (goodRates.some(function(sr) { try { - ctx = new ctxClass({sampleRate: sr}); + ctx = new ctxClass({sampleRate: sr, latencyHint: 'playback'}); return true; } catch (e) { return false; @@ -60,7 +60,7 @@ AudioEngine.prototype.buildAudioContext = function() { // fallback: let the browser decide // this may cause playback problems down the line - return new ctxClass(); + return new ctxClass({latencyHint: 'playback'}); } AudioEngine.prototype.resume = function(){