replace live scrubbing with horizontal jog controls

Hunter
Friday, November 13th, 2026 at 9:39 PM

readme.md+2-2
readme_images/jog.gifnew
readme_images/record.gif  
readme_images/scrub.gifdeleted
resources/deck.js+30-18
resources/main.js+9-12

readme.md
12  
13  <p align="center"><img src="readme_images/volume.gif" width="390"></p>
14  
   -### scrub a dub, bub.
15 +### run it back.
16  
   -<p align="center"><img src="readme_images/scrub.gif" width="390"></p>
17 +<p align="center"><img src="readme_images/jog.gif" width="390"></p>
18  
19  ### wipeout.
20  
readme_images/jog.gif
Binary files differ.
readme_images/record.gif
Binary files differ.
readme_images/scrub.gif
Binary files differ.
resources/deck.js
  1  const BAR_SECONDS = 0.1;
  2  const SPLICE_SECONDS = 0.005;
    -// Time constant of a held tape chasing the finger.
  3 +// Time constant of a held tape's speed chasing the finger.
  4  const FOLLOW_SECONDS = 0.05;
  5  // Extra acceleration for the part of a speed gap beyond 1, so big gaps close fast.
  6  const FAST_DECAY_SECONDS = 0.35;
    -// A release slower than this, as a fraction of normal speed, leaves the tape stopped.
    -const SLOWEST_THROW = 0.05;
  7 +// A tape jogged slower than this, as a fraction of normal speed, counts as stopped.
  8 +const SLOWEST_JOG = 0.05;
  9  // Volume smoothing, against clicks.
 10  const VOLUME_SECONDS = 0.02;
 11  const RENDERS_PER_REPORT = 3;

 52  			if (data.type === 'grab') {
 53  				tape.held = true;
 54  				tape.pressed = false;
 55 +				tape.base = tape.speed;
 56 +				tape.direction = null;
 57 +				tape.target = tape.speed;
 58  			}
 59  			// A deleted tape fades out first, so that a playing one does not click.
 60  			if (data.type === 'delete') tape.fadeRate = this.deleteRate;
    -			if (data.type === 'drag') tape.pull += data.bars * BAR_SAMPLES;
 61 +			if (data.type === 'jog') {
 62 +				tape.target = tape.base + data.change;
 63 +				this.reportDirection(data.id);
 64 +			}
 65  			if (data.type === 'drop') tape.pressed = false;
 66  			if (data.type === 'release') {
    -				// No decay: the tape coasts at its drag speed.
 67  				tape.held = false;
    -				tape.pull = 0;
    -				if (Math.abs(tape.speed) < SLOWEST_THROW) tape.speed = 0;
    -				tape.target = tape.speed;
    -				this.port.postMessage({type: 'released', id: data.id, speed: tape.speed});
 68 +				if (Math.abs(tape.target) < SLOWEST_JOG) {
 69 +					tape.target = 0;
 70 +					tape.speed = 0;
 71 +				}
 72 +				this.reportDirection(data.id);
 73  			}
 74  		};
 75  	}
 76  
 77 +	reportDirection(id) {
 78 +		const tape = this.tapes[id];
 79 +		const direction = Math.abs(tape.target) < SLOWEST_JOG ? 0 : Math.sign(tape.target);
 80 +		if (direction === tape.direction) return;
 81 +		tape.direction = direction;
 82 +		this.port.postMessage({type: 'direction', id, direction});
 83 +	}
 84 +
 85  	record() {
 86  		this.recording = {
 87  			blocks: [],

158  			pressed: false,
159  			// Speed lost per sample while stopping.
160  			stopRate: 0,
    -			// Samples a held tape still lags behind the finger.
    -			pull: 0,
161 +			// Speed when a jog began.
162 +			base: 0,
163 +			// Last direction reported to the main thread during this jog.
164 +			direction: null,
165  			volume,
166  			// Smoothed `volume`.
167  			gain: volume,

192  				this.tapes[id] = null;
193  				continue;
194  			}
    -			if (tape.speed === 0 && tape.pull === 0 && (tape.held || goal === 0)) {
195 +			if (tape.speed === 0 && goal === 0) {
196  				tape.gain = tape.volume;
197  				continue;
198  			}

200  			const length = samples.length;
201  			for (let i = 0; i < output.length; i++) {
202  				if (tape.held) {
    -					tape.speed = tape.pull / FOLLOW_SAMPLES;
    -					tape.pull -= tape.speed;
203 +					tape.speed += (tape.target - tape.speed) / FOLLOW_SAMPLES;
204  				} else if (tape.speed !== goal) {
205  					const gap = goal - tape.speed;
206  					const distance = Math.abs(gap);

224  					if (tape.position >= length) tape.position = 0;
225  				}
226  			}
    -			if (tape.held && Math.abs(tape.pull) < 1) {
    -				tape.pull = 0;
    -				tape.speed = 0;
    -			}
227 +			if (tape.held && tape.target === 0 && Math.abs(tape.speed) < 1e-4) tape.speed = 0;
228  		}
229  
230  		// Soft-clip the raised mix, as in capture().
resources/main.js
 21  // reaches SCROLL_TOP_SPEED px/s.
 22  const SCROLL_FULL_DRAG = 100;
 23  const SCROLL_TOP_SPEED = 1000;
 24 +// Sideways drag distance, in CSS px, that changes a tape's speed by 1.
 25 +const JOG_DRAG = 100;
 26  // The iOS built-in microphone is super quiet with processing off, and while it is
 27  // open the speaker plays quieter. These gains compensate.
 28  const BUILT_IN_MICROPHONE_GAIN = 20;

219  		recording = null;
220  	},
221  
    -	released({id, speed}) {
    -		if (tapes[id]) tapes[id].direction = Math.sign(speed);
222 +	direction({id, direction}) {
223 +		if (tapes[id]) tapes[id].direction = direction;
224  	},
225  
226  	positions({positions}) {

305  	const {row} = tape;
306  	const send = (type, fields) => deck.port.postMessage({type, id, ...fields});
307  	let start = null;
    -	let lastX = 0;
308  	let mode = null;
309  	let wasPlaying = false;
310  	// This pointer has started braking the tape.

338  		pointerId = event.pointerId;
339  		row.setPointerCapture(pointerId);
340  		start = {x: event.clientX, y: event.clientY, volume: tape.volume};
    -		lastX = event.clientX;
341  		mode = null;
342  		wasPlaying = tape.direction !== 0;
343  		pressed = false;

357  			const upTravel = Math.abs(event.clientY - start.y);
358  			if (Math.max(acrossTravel, upTravel) < DRAG_THRESHOLD) return;
359  			if (acrossTravel < upTravel && pressed) return;
    -			mode = acrossTravel >= upTravel ? 'scrub' : 'volume';
360 +			mode = acrossTravel >= upTravel ? 'jog' : 'volume';
361  			clearTimeout(pressTimer);
362  			clearTimeout(holdTimer);
363  			row.classList.add('grabbed');
    -			if (mode === 'scrub') send('grab');
364 +			if (mode === 'jog') send('grab');
365  			pressed = false;
366  		}
    -		if (mode === 'scrub') {
    -			// Dragging left pulls later tape under the head, which is forwards.
    -			const pitch = tape.canvas.clientWidth / SLOTS;
    -			send('drag', {bars: (lastX - event.clientX) / pitch});
    -			lastX = event.clientX;
367 +		if (mode === 'jog') {
368 +			send('jog', {change: (event.clientX - start.x) / JOG_DRAG});
369  		} else {
370  			const change = (start.y - event.clientY) / row.clientHeight;
371  			tape.volume = Math.min(MAX_VOLUME, Math.max(0, start.volume + change));

382  		start = null;
383  		row.classList.remove('grabbed');
384  		if (mode === 'volume') saveVolume(tape);
    -		if (mode === 'scrub') {
385 +		if (mode === 'jog') {
386  			send('release');
387  		} else if (!mode && event.type === 'pointerup') {
388  			send(wasPlaying ? 'brake' : 'play');