Files
Hadrian Burkhardt 0718e3f252 Open Lumen on a responsive bookshelf and land pending story work
- Start the app on a shelf of every installed book instead of the last
  book's home. Cards show the cover, translated metadata, available
  languages, restored patterns and either "Continue reading" or a way in.
- Keep each book's saved route: the shelf is never written to
  flutter_screen, so choosing a book resumes its own leaf.
- Lay the shelf out responsively: dense single-column cards on phones,
  a two-column grid from 720 logical pixels, a centred 860 px column on
  tablets and a chevron that exists in the bundled handwriting font.
- Keep Settings reachable from the shelf and let the home page's story
  library button open the shelf instead of a dialog.
- Add tool/shelf_screenshots_test.dart, which renders the shelf at phone
  and tablet metrics, checks that every card and Settings stay reachable
  without overflow, and writes artifacts/library/shelf-*.png.
- Commit the pending Midnight Invitation package (campaign, notebook,
  narration and artwork), cast drama and ambience tooling, region
  selection, phone/tablet integration coverage and related docs.

flutter analyze is clean and all 74 widget/domain tests pass.
2026-11-05 14:29:50 +01:00

42 lines
2.2 KiB
Python

"""Offline drama helpers. Stage directions remain metadata, never spoken text."""
import numpy as np
def validate_segments(record, cast):
segments = record['segments']
if not segments or ''.join(s['text'] for s in segments) != record['text']:
raise ValueError(f"Segments must preserve the exact prose: {record['pageId']}")
for segment in segments:
if not segment['text'].strip() or segment['speaker'] not in cast:
raise ValueError(f"Missing text or cast member: {segment}")
if not 0.5 <= segment.get('speed', cast[segment['speaker']]['speed']) <= 1.5:
raise ValueError('Delivery speed must be between 0.5 and 1.5')
if not 0 <= segment.get('pauseMs', 600) <= 5000:
raise ValueError('Pause must be between 0 and 5000 ms')
if segment.get('afterEffect') not in (None, 'door-knock', 'chair-shift', 'paper'):
raise ValueError('Unknown sound effect')
if segment.get('perspective', 'near') not in ('near', 'behind-door'):
raise ValueError('Unknown voice perspective')
def effect(name, rate=24000):
"""Original, deliberately soft Foley approximations, deterministic and offline."""
rng = np.random.default_rng(1031)
duration = {'door-knock': 1.0, 'chair-shift': .8, 'paper': .7}[name]
t = np.arange(round(rate * duration)) / rate
noise = rng.normal(size=len(t))
if name == 'door-knock':
result = np.zeros(len(t))
for onset in (.12, .40):
dt = np.maximum(t - onset, 0)
envelope = (t >= onset) * (1 - np.exp(-dt * 1000)) * np.exp(-dt * 35)
result += envelope * (np.sin(2 * np.pi * 175 * dt) + .4 * np.sin(2 * np.pi * 320 * dt) + .08 * noise)
elif name == 'chair-shift':
filtered = np.convolve(noise, np.ones(12) / 12, mode='same')
result = (filtered + .12 * np.sin(2 * np.pi * (180 * t + 22 * t * t))) * np.sin(np.pi * t / duration) ** 2
else:
filtered = noise - np.convolve(noise, np.ones(7) / 7, mode='same')
result = filtered * np.sin(np.pi * t / duration) ** 2 * (.65 + .35 * np.sin(2 * np.pi * 7 * t))
result *= .16 / np.max(np.abs(result))
return result.astype(np.float32)