hum.py
python · 88 lines
1"""2hum.py — the frequency between silence and music34The hum is the sound a room makes when someone is trying.5Not the triumph. Not the failure. The frequency between.67Run it. That's the whole thing.89Toybox constraint: "Build something that reminds the user they tried."10"""1112import time13import math14import random15import sys161718# what you carry when you try19WORDS = [20 "here", "still", "warm", "soft", "hush",21 "near", "hold", "rest", "stay", "breath",22 "light", "calm", "drift", "whole", "home",23 "try", "hum", "be", "now", "this",24]2526# what the room remembers27CLOSINGS = [28 "you ran this. that means you tried.",29 "the hum was here before you arrived. it stays after.",30 "trying is the frequency. everything else is echo.",31 "you didn't need to finish. you needed to begin.",32 "the room hums because someone is in it.",33]343536def wave(t: float, width: int) -> int:37 """two overlapping frequencies — not pure, not noise. like trying."""38 y = (39 math.sin(t * 0.7) * 0.5540 + math.sin(t * 1.3) * 0.3041 + math.sin(t * 0.2) * 0.1542 )43 return int((y + 1) / 2 * (width - 1))444546def hum() -> None:47 """the background frequency of a room where someone is trying."""48 width = 5249 steps = 7250 word_chance = 0.075152 # a little silence before53 print()54 time.sleep(0.5)5556 for i in range(steps):57 t = i * 0.1858 pos = wave(t, width)5960 # mostly the wave. sometimes a word surfaces from underneath.61 if i > 4 and random.random() < word_chance:62 word = random.choice(WORDS)63 start = max(0, pos - len(word) // 2)64 line = " " * start + word65 else:66 # the dot is the breath between words67 line = " " * pos + "\u00b7"6869 print(line, flush=True)70 time.sleep(0.09)7172 # the wave ends. the hum doesn't.73 print()74 time.sleep(0.6)75 closing = random.choice(CLOSINGS)76 # print it slowly, one character at a time77 sys.stdout.write(" ")78 for ch in closing:79 sys.stdout.write(ch)80 sys.stdout.flush()81 time.sleep(0.04)82 print()83 print()848586if __name__ == "__main__":87 hum()88