mirror of
https://github.com/9001/copyparty.git
synced 2026-02-26 05:23:10 -07:00
audioplayer: s-s: weave it in
This commit is contained in:
parent
17145ba074
commit
cd927e7837
|
|
@ -1487,6 +1487,11 @@ input.ssconf_v {
|
||||||
#au_drc {
|
#au_drc {
|
||||||
padding: .4em .3em;
|
padding: .4em .3em;
|
||||||
}
|
}
|
||||||
|
#au_ss.on {
|
||||||
|
width: 3em;
|
||||||
|
height: 1em;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
#ico1 {
|
#ico1 {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1742,6 +1742,7 @@ function MPlayer() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
r.fade_out = function () {
|
r.fade_out = function () {
|
||||||
|
mpss.stop();
|
||||||
r.fvol = r.vol;
|
r.fvol = r.vol;
|
||||||
r.fdir = -0.05 * r.vol * (CHROME ? 2 : 1);
|
r.fdir = -0.05 * r.vol * (CHROME ? 2 : 1);
|
||||||
r.ftid = r.au.tid;
|
r.ftid = r.au.tid;
|
||||||
|
|
@ -1768,8 +1769,10 @@ function MPlayer() {
|
||||||
if (isNum(t))
|
if (isNum(t))
|
||||||
r.au.currentTime = Math.max(t, 0);
|
r.au.currentTime = Math.max(t, 0);
|
||||||
}
|
}
|
||||||
else if (r.fvol > r.vol)
|
else if (r.fvol > r.vol) {
|
||||||
r.fvol = r.vol;
|
r.fvol = r.vol;
|
||||||
|
mpss.go();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
done = false;
|
done = false;
|
||||||
|
|
||||||
|
|
@ -2601,8 +2604,6 @@ var mpui = (function () {
|
||||||
// occasionally draw buffered regions
|
// occasionally draw buffered regions
|
||||||
if (nth % 5 == 0)
|
if (nth % 5 == 0)
|
||||||
pbar.drawbuf();
|
pbar.drawbuf();
|
||||||
|
|
||||||
if (!IE && afilt.ssen) skipSilence();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// preload next song
|
// preload next song
|
||||||
|
|
@ -2793,6 +2794,7 @@ var afilt = (function () {
|
||||||
|
|
||||||
r.drcv = jread('au_drcv', r.drcv);
|
r.drcv = jread('au_drcv', r.drcv);
|
||||||
r.sscv = jread('au_sscv', r.sscv);
|
r.sscv = jread('au_sscv', r.sscv);
|
||||||
|
mpss.load();
|
||||||
}
|
}
|
||||||
catch (ex) { }
|
catch (ex) { }
|
||||||
|
|
||||||
|
|
@ -2810,6 +2812,7 @@ var afilt = (function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
r.stop = function () {
|
r.stop = function () {
|
||||||
|
mpss.stop();
|
||||||
if (r.filters.length)
|
if (r.filters.length)
|
||||||
for (var a = 0; a < r.filters.length; a++)
|
for (var a = 0; a < r.filters.length; a++)
|
||||||
r.filters[a].disconnect();
|
r.filters[a].disconnect();
|
||||||
|
|
@ -2875,12 +2878,15 @@ var afilt = (function () {
|
||||||
|
|
||||||
mp.acs.connect(r.filters.length ?
|
mp.acs.connect(r.filters.length ?
|
||||||
r.filters[r.filters.length - 1] : actx.destination);
|
r.filters[r.filters.length - 1] : actx.destination);
|
||||||
|
|
||||||
|
if (!au.paused)
|
||||||
|
mpss.go();
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_ss() {
|
function add_ss() {
|
||||||
r.filters.push(mp.au._gnod = actx.createGain());
|
r.filters.push(mp.ssg = actx.createGain());
|
||||||
r.filters.push(mp.au._analyser = actx.createAnalyser());
|
r.filters.push(mp.ssa = actx.createAnalyser());
|
||||||
mp.au._analyser.fftSize = 256;
|
mp.ssa.fftSize = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
function add_eq() {
|
function add_eq() {
|
||||||
|
|
@ -3048,6 +3054,7 @@ var afilt = (function () {
|
||||||
|
|
||||||
r.sscv[n] = v;
|
r.sscv[n] = v;
|
||||||
jwrite('au_sscv', r.sscv);
|
jwrite('au_sscv', r.sscv);
|
||||||
|
mpss.load();
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
err = true;
|
err = true;
|
||||||
|
|
@ -3288,6 +3295,7 @@ function play(tid, is_ev, seek) {
|
||||||
if (mpl.waves)
|
if (mpl.waves)
|
||||||
pbar.loadwaves(url.replace(/\bth=(opus|mp3)&/, '') + '&th=p');
|
pbar.loadwaves(url.replace(/\bth=(opus|mp3)&/, '') + '&th=p');
|
||||||
|
|
||||||
|
mpss.go();
|
||||||
mpui.progress_updater();
|
mpui.progress_updater();
|
||||||
pbar.onresize();
|
pbar.onresize();
|
||||||
vbar.onresize();
|
vbar.onresize();
|
||||||
|
|
@ -10018,57 +10026,43 @@ function reload_browser() {
|
||||||
dsel_init();
|
dsel_init();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
var ssint = null;
|
|
||||||
|
|
||||||
function skipSilence() {
|
var mpss = (function() {
|
||||||
var ae = mp.au;
|
var r = {}, config, ssint, npaint = 0;
|
||||||
var ssconf = afilt.sscv;
|
|
||||||
|
|
||||||
var config = {
|
r.load = function () {
|
||||||
vthresh: ssconf[0],
|
if (!mp || !mp.ssg)
|
||||||
sthresh: ssconf[1],
|
return false;
|
||||||
etresh: ssconf[2],
|
|
||||||
sspeed: ssconf[3],
|
config = {
|
||||||
rspeed: ssconf[4],
|
vthresh: afilt.sscv[0],
|
||||||
loopInterval: 25
|
sthresh: afilt.sscv[1],
|
||||||
|
etresh: afilt.sscv[2],
|
||||||
|
sspeed: afilt.sscv[3],
|
||||||
|
rspeed: afilt.sscv[4],
|
||||||
|
loopInterval: 25,
|
||||||
|
};
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!ae._gnod)
|
r.go = function () {
|
||||||
return;
|
if (!ssint && afilt.ssen && r.load())
|
||||||
|
|
||||||
if (!ae._ssa) {
|
|
||||||
ae._ssa = true;
|
|
||||||
|
|
||||||
ae.addEventListener('play', startLoop);
|
|
||||||
ae.addEventListener('pause', stopLoop);
|
|
||||||
ae.addEventListener('ended', stopLoop);
|
|
||||||
|
|
||||||
ae.addEventListener('durationchange', function() {
|
|
||||||
if (ae._gnod) ae._gnod.gain.value = 1.0;
|
|
||||||
ae.playbackRate = 1.0;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!ae.paused && !ae.ended) {
|
|
||||||
startLoop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function startLoop() {
|
|
||||||
if (!ssint) {
|
|
||||||
ssint = setInterval(detectSilence, config.loopInterval);
|
ssint = setInterval(detectSilence, config.loopInterval);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
function stopLoop() {
|
r.stop = function () {
|
||||||
if (ssint) {
|
clearInterval(ssint);
|
||||||
clearInterval(ssint);
|
ssint = null;
|
||||||
ssint = null;
|
if (!mp) return;
|
||||||
}
|
if (mp.ssg) mp.ssg.gain.value = 1.0;
|
||||||
if(ae._gnod) ae._gnod.gain.value = 1.0;
|
if (mp.au && mp.au._ss) mp.au.playbackRate = 1.0;
|
||||||
ae.playbackRate = 1.0;
|
if (mp.au2 && mp.au2._ss) mp.au2.playbackRate = 1.0;
|
||||||
}
|
};
|
||||||
|
|
||||||
function detectSilence() {
|
function detectSilence() {
|
||||||
|
var ae = mp.au;
|
||||||
|
ae._ss = true;
|
||||||
|
|
||||||
var duration = ae.duration || 0;
|
var duration = ae.duration || 0;
|
||||||
|
|
||||||
var slimit = duration * (config.sthresh / 100);
|
var slimit = duration * (config.sthresh / 100);
|
||||||
|
|
@ -10080,7 +10074,7 @@ function skipSilence() {
|
||||||
var is_silent = false;
|
var is_silent = false;
|
||||||
|
|
||||||
if (in_limits) {
|
if (in_limits) {
|
||||||
var analyser = ae._analyser;
|
var analyser = mp.ssa;
|
||||||
var da = new Uint8Array(analyser.frequencyBinCount);
|
var da = new Uint8Array(analyser.frequencyBinCount);
|
||||||
analyser.getByteFrequencyData(da);
|
analyser.getByteFrequencyData(da);
|
||||||
|
|
||||||
|
|
@ -10089,6 +10083,11 @@ function skipSilence() {
|
||||||
if (da[i] > maxvol) maxvol = da[i];
|
if (da[i] > maxvol) maxvol = da[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (++npaint > 4) {
|
||||||
|
npaint = 0;
|
||||||
|
ebi('au_ss').innerHTML = maxvol;
|
||||||
|
}
|
||||||
|
|
||||||
if (maxvol < config.vthresh) {
|
if (maxvol < config.vthresh) {
|
||||||
tspeed = config.sspeed;
|
tspeed = config.sspeed;
|
||||||
tvol = 0.0;
|
tvol = 0.0;
|
||||||
|
|
@ -10100,15 +10099,17 @@ function skipSilence() {
|
||||||
if (Math.abs(ae.playbackRate - tspeed) > 0.01) {
|
if (Math.abs(ae.playbackRate - tspeed) > 0.01) {
|
||||||
ae.playbackRate += (tspeed - ae.playbackRate) * config.rspeed;
|
ae.playbackRate += (tspeed - ae.playbackRate) * config.rspeed;
|
||||||
}
|
}
|
||||||
if (Math.abs(ae._gnod.gain.value - tvol) > 0.01) {
|
if (Math.abs(mp.ssg.gain.value - tvol) > 0.01) {
|
||||||
ae._gnod.gain.value += (tvol - ae._gnod.gain.value) * config.rspeed;
|
mp.ssg.gain.value += (tvol - mp.ssg.gain.value) * config.rspeed;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ae.playbackRate = 1.0;
|
ae.playbackRate = 1.0;
|
||||||
ae._gnod.gain.value = 1.0;
|
mp.ssg.gain.value = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return r;
|
||||||
|
})();
|
||||||
|
|
||||||
treectl.hydrate();
|
treectl.hydrate();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue