MCPcopy Create free account
hub / github.com/stemdeckapp/stemdeck / seek

Function seek

static/js/chunkedAudioEngine.js:356–374  ·  view source on GitHub ↗
(t)

Source from the content-addressed store, hash-verified

354 }
355
356 function seek(t) {
357 const clamped = Math.max(0, Math.min(t, _duration || 0));
358 const wasPlaying = playing;
359 if (wasPlaying) {
360 _stopNodes();
361 playing = false;
362 _audioStarted = false;
363 if (rafId) { cancelAnimationFrame(rafId); rafId = null; }
364 }
365 _startOffset = clamped;
366 _scheduledTo = clamped;
367 // Evict cache for chunks before the new position.
368 const newIdx = Math.floor(clamped / CHUNK_SEC);
369 for (const k of _cache.keys()) {
370 if (k < newIdx) _cache.delete(k);
371 }
372 onTime?.(clamped);
373 if (wasPlaying) play();
374 }
375
376 // Initialize: fetch all WAV headers in parallel and load the SoundTouch worklet.
377 // Chunk 0 is kicked off in the background so ready() resolves quickly (headers

Callers 1

setPlaybackRateFunction · 0.70

Calls 2

_stopNodesFunction · 0.85
playFunction · 0.70

Tested by

no test coverage detected