Add separate bar/peak decays

This commit is contained in:
Armin 2026-07-06 22:13:12 +02:00
commit efda5ce7f2

View file

@ -194,13 +194,20 @@ footer .footer-track { flex: 1; min-width: 0; white-space: nowrap; overflow: hid
<option value="kaiser">Kaiser</option> <option value="kaiser">Kaiser</option>
<option value="flatTop">Flat Top</option> <option value="flatTop">Flat Top</option>
</select> </select>
<span style="font-size:11px;color:#555">Decay:</span> <span style="font-size:11px;color:#555">Peak Decay:</span>
<select id="decaySelect"> <select id="decaySelect">
<option value="0.995">Slow</option> <option value="0.995">Slow</option>
<option value="0.985" selected>Medium</option> <option value="0.985" selected>Medium</option>
<option value="0.97">Fast</option> <option value="0.97">Fast</option>
<option value="0.94">Very Fast</option> <option value="0.94">Very Fast</option>
</select> </select>
<span style="font-size:11px;color:#555;margin-left:8px">Bar Decay:</span>
<select id="barDecaySelect">
<option value="0.99">Slow</option>
<option value="0.96" selected>Medium</option>
<option value="0.9">Fast</option>
<option value="0.8">Very Fast</option>
</select>
<span style="font-size:11px;color:#555;margin-left:8px">Crossfade:</span> <span style="font-size:11px;color:#555;margin-left:8px">Crossfade:</span>
<select id="crossfadeSelect"> <select id="crossfadeSelect">
<option value="0" selected>Off</option> <option value="0" selected>Off</option>
@ -275,6 +282,8 @@ let sortField = 'idx';
let sortAsc = true; let sortAsc = true;
let windowType = 'hanning'; let windowType = 'hanning';
let peakDecay = 0.985; let peakDecay = 0.985;
let barDecay = 0.96;
function initAudioCtx() { function initAudioCtx() {
if (audioCtx) return; if (audioCtx) return;
@ -459,7 +468,7 @@ function drawSpectrum() {
grad.addColorStop(0, '#4a9dff'); grad.addColorStop(0, '#4a9dff');
grad.addColorStop(0.4, '#1a6df5'); grad.addColorStop(0.4, '#1a6df5');
grad.addColorStop(1, '#0a1a3e'); grad.addColorStop(1, '#0a1a3e');
const smoothFactor = 0.96; const smoothFactor = barDecay;
const barW = Math.max(1, Math.floor(w / NUM_BARS * 0.75)); const barW = Math.max(1, Math.floor(w / NUM_BARS * 0.75));
const gap = Math.max(1, Math.floor(w / NUM_BARS * 0.25)); const gap = Math.max(1, Math.floor(w / NUM_BARS * 0.25));
const totalBar = barW + gap; const totalBar = barW + gap;
@ -590,6 +599,7 @@ const audioInfo = document.getElementById('audioInfo');
const errorEl = document.getElementById('error'); const errorEl = document.getElementById('error');
const windowSelect = document.getElementById('windowSelect'); const windowSelect = document.getElementById('windowSelect');
const decaySelect = document.getElementById('decaySelect'); const decaySelect = document.getElementById('decaySelect');
const barDecaySelect = document.getElementById('barDecaySelect');
const crossfadeSelect = document.getElementById('crossfadeSelect'); const crossfadeSelect = document.getElementById('crossfadeSelect');
const AUDIO_EXTS = new Set(['.mp3','.wav','.ogg','.flac','.m4a','.aac','.wma','.aiff','.alac','.opus']); const AUDIO_EXTS = new Set(['.mp3','.wav','.ogg','.flac','.m4a','.aac','.wma','.aiff','.alac','.opus']);
@ -979,6 +989,7 @@ function deleteTrack() {
const playingTrack = currentIndex >= 0 ? tracks[currentIndex] : null; const playingTrack = currentIndex >= 0 ? tracks[currentIndex] : null;
for (const idx of sortedSel) URL.revokeObjectURL(tracks[idx].url); for (const idx of sortedSel) URL.revokeObjectURL(tracks[idx].url);
for (let j = sortedSel.length - 1; j >= 0; j--) tracks.splice(sortedSel[j], 1); for (let j = sortedSel.length - 1; j >= 0; j--) tracks.splice(sortedSel[j], 1);
selectedIndices.clear();
if (willDeleteCurrent) { if (willDeleteCurrent) {
if (tracks.length > 0) { if (tracks.length > 0) {
currentIndex = Math.min(sortedSel[0], tracks.length - 1); currentIndex = Math.min(sortedSel[0], tracks.length - 1);
@ -992,7 +1003,6 @@ function deleteTrack() {
currentIndex -= removedBefore; currentIndex -= removedBefore;
renderTracks(); renderTracks();
} }
selectedIndices.clear();
} }
function getSortFn(field) { function getSortFn(field) {
@ -1305,6 +1315,7 @@ sortSelect.addEventListener('change', () => {
windowSelect.addEventListener('change', () => { windowType = windowSelect.value; }); windowSelect.addEventListener('change', () => { windowType = windowSelect.value; });
decaySelect.addEventListener('change', () => { peakDecay = parseFloat(decaySelect.value); }); decaySelect.addEventListener('change', () => { peakDecay = parseFloat(decaySelect.value); });
barDecaySelect.addEventListener('change', () => { barDecay = parseFloat(barDecaySelect.value); });
crossfadeSelect.addEventListener('change', () => { crossfadeDuration = parseFloat(crossfadeSelect.value); }); crossfadeSelect.addEventListener('change', () => { crossfadeDuration = parseFloat(crossfadeSelect.value); });
crossfadeDuration = parseFloat(crossfadeSelect.value); crossfadeDuration = parseFloat(crossfadeSelect.value);
repeatSelect.addEventListener('change', () => { repeatMode = repeatSelect.value; }); repeatSelect.addEventListener('change', () => { repeatMode = repeatSelect.value; });