load eq ui early

This commit is contained in:
ed 2022-09-08 18:47:30 +02:00
parent 0a81aba899
commit 68a9c05947

View file

@ -1908,8 +1908,7 @@ function ev_play(e) {
} }
var actx = null, var actx = null;
audio_eq = null;
function start_actx() { function start_actx() {
// bonus: speedhack for unfocused file hashing (removes 1sec delay on subtle.digest resolves) // bonus: speedhack for unfocused file hashing (removes 1sec delay on subtle.digest resolves)
@ -1933,11 +1932,8 @@ function start_actx() {
} }
} }
function create_eq() { var audio_eq = (function () {
if (audio_eq) var r = {
return start_actx();
var r = audio_eq = {
"en": false, "en": false,
"bands": [31.25, 62.5, 125, 250, 500, 1000, 2000, 4000, 8000, 16000], "bands": [31.25, 62.5, 125, 250, 500, 1000, 2000, 4000, 8000, 16000],
"gains": [4, 3, 2, 1, 0, 0, 1, 2, 3, 4], "gains": [4, 3, 2, 1, 0, 0, 1, 2, 3, 4],
@ -1948,7 +1944,14 @@ function create_eq() {
"acst": {} "acst": {}
}; };
if (!ACtx)
ebi('audio_eq').parentNode.style.display = 'none';
r.init = function () {
start_actx(); start_actx();
if (r.cfg)
return;
if (!actx) if (!actx)
ebi('audio_eq').parentNode.style.display = 'none'; ebi('audio_eq').parentNode.style.display = 'none';
@ -1978,7 +1981,7 @@ function create_eq() {
var e1 = r.cali < 1.05; var e1 = r.cali < 1.05;
var cfg = [ // hz, q, g r.cfg = [ // hz, q, g
[31.25 * 0.88, 0, 1.4], // shelf [31.25 * 0.88, 0, 1.4], // shelf
[31.25 * 1.04, 0.7, 0.96], // peak [31.25 * 1.04, 0.7, 0.96], // peak
[62.5, 0.7, 1], [62.5, 0.7, 1],
@ -1993,6 +1996,7 @@ function create_eq() {
[16000 * 1.13, 0.82, e1 ? 1.09 : 0.75], // peak [16000 * 1.13, 0.82, e1 ? 1.09 : 0.75], // peak
[16000 * 1.205, 0, e1 ? 1.9 : 1.85] // shelf [16000 * 1.205, 0, e1 ? 1.9 : 1.85] // shelf
]; ];
};
try { try {
r.amp = fcfg_get('au_eq_amp', r.amp); r.amp = fcfg_get('au_eq_amp', r.amp);
@ -2033,6 +2037,7 @@ function create_eq() {
}; };
r.apply = function () { r.apply = function () {
r.init();
r.draw(); r.draw();
if (!actx) if (!actx)
@ -2066,12 +2071,12 @@ function create_eq() {
gains.push(t); gains.push(t);
gains.unshift(gains[0]); gains.unshift(gains[0]);
for (var a = 0; a < cfg.length && min != max; a++) { for (var a = 0; a < r.cfg.length && min != max; a++) {
var fi = actx.createBiquadFilter(); var fi = actx.createBiquadFilter(), c = r.cfg[a];
fi.frequency.value = cfg[a][0]; fi.frequency.value = c[0];
fi.gain.value = cfg[a][2] * gains[a]; fi.gain.value = c[2] * gains[a];
fi.Q.value = cfg[a][1]; fi.Q.value = c[1];
fi.type = a == 0 ? 'lowshelf' : a == cfg.length - 1 ? 'highshelf' : 'peaking'; fi.type = a == 0 ? 'lowshelf' : a == r.cfg.length - 1 ? 'highshelf' : 'peaking';
r.filters.push(fi); r.filters.push(fi);
} }
@ -2209,7 +2214,8 @@ function create_eq() {
bcfg_bind(r, 'en', 'au_eq', false, r.apply); bcfg_bind(r, 'en', 'au_eq', false, r.apply);
r.draw(); r.draw();
} return r;
})();
// plays the tid'th audio file on the page // plays the tid'th audio file on the page
@ -2287,7 +2293,6 @@ function play(tid, is_ev, seek) {
else else
mp.au.src = mp.au.rsrc = url; mp.au.src = mp.au.rsrc = url;
create_eq();
audio_eq.apply(); audio_eq.apply();
setTimeout(function () { setTimeout(function () {