Fixing warnings

This commit is contained in:
2025-12-25 14:56:55 +01:00
parent aba4abb054
commit 3cadc23238
3 changed files with 28 additions and 27 deletions

View File

@ -52,6 +52,7 @@
let duration = $state(loadDuration()); let duration = $state(loadDuration());
let volume = $state(loadVolume()); let volume = $state(loadVolume());
let playbackPosition = $state(-1); let playbackPosition = $state(-1);
let cuePoint = $state(0);
let waveformColor = $state(generateRandomColor()); let waveformColor = $state(generateRandomColor());
let showModal = $state(true); let showModal = $state(true);
let isProcessed = $state(false); let isProcessed = $state(false);
@ -195,7 +196,7 @@
onProcess: processSound, onProcess: processSound,
onDownload: download, onDownload: download,
onUndo: undo, onUndo: undo,
onPlayFromStart: replaySound, onPlayFromStart: togglePlayback,
onDurationDecrease: (large) => { onDurationDecrease: (large) => {
duration = Math.max(0.05, duration - (large ? 1 : 0.05)); duration = Math.max(0.05, duration - (large ? 1 : 0.05));
}, },
@ -267,6 +268,7 @@
pitchLock, pitchLock,
); );
currentBuffer = audioService.createAudioBuffer(data); currentBuffer = audioService.createAudioBuffer(data);
cuePoint = 0;
audioService.play(currentBuffer); audioService.play(currentBuffer);
} }
@ -276,9 +278,15 @@
} }
} }
function playFromPosition(offset: number) { function setCuePoint(offset: number) {
if (currentBuffer) { cuePoint = offset;
audioService.play(currentBuffer, offset); }
function togglePlayback() {
if (playbackPosition >= 0) {
audioService.stop();
} else if (currentBuffer) {
audioService.play(currentBuffer, cuePoint);
} }
} }
@ -673,10 +681,11 @@
buffer={currentBuffer} buffer={currentBuffer}
color={waveformColor} color={waveformColor}
{playbackPosition} {playbackPosition}
{cuePoint}
{selectionStart} {selectionStart}
{selectionEnd} {selectionEnd}
onselectionchange={handleSelectionChange} onselectionchange={handleSelectionChange}
onclick={playFromPosition} onclick={setCuePoint}
/> />
{/if} {/if}
@ -705,7 +714,7 @@
> >
<button onclick={processSound}>Process (P)</button> <button onclick={processSound}>Process (P)</button>
{#if showProcessorPopup} {#if showProcessorPopup}
<div onmouseenter={keepPopupOpen} onmouseleave={scheduleHidePopup}> <div role="menu" tabindex="-1" onmouseenter={keepPopupOpen} onmouseleave={scheduleHidePopup}>
<ProcessorPopup <ProcessorPopup
onselect={applyProcessor} onselect={applyProcessor}
selectedCategory={selectedProcessorCategory} selectedCategory={selectedProcessorCategory}

View File

@ -5,6 +5,7 @@
buffer: AudioBuffer | null; buffer: AudioBuffer | null;
color?: string; color?: string;
playbackPosition?: number; playbackPosition?: number;
cuePoint?: number;
selectionStart?: number | null; selectionStart?: number | null;
selectionEnd?: number | null; selectionEnd?: number | null;
onselectionchange?: (start: number | null, end: number | null) => void; onselectionchange?: (start: number | null, end: number | null) => void;
@ -15,6 +16,7 @@
buffer, buffer,
color = '#646cff', color = '#646cff',
playbackPosition = 0, playbackPosition = 0,
cuePoint = 0,
selectionStart = null, selectionStart = null,
selectionEnd = null, selectionEnd = null,
onselectionchange, onselectionchange,
@ -43,6 +45,7 @@
buffer; buffer;
color; color;
playbackPosition; playbackPosition;
cuePoint;
selectionStart; selectionStart;
selectionEnd; selectionEnd;
draw(); draw();
@ -251,6 +254,16 @@
const duration = buffer.length / buffer.sampleRate; const duration = buffer.length / buffer.sampleRate;
const x = (playbackPosition / duration) * width; const x = (playbackPosition / duration) * width;
ctx.strokeStyle = '#fff';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, height);
ctx.stroke();
} else if (cuePoint > 0 && buffer) {
const duration = buffer.length / buffer.sampleRate;
const x = (cuePoint / duration) * width;
ctx.strokeStyle = '#fff'; ctx.strokeStyle = '#fff';
ctx.lineWidth = 2; ctx.lineWidth = 2;
ctx.beginPath(); ctx.beginPath();

View File

@ -157,15 +157,6 @@
border: 1px solid #444; border: 1px solid #444;
} }
.modal-content ul {
margin: 0 0 1rem 0;
padding-left: 1.25rem;
}
.modal-content ul li {
margin-bottom: 0;
}
.text-column ol li { .text-column ol li {
margin-bottom: 0; margin-bottom: 0;
} }
@ -229,10 +220,6 @@
.modal-content .description { .modal-content .description {
font-size: 0.9375rem; font-size: 0.9375rem;
} }
.modal-links p {
font-size: 0.875rem;
}
} }
@media (min-width: 768px) { @media (min-width: 768px) {
@ -257,10 +244,6 @@
line-height: 1.7; line-height: 1.7;
} }
.modal-content ul {
margin: 0;
}
.modal-footer { .modal-footer {
margin: 0 0 2.1rem 0; margin: 0 0 2.1rem 0;
font-size: 0.875rem; font-size: 0.875rem;
@ -282,9 +265,5 @@
.modal-close { .modal-close {
transition: none; transition: none;
} }
.modal-links a {
transition: none;
}
} }
</style> </style>