Baird Mechanical Television Figures Implementation Plan
For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Build three interactive figures demonstrating Baird’s 30-line television system: transmitter (encodes video), signal dingbat (visualizes/sonifies), and receiver (decodes with manual tuning).
Architecture: Figures communicate via pub/sub. Transmitter publishes signal samples; dingbat and receiver subscribe. Channel effects (noise, fading) applied at display time so figures work independently. Canvas 2D rendering throughout.
Tech Stack: Vanilla JS ES modules, Canvas 2D, Web Audio API, Pointer Events
Already Complete:
- nipkow.js — Disk geometry and sampling (tested, 19/19 passing)
- channel.js — Noise/fading functions (implemented, untested)
- neon-lamp.js — Lamp physics (implemented, untested)
- manifest.json, runtime.js, test.html, Makefile — Scaffolded
Phase 1: Complete Utility Module Testing
Task 1: Test channel.js
Files:
- Create: editorial/inbox/logiebair/assets/figures/tests/channel.test.js
- Verify: editorial/inbox/logiebair/assets/figures/channel.js
Step 1: Write tests for noise functions
// tests/channel.test.js
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import {
addGaussianNoise,
addImpulseNoise,
applyFading,
applyBandwidthLimit,
processChannel,
} from '../channel.js';
describe('addGaussianNoise', () => {
it('returns Float32Array of same length', () => {
const input = new Float32Array([0.5, 0.5, 0.5]);
const output = addGaussianNoise(input, 0.1);
assert.ok(output instanceof Float32Array);
assert.equal(output.length, input.length);
});
it('output differs from input when sigma > 0', () => {
const input = new Float32Array(100).fill(0.5);
const output = addGaussianNoise(input, 0.1);
const differs = output.some((v, i) => v !== input[i]);
assert.ok(differs, 'noise should modify values');
});
it('output stays in 0-1 range', () => {
const input = new Float32Array(1000).fill(0.5);
const output = addGaussianNoise(input, 0.3);
assert.ok(output.every(v => v >= 0 && v <= 1));
});
it('zero sigma returns unchanged values', () => {
const input = new Float32Array([0.3, 0.5, 0.7]);
const output = addGaussianNoise(input, 0);
// With sigma=0, Box-Muller still runs but multiplies by 0
assert.ok(output.every((v, i) => Math.abs(v - input[i]) < 0.001));
});
});
describe('addImpulseNoise', () => {
it('returns Float32Array of same length', () => {
const input = new Float32Array([0.5, 0.5, 0.5]);
const output = addImpulseNoise(input, 0.5, 0.3);
assert.ok(output instanceof Float32Array);
assert.equal(output.length, input.length);
});
it('with probability 0, output equals input', () => {
const input = new Float32Array([0.3, 0.5, 0.7]);
const output = addImpulseNoise(input, 0, 0.5);
assert.deepEqual([...output], [...input]);
});
it('output stays in 0-1 range', () => {
const input = new Float32Array(1000).fill(0.5);
const output = addImpulseNoise(input, 0.1, 0.8);
assert.ok(output.every(v => v >= 0 && v <= 1));
});
});
describe('applyFading', () => {
it('returns Float32Array of same length', () => {
const input = new Float32Array([0.5, 0.5, 0.5]);
const output = applyFading(input, 0, 0.2);
assert.ok(output instanceof Float32Array);
assert.equal(output.length, input.length);
});
it('fading modulates amplitude', () => {
const input = new Float32Array(100).fill(1.0);
const output1 = applyFading(input, 0, 0.2);
const output2 = applyFading(input, 2.5, 0.2); // Half cycle later
const avg1 = output1.reduce((a, b) => a + b) / output1.length;
const avg2 = output2.reduce((a, b) => a + b) / output2.length;
// Averages should differ due to fading phase
assert.ok(Math.abs(avg1 - avg2) > 0.01, 'fading should change with time');
});
});
describe('applyBandwidthLimit', () => {
it('returns Float32Array of same length', () => {
const input = new Float32Array([0, 1, 0, 1, 0]);
const output = applyBandwidthLimit(input, 3);
assert.ok(output instanceof Float32Array);
assert.equal(output.length, input.length);
});
it('smooths rapid transitions', () => {
const input = new Float32Array([0, 0, 1, 1, 0, 0]);
const output = applyBandwidthLimit(input, 3);
// The transition should be smoother
assert.ok(output[2] < 1, 'sharp edge should be smoothed');
assert.ok(output[2] > 0.5, 'but not completely eliminated');
});
});
describe('processChannel', () => {
it('applies all effects and returns Float32Array', () => {
const input = new Float32Array(100).fill(0.5);
const output = processChannel(input, 0);
assert.ok(output instanceof Float32Array);
assert.equal(output.length, input.length);
});
});
Step 2: Run tests
cd editorial/inbox/logiebair/assets/figures && node --test tests/channel.test.js
Expected: All tests PASS
Step 3: Commit
git add tests/channel.test.js
git commit -m "test: add channel.js tests"
Task 2: Test neon-lamp.js
Files:
- Create: editorial/inbox/logiebair/assets/figures/tests/neon-lamp.test.js
- Verify: editorial/inbox/logiebair/assets/figures/neon-lamp.js
Step 1: Write tests for neon lamp physics
// tests/neon-lamp.test.js
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import {
createNeonLamp,
neonColor,
processWithNeonLamp,
} from '../neon-lamp.js';
describe('createNeonLamp', () => {
it('starts in off state', () => {
const lamp = createNeonLamp();
assert.equal(lamp.isLit(), false);
assert.equal(lamp.getOutput(), 0);
});
it('strikes when voltage exceeds strike threshold', () => {
const lamp = createNeonLamp({ strikeVoltage: 0.8 });
lamp.update(0.7); // Below strike
assert.equal(lamp.isLit(), false);
lamp.update(0.85); // Above strike
assert.equal(lamp.isLit(), true);
assert.ok(lamp.getOutput() > 0);
});
it('stays lit until voltage drops below extinction', () => {
const lamp = createNeonLamp({ strikeVoltage: 0.8, extinctionVoltage: 0.6 });
lamp.update(0.9); // Strike
assert.equal(lamp.isLit(), true);
lamp.update(0.65); // Above extinction, stays lit
assert.equal(lamp.isLit(), true);
lamp.update(0.5); // Below extinction, goes dark
assert.equal(lamp.isLit(), false);
});
it('exhibits hysteresis (different on/off thresholds)', () => {
const lamp = createNeonLamp({ strikeVoltage: 0.8, extinctionVoltage: 0.6 });
// Rising: doesn't light at 0.7
lamp.update(0.7);
assert.equal(lamp.isLit(), false);
// Light it
lamp.update(0.9);
assert.equal(lamp.isLit(), true);
// Falling: stays lit at 0.7 (between extinction and strike)
lamp.update(0.7);
assert.equal(lamp.isLit(), true);
});
it('reset() returns to cold state', () => {
const lamp = createNeonLamp();
lamp.update(0.9);
assert.equal(lamp.isLit(), true);
lamp.reset();
assert.equal(lamp.isLit(), false);
assert.equal(lamp.getOutput(), 0);
});
it('persistence causes gradual decay', () => {
const lamp = createNeonLamp({ persistence: 0.8 });
lamp.update(1.0); // Full brightness
const bright = lamp.getOutput();
lamp.update(0.0); // Voltage drops (lamp goes dark)
const afterDrop = lamp.getOutput();
// Should still have some glow due to persistence
assert.ok(afterDrop > 0, 'persistence should maintain some glow');
assert.ok(afterDrop < bright, 'but less than full brightness');
});
});
describe('neonColor', () => {
it('returns dark color for zero brightness', () => {
const color = neonColor(0);
assert.ok(color.includes('rgb'));
});
it('returns brighter color for higher brightness', () => {
const dim = neonColor(0.2);
const bright = neonColor(0.9);
// Extract R values
const dimR = parseInt(dim.match(/rgb\((\d+)/)[1]);
const brightR = parseInt(bright.match(/rgb\((\d+)/)[1]);
assert.ok(brightR > dimR, 'higher brightness should mean higher R');
});
it('produces orange-pink hue (R > G > B)', () => {
const color = neonColor(0.8);
const match = color.match(/rgb\((\d+), (\d+), (\d+)\)/);
const [, r, g, b] = match.map(Number);
assert.ok(r > g, 'neon should be red-dominant');
assert.ok(g > b, 'neon should have more green than blue');
});
});
describe('processWithNeonLamp', () => {
it('returns Float32Array of same length', () => {
const input = new Float32Array([0.5, 0.9, 0.3]);
const output = processWithNeonLamp(input);
assert.ok(output instanceof Float32Array);
assert.equal(output.length, input.length);
});
it('low voltages produce zero output (below strike)', () => {
const input = new Float32Array([0.1, 0.2, 0.3, 0.4, 0.5]);
const output = processWithNeonLamp(input, { strikeVoltage: 0.8 });
assert.ok(output.every(v => v === 0), 'all below strike should be dark');
});
});
Step 2: Run tests
cd editorial/inbox/logiebair/assets/figures && node --test tests/neon-lamp.test.js
Expected: All tests PASS
Step 3: Commit
git add tests/neon-lamp.test.js
git commit -m "test: add neon-lamp.js tests"
Phase 2: Source Video Assets
Task 3: Create test card video
Files:
- Create: editorial/inbox/logiebair/assets/figures/video/test-card.webm
Step 1: Generate a simple test card image
Create a static test card (vertical bars pattern, appropriate for 30-line testing):
cd editorial/inbox/logiebair/assets/figures/video
# Create test card using ImageMagick (30x70 to match aspect ratio)
convert -size 90x210 \
\( -size 30x210 xc:white \) \
\( -size 30x210 xc:gray \) \
\( -size 30x210 xc:black \) \
+append \
-scale 270x630 \
test-card.png
Step 2: Convert to looped video
# Create 2-second looped video from static image
ffmpeg -loop 1 -i test-card.png -c:v libvpx-vp9 -t 2 -pix_fmt yuva420p \
-vf "scale=270:630" test-card.webm
Step 3: Verify file exists and is reasonable size
ls -la test-card.webm
# Should be small (few KB for static pattern)
Step 4: Commit
git add video/test-card.png video/test-card.webm
git commit -m "asset: add test card video"
Task 4: Source or create Stookie Bill video
Files:
- Create: editorial/inbox/logiebair/assets/figures/video/stookie-bill.webm
Step 1: Research options
Stookie Bill was a ventriloquist dummy. Options: 1. Find public domain footage of a ventriloquist dummy 2. Create a simple animated illustration 3. Use a placeholder (face silhouette) for now
Step 2: Create placeholder (can upgrade later)
cd editorial/inbox/logiebair/assets/figures/video
# Create simple face silhouette placeholder
convert -size 270x630 xc:black \
-fill white \
-draw "ellipse 135,250 80,100 0,360" \
-draw "ellipse 110,220 15,20 0,360" \
-draw "ellipse 160,220 15,20 0,360" \
-fill black \
-draw "ellipse 110,220 5,7 0,360" \
-draw "ellipse 160,220 5,7 0,360" \
-fill white \
-draw "ellipse 135,290 30,10 0,360" \
stookie-placeholder.png
ffmpeg -loop 1 -i stookie-placeholder.png -c:v libvpx-vp9 -t 2 \
-pix_fmt yuva420p stookie-bill.webm
Step 3: Commit placeholder
git add video/stookie-placeholder.png video/stookie-bill.webm
git commit -m "asset: add Stookie Bill placeholder video"
Phase 3: Implement Transmitter Figure
Task 5: Create video source manager
Files:
- Create: editorial/inbox/logiebair/assets/figures/video-source.js
- Test: editorial/inbox/logiebair/assets/figures/tests/video-source.test.js
Step 1: Write video source module
// video-source.js - Manages video sources (files and webcam)
/**
* Create a video source manager.
*
* @param {object} options
* @param {string} options.stookieUrl - URL to Stookie Bill video
* @param {string} options.testCardUrl - URL to test card video
* @returns {object} Video source manager
*/
export function createVideoSource(options = {}) {
const {
stookieUrl = './video/stookie-bill.webm',
testCardUrl = './video/test-card.webm',
} = options;
let currentSource = 'stookie';
let videoElement = null;
let stream = null;
// Create hidden video element
videoElement = document.createElement('video');
videoElement.muted = true;
videoElement.loop = true;
videoElement.playsInline = true;
videoElement.crossOrigin = 'anonymous';
async function switchTo(source) {
// Stop any existing webcam stream
if (stream) {
stream.getTracks().forEach(track => track.stop());
stream = null;
}
currentSource = source;
if (source === 'camera') {
try {
stream = await navigator.mediaDevices.getUserMedia({
video: { facingMode: 'user', width: 270, height: 630 }
});
videoElement.srcObject = stream;
await videoElement.play();
return true;
} catch (err) {
console.warn('Camera access denied, falling back to stookie');
return switchTo('stookie');
}
} else {
videoElement.srcObject = null;
videoElement.src = source === 'testcard' ? testCardUrl : stookieUrl;
await videoElement.play();
return true;
}
}
function getVideoElement() {
return videoElement;
}
function getCurrentSource() {
return currentSource;
}
function destroy() {
if (stream) {
stream.getTracks().forEach(track => track.stop());
}
videoElement.pause();
videoElement.src = '';
}
// Start with default source
switchTo('stookie');
return {
switchTo,
getVideoElement,
getCurrentSource,
destroy,
};
}
Step 2: Commit (testing video sources requires browser)
git add video-source.js
git commit -m "feat: add video source manager for transmitter"
Task 6: Implement transmitter canvas rendering
Files:
- Modify: editorial/inbox/logiebair/assets/figures/baird-transmitter.js
Step 1: Implement the transmitter figure
// baird-transmitter.js - Video source to 30-line signal encoder
import { BAIRD, getScanPosition, sampleFrame } from './nipkow.js';
import { createVideoSource } from './video-source.js';
export const meta = {
name: 'baird-transmitter',
description: 'Encodes video input into Baird 30-line signal via Nipkow disk',
version: '1.0.0',
};
export function setup(container, { publish, subscribe, assets }) {
// Create DOM structure
container.innerHTML = `
<div class="baird-transmitter" style="display: flex; gap: 1rem; padding: 1rem; background: #1a1a1a; align-items: center; justify-content: center; flex-wrap: wrap;">
<div class="source-panel" style="position: relative;">
<canvas class="source-canvas" width="90" height="210" style="border: 1px solid #333; image-rendering: pixelated;"></canvas>
<div class="flying-spot" style="position: absolute; width: 6px; height: 6px; background: #fff; border-radius: 50%; pointer-events: none; box-shadow: 0 0 10px #fff;"></div>
</div>
<div class="disk-panel">
<canvas class="disk-canvas" width="200" height="200" style="background: #0a0a0a; border-radius: 50%;"></canvas>
</div>
<div class="signal-panel">
<canvas class="signal-canvas" width="150" height="80" style="background: #0a0a0a; border: 1px solid #333;"></canvas>
</div>
</div>
<div class="source-selector" style="display: flex; gap: 0.5rem; justify-content: center; padding: 0.5rem; background: #222;">
<button data-source="stookie" class="active" style="padding: 0.3rem 0.8rem; cursor: pointer;">Stookie Bill</button>
<button data-source="testcard" style="padding: 0.3rem 0.8rem; cursor: pointer;">Test Card</button>
<button data-source="camera" style="padding: 0.3rem 0.8rem; cursor: pointer;">📷 Camera</button>
</div>
`;
// Get elements
const sourceCanvas = container.querySelector('.source-canvas');
const diskCanvas = container.querySelector('.disk-canvas');
const signalCanvas = container.querySelector('.signal-canvas');
const flyingSpot = container.querySelector('.flying-spot');
const buttons = container.querySelectorAll('[data-source]');
const sourceCtx = sourceCanvas.getContext('2d');
const diskCtx = diskCanvas.getContext('2d');
const signalCtx = signalCanvas.getContext('2d');
// Video source
const videoSource = createVideoSource({
stookieUrl: assets?.stookieUrl || './video/stookie-bill.webm',
testCardUrl: assets?.testCardUrl || './video/test-card.webm',
});
// Signal buffer for preview and publishing
const signalBuffer = new Float32Array(2100); // One frame
let signalIndex = 0;
// Animation state
let frameTime = 0;
let animationId = null;
const frameDuration = 1 / BAIRD.frameRate;
// Button handlers
buttons.forEach(btn => {
btn.addEventListener('click', async () => {
buttons.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
await videoSource.switchTo(btn.dataset.source);
if (publish['baird.source']) {
publish['baird.source'](btn.dataset.source);
}
});
});
function drawNipkowDisk(time) {
const ctx = diskCtx;
const cx = 100, cy = 100, outerR = 90, innerR = 60;
ctx.clearRect(0, 0, 200, 200);
// Disk background
ctx.fillStyle = '#222';
ctx.beginPath();
ctx.arc(cx, cy, outerR, 0, Math.PI * 2);
ctx.fill();
// Calculate current rotation
const rotationsPerFrame = 1;
const currentRotation = (time / frameDuration) * Math.PI * 2 * rotationsPerFrame;
// Draw apertures
const deltaTheta = (2 * Math.PI) / BAIRD.lines;
const deltaR = (outerR - innerR) / BAIRD.lines;
const currentLine = Math.floor((time % frameDuration) / frameDuration * BAIRD.lines);
for (let n = 0; n < BAIRD.lines; n++) {
const theta = n * deltaTheta + currentRotation;
const r = outerR - n * deltaR;
const x = cx + r * Math.cos(theta);
const y = cy + r * Math.sin(theta);
ctx.fillStyle = n === currentLine ? '#fff' : '#666';
ctx.beginPath();
ctx.arc(x, y, 3, 0, Math.PI * 2);
ctx.fill();
}
// Center hub
ctx.fillStyle = '#111';
ctx.beginPath();
ctx.arc(cx, cy, 15, 0, Math.PI * 2);
ctx.fill();
}
function drawSignalPreview() {
const ctx = signalCtx;
const w = 150, h = 80;
ctx.fillStyle = '#0a0a0a';
ctx.fillRect(0, 0, w, h);
ctx.strokeStyle = '#0f0';
ctx.lineWidth = 1;
ctx.beginPath();
const samples = Math.min(signalBuffer.length, w);
for (let i = 0; i < samples; i++) {
const x = (i / samples) * w;
const y = h - signalBuffer[i] * h * 0.9 - 4;
if (i === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
}
ctx.stroke();
}
function render(timestamp) {
const video = videoSource.getVideoElement();
if (video.readyState < 2) {
animationId = requestAnimationFrame(render);
return;
}
// Draw video to source canvas (cropped to 3:7)
sourceCtx.drawImage(video, 0, 0, sourceCanvas.width, sourceCanvas.height);
// Get image data for sampling
const imageData = sourceCtx.getImageData(0, 0, sourceCanvas.width, sourceCanvas.height);
// Calculate frame time (looping)
frameTime = (timestamp / 1000) % frameDuration;
// Sample current position
const pos = getScanPosition(frameTime, sourceCanvas.width, sourceCanvas.height);
const sample = sampleFrame(imageData, frameTime);
// Update signal buffer
signalBuffer[signalIndex % signalBuffer.length] = sample;
signalIndex++;
// Update flying spot position
flyingSpot.style.left = `${pos.x - 3}px`;
flyingSpot.style.top = `${pos.y - 3}px`;
// Draw Nipkow disk
drawNipkowDisk(timestamp / 1000);
// Draw signal preview
drawSignalPreview();
// Publish signal batch periodically (every ~40ms = 1024 samples)
if (signalIndex % 1024 === 0 && publish['baird.signal']) {
const batch = signalBuffer.slice(
Math.max(0, signalIndex - 1024),
signalIndex
);
publish['baird.signal']({
sampleRate: BAIRD.sampleRate,
samples: batch,
frameSync: Math.floor(signalIndex / 2100) * 2100,
timestamp: timestamp,
});
}
animationId = requestAnimationFrame(render);
}
// Start animation
animationId = requestAnimationFrame(render);
// Cleanup
return () => {
if (animationId) cancelAnimationFrame(animationId);
videoSource.destroy();
};
}
Step 2: Test in browser
cd editorial/inbox/logiebair/assets/figures && python -m http.server 8080
# Open http://localhost:8080/test.html
Verify: - Stookie Bill video loads and displays - Nipkow disk animates - Flying spot moves across source - Signal preview shows waveform - Source buttons switch video
Step 3: Commit
git add baird-transmitter.js
git commit -m "feat: implement transmitter figure with Nipkow disk animation"
Phase 4: Implement Signal Dingbat
Task 7: Implement signal oscilloscope display
Files:
- Modify: editorial/inbox/logiebair/assets/figures/baird-signal.js
Step 1: Implement the signal dingbat
// baird-signal.js - Oscilloscope dingbat showing the raw signal
import { addGaussianNoise, addImpulseNoise, applyFading } from './channel.js';
export const meta = {
name: 'baird-signal',
description: 'Oscilloscope visualization of the 30-line signal with audio playback',
version: '1.0.0',
};
export function setup(container, { publish, subscribe, assets }) {
// Create DOM structure
container.innerHTML = `
<div class="baird-signal" style="display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem; background: #0a0a0a;">
<canvas class="scope-canvas" width="500" height="80" style="flex: 1; background: #050505; border: 1px solid #1a1a1a;"></canvas>
<button class="audio-toggle" aria-label="Toggle audio" style="width: 40px; height: 40px; border-radius: 50%; border: 1px solid #333; background: #1a1a1a; color: #4a4; cursor: pointer; font-size: 1.2rem;">🔇</button>
</div>
`;
const canvas = container.querySelector('.scope-canvas');
const audioBtn = container.querySelector('.audio-toggle');
const ctx = canvas.getContext('2d');
// Signal buffer (rolling ~500ms at 26kHz = ~13000 samples, downsample for display)
const displayBuffer = new Float32Array(500);
let writeIndex = 0;
// Audio state
let audioCtx = null;
let audioEnabled = false;
let scriptNode = null;
let pendingAudioSamples = [];
// Time for fading effect
let time = 0;
function processIncomingSignal(signal) {
if (!signal || !signal.samples) return;
// Apply channel effects for display
let processed = new Float32Array(signal.samples);
processed = addGaussianNoise(processed, 0.03);
processed = addImpulseNoise(processed, 0.0005, 0.4);
processed = applyFading(processed, time, 0.15);
// Downsample for display (take every Nth sample)
const ratio = Math.max(1, Math.floor(processed.length / 50));
for (let i = 0; i < processed.length; i += ratio) {
displayBuffer[writeIndex % displayBuffer.length] = processed[i];
writeIndex++;
}
// Queue for audio if enabled
if (audioEnabled && audioCtx) {
pendingAudioSamples.push(...processed);
// Keep buffer from growing too large
if (pendingAudioSamples.length > 26250) {
pendingAudioSamples = pendingAudioSamples.slice(-13125);
}
}
time += signal.samples.length / signal.sampleRate;
}
function drawScope() {
const w = canvas.width;
const h = canvas.height;
// Fade previous frame (CRT persistence)
ctx.fillStyle = 'rgba(5, 5, 5, 0.3)';
ctx.fillRect(0, 0, w, h);
// Draw waveform
ctx.strokeStyle = '#0f0';
ctx.lineWidth = 1.5;
ctx.shadowColor = '#0f0';
ctx.shadowBlur = 3;
ctx.beginPath();
for (let i = 0; i < displayBuffer.length; i++) {
const x = (i / displayBuffer.length) * w;
const y = h - displayBuffer[i] * h * 0.85 - 6;
if (i === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
}
ctx.stroke();
ctx.shadowBlur = 0;
// Grid lines (subtle)
ctx.strokeStyle = '#1a1a1a';
ctx.lineWidth = 0.5;
for (let y = 20; y < h; y += 20) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(w, y);
ctx.stroke();
}
}
function initAudio() {
if (audioCtx) return;
audioCtx = new (window.AudioContext || window.webkitAudioContext)();
// Use ScriptProcessorNode for simplicity (deprecated but widely supported)
scriptNode = audioCtx.createScriptProcessor(4096, 1, 1);
scriptNode.onaudioprocess = (e) => {
const output = e.outputBuffer.getChannelData(0);
for (let i = 0; i < output.length; i++) {
if (pendingAudioSamples.length > 0) {
// Convert 0-1 signal to -1 to 1 audio, with volume reduction
output[i] = (pendingAudioSamples.shift() - 0.5) * 0.3;
} else {
output[i] = 0;
}
}
};
// Bandpass filter to make it sound more "radio-like"
const filter = audioCtx.createBiquadFilter();
filter.type = 'bandpass';
filter.frequency.value = 5000;
filter.Q.value = 0.5;
scriptNode.connect(filter);
filter.connect(audioCtx.destination);
}
audioBtn.addEventListener('click', () => {
if (!audioEnabled) {
initAudio();
audioEnabled = true;
audioBtn.textContent = '🔊';
audioBtn.style.color = '#4a4';
} else {
audioEnabled = false;
audioBtn.textContent = '🔇';
audioBtn.style.color = '#4a4';
pendingAudioSamples = [];
}
});
// Subscribe to signal
if (subscribe['baird.signal']) {
subscribe['baird.signal'](processIncomingSignal);
}
// Animation loop
let animationId = null;
function animate() {
drawScope();
animationId = requestAnimationFrame(animate);
}
animationId = requestAnimationFrame(animate);
// Cleanup
return () => {
if (animationId) cancelAnimationFrame(animationId);
if (scriptNode) scriptNode.disconnect();
if (audioCtx) audioCtx.close();
};
}
Step 2: Test in browser
Verify: - Waveform displays and scrolls - Green CRT glow effect - Audio button toggles sound - Sound has characteristic buzzing quality
Step 3: Commit
git add baird-signal.js
git commit -m "feat: implement signal dingbat with oscilloscope and audio"
Phase 5: Implement Receiver Figure
Task 8: Implement televisor display
Files:
- Modify: editorial/inbox/logiebair/assets/figures/baird-receiver.js
Step 1: Implement the receiver figure
// baird-receiver.js - Televisor display with manual tuning
import { BAIRD } from './nipkow.js';
import { processChannel } from './channel.js';
import { createNeonLamp, neonColor } from './neon-lamp.js';
export const meta = {
name: 'baird-receiver',
description: 'Televisor that reconstructs image from signal with manual tuning',
version: '1.0.0',
};
export function setup(container, { publish, subscribe, assets }) {
// Create DOM structure
container.innerHTML = `
<div class="baird-receiver" style="display: flex; gap: 2rem; padding: 1.5rem; background: #1a1a1a; align-items: flex-start; justify-content: center; flex-wrap: wrap;">
<div class="televisor-panel" style="position: relative;">
<canvas class="televisor-canvas" width="90" height="210" style="border: 4px solid #333; border-radius: 8px; image-rendering: pixelated; box-shadow: 0 0 30px rgba(255, 150, 100, 0.2);"></canvas>
<div class="scan-line" style="position: absolute; left: 4px; top: 4px; width: 82px; height: 2px; background: rgba(255,200,150,0.3); pointer-events: none;"></div>
</div>
<div class="controls-panel" style="display: flex; flex-direction: column; gap: 1rem; min-width: 200px;">
<label style="color: #888; font-size: 0.85rem;">
FRAMING
<input type="range" class="framing-slider" min="-50" max="50" value="5" style="width: 100%;">
</label>
<label style="color: #888; font-size: 0.85rem;">
SPEED
<input type="range" class="speed-slider" min="-20" max="20" value="2" style="width: 100%;">
</label>
<label style="color: #888; font-size: 0.85rem;">
BRIGHTNESS
<input type="range" class="brightness-slider" min="0" max="100" value="70" style="width: 100%;">
</label>
<button class="reset-btn" style="padding: 0.5rem; cursor: pointer; background: #333; color: #aaa; border: 1px solid #444;">↺ Reset Tuning</button>
</div>
</div>
`;
const canvas = container.querySelector('.televisor-canvas');
const scanLine = container.querySelector('.scan-line');
const framingSlider = container.querySelector('.framing-slider');
const speedSlider = container.querySelector('.speed-slider');
const brightnessSlider = container.querySelector('.brightness-slider');
const resetBtn = container.querySelector('.reset-btn');
const ctx = canvas.getContext('2d');
const width = canvas.width;
const height = canvas.height;
// Create neon lamp for each scan line
const lamps = Array.from({ length: BAIRD.lines }, () => createNeonLamp({
strikeVoltage: 0.75,
extinctionVoltage: 0.55,
persistence: 0.7,
}));
// Signal buffer
let signalBuffer = new Float32Array(2100);
let signalWriteIndex = 0;
let lastSignalTime = 0;
// Motor simulation
let motorPhase = 0; // 0-1, where in the frame we are
let motorSpeed = 1.0; // Relative to correct speed
let motorDrift = 0.0001; // Slow drift rate
// Tuning state
let frameOffset = 5; // Pixels of vertical offset (framing)
let speedOffset = 0.002; // Speed deviation
let brightness = 0.7;
// Reduced motion preference
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
function processIncomingSignal(signal) {
if (!signal || !signal.samples) return;
// Apply channel effects
const processed = processChannel(signal.samples, signal.timestamp / 1000, {
noiseLevel: 0.04,
impulseProb: 0.0003,
fadeFreq: 0.1,
bandwidth: 2,
});
// Write to buffer
for (let i = 0; i < processed.length; i++) {
signalBuffer[signalWriteIndex % signalBuffer.length] = processed[i];
signalWriteIndex++;
}
lastSignalTime = performance.now();
}
function renderTelevisor() {
// Apply persistence (fade previous frame)
ctx.fillStyle = 'rgba(10, 5, 5, 0.15)';
ctx.fillRect(0, 0, width, height);
// Calculate where to read from buffer based on motor phase
const samplesPerFrame = 2100;
const samplesPerLine = samplesPerFrame / BAIRD.lines;
// Update motor phase with drift
if (!prefersReducedMotion) {
motorSpeed = 1.0 + speedOffset + motorDrift * Math.sin(performance.now() / 5000);
}
motorPhase = (motorPhase + motorSpeed * 0.02) % 1;
// Calculate frame offset from framing control
const lineOffset = Math.floor(frameOffset / (height / BAIRD.lines));
// Render each line
const lineHeight = height / BAIRD.lines;
for (let line = 0; line < BAIRD.lines; line++) {
const displayLine = (line + lineOffset + BAIRD.lines) % BAIRD.lines;
// Get samples for this line
const lineStart = Math.floor((motorPhase * samplesPerFrame + line * samplesPerLine)) % signalBuffer.length;
// Average samples for this line
let sum = 0;
for (let s = 0; s < samplesPerLine; s++) {
sum += signalBuffer[(lineStart + s) % signalBuffer.length];
}
const avgVoltage = (sum / samplesPerLine) * brightness;
// Process through neon lamp
const lampOutput = lamps[line].update(avgVoltage);
// Draw the line with neon color
ctx.fillStyle = neonColor(lampOutput);
ctx.fillRect(line * (width / BAIRD.lines), 0, width / BAIRD.lines + 1, height);
}
// Update scan line position indicator
const scanY = (motorPhase * height) % height;
scanLine.style.top = `${4 + scanY}px`;
}
// Control handlers
framingSlider.addEventListener('input', (e) => {
frameOffset = parseInt(e.target.value);
});
speedSlider.addEventListener('input', (e) => {
speedOffset = parseInt(e.target.value) / 1000;
});
brightnessSlider.addEventListener('input', (e) => {
brightness = parseInt(e.target.value) / 100;
});
resetBtn.addEventListener('click', () => {
framingSlider.value = 0;
speedSlider.value = 0;
brightnessSlider.value = 70;
frameOffset = 0;
speedOffset = 0;
brightness = 0.7;
motorPhase = 0;
});
// Subscribe to signal
if (subscribe['baird.signal']) {
subscribe['baird.signal'](processIncomingSignal);
}
// Animation loop
let animationId = null;
function animate() {
renderTelevisor();
animationId = requestAnimationFrame(animate);
}
animationId = requestAnimationFrame(animate);
// Cleanup
return () => {
if (animationId) cancelAnimationFrame(animationId);
};
}
Step 2: Test in browser
Verify: - Televisor displays reconstructed image - Neon orange-pink glow effect - Framing slider shifts image vertically - Speed slider causes rolling when off-center - Brightness affects overall image - Reset button returns to tuned state - Image is recognizable when tuned
Step 3: Commit
git add baird-receiver.js
git commit -m "feat: implement receiver figure with tuning controls"
Phase 6: Integration and Polish
Task 9: Test full signal chain
Files:
- Verify: editorial/inbox/logiebair/assets/figures/test.html
Step 1: Open test harness and verify end-to-end
cd editorial/inbox/logiebair/assets/figures && python -m http.server 8080
Step 2: Verification checklist
- [ ] Transmitter loads and shows Stookie Bill
- [ ] Nipkow disk animates smoothly
- [ ] Flying spot tracks scan position
- [ ] Signal dingbat shows waveform
- [ ] Audio plays when enabled (buzzing, rhythmic)
- [ ] Receiver shows recognizable image when tuned
- [ ] Framing/Speed/Brightness controls work
- [ ] Source switching works (Stookie → Test Card → Camera)
- [ ] Camera permission request appears
- [ ] Camera fallback works if denied
- [ ] Reset button tunes the image
- [ ] No console errors
Step 3: Commit any fixes
git add -A
git commit -m "fix: integration fixes for full signal chain"
Task 10: Add accessibility features
Files:
- Modify: editorial/inbox/logiebair/assets/figures/baird-transmitter.js
- Modify: editorial/inbox/logiebair/assets/figures/baird-signal.js
- Modify: editorial/inbox/logiebair/assets/figures/baird-receiver.js
Step 1: Add ARIA labels to transmitter
In baird-transmitter.js, update the source selector buttons:
<button data-source="stookie" class="active" aria-pressed="true" aria-label="Select Stookie Bill video source">Stookie Bill</button>
<button data-source="testcard" aria-pressed="false" aria-label="Select test card video source">Test Card</button>
<button data-source="camera" aria-pressed="false" aria-label="Select camera video source">📷 Camera</button>
Step 2: Add ARIA labels to receiver
In baird-receiver.js, update the sliders:
<input type="range" class="framing-slider" min="-50" max="50" value="5"
aria-label="Framing adjustment" aria-valuemin="-50" aria-valuemax="50">
<input type="range" class="speed-slider" min="-20" max="20" value="2"
aria-label="Speed adjustment" aria-valuemin="-20" aria-valuemax="20">
<input type="range" class="brightness-slider" min="0" max="100" value="70"
aria-label="Brightness adjustment" aria-valuemin="0" aria-valuemax="100">
Step 3: Add keyboard support to receiver
Add keyboard handlers for fine-tuning:
// Keyboard support
container.addEventListener('keydown', (e) => {
const step = e.shiftKey ? 10 : 1;
if (document.activeElement === framingSlider) {
if (e.key === 'ArrowLeft') frameOffset = Math.max(-50, frameOffset - step);
if (e.key === 'ArrowRight') frameOffset = Math.min(50, frameOffset + step);
framingSlider.value = frameOffset;
}
// Similar for other sliders
});
Step 4: Commit
git add baird-transmitter.js baird-signal.js baird-receiver.js
git commit -m "a11y: add ARIA labels and keyboard support"
Task 11: Add lazy loading for receiver
Files:
- Verify: editorial/inbox/logiebair/assets/figures/test.html
Step 1: Verify data-lazy attribute is present
In test.html, the receiver should have data-lazy:
<figure data-interactive="baird-receiver" data-lazy>
Step 2: Verify runtime.js handles lazy loading
Check that runtime.js uses IntersectionObserver for data-lazy figures. (Already implemented in regolith version.)
Step 3: Test lazy loading
- Load page
- Scroll down slowly
- Verify receiver only initializes when scrolled into view
- Check console for initialization timing
Task 12: Final documentation update
Files:
- Modify: editorial/inbox/logiebair/assets/figures/README.md
Step 1: Update README with usage instructions
# Baird Mechanical Television Figures
Interactive figures demonstrating John Logie Baird's 30-line television system.
## Figures
| Figure | Description |
|--------|-------------|
| `baird-transmitter` | Encodes video to signal via animated Nipkow disk |
| `baird-signal` | Oscilloscope dingbat with audio playback |
| `baird-receiver` | Televisor with manual tuning controls |
## Quick Start
```bash
# Serve locally
make serve
# Open http://localhost:8080/test.html
Usage in Article
<figure data-interactive="baird-transmitter">
<figcaption>The transmitter encodes video into a 30-line signal</figcaption>
</figure>
<!-- Later in article -->
<figure data-interactive="baird-signal">
<figcaption>The raw signal at ~13 kHz</figcaption>
</figure>
<!-- Even later -->
<figure data-interactive="baird-receiver" data-lazy>
<figcaption>Tune the televisor to see the image</figcaption>
</figure>
<script type="module">
import { initFigures } from './assets/figures/runtime.js';
initFigures();
</script>
Video Sources
- Stookie Bill —
video/stookie-bill.webm(placeholder, upgrade with real footage) - Test Card —
video/test-card.webm(vertical bars pattern) - Camera — Uses
getUserMedia, falls back to Stookie Bill
Testing
make test # Run all tests
make test-local # Run Node.js tests only
Architecture
Figures communicate via pub/sub topics:
baird.signal— Voltage samples from transmitterbaird.source— Current video source name
See doc/process/plans/2026-01-22-baird-figures-design.md for full specification.
**Step 2: Commit**
```bash
git add README.md
git commit -m "docs: update README with usage instructions"
Summary
| Phase | Tasks | Status |
|---|---|---|
| 1. Utility Testing | channel.js tests, neon-lamp.js tests | Pending |
| 2. Video Assets | Test card, Stookie Bill placeholder | Pending |
| 3. Transmitter | Video source, canvas rendering | Pending |
| 4. Signal Dingbat | Oscilloscope, audio playback | Pending |
| 5. Receiver | Televisor, tuning controls | Pending |
| 6. Polish | Integration, a11y, lazy loading, docs | Pending |
Total tasks: 12 Estimated commits: 12-15