-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_overlay_harness.py
More file actions
executable file
·127 lines (107 loc) · 4.08 KB
/
test_overlay_harness.py
File metadata and controls
executable file
·127 lines (107 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/usr/bin/env python3
"""Test harness for overlay design iteration"""
import sys
import math
import time
from AppKit import NSApplication, NSApp, NSApplicationActivationPolicyAccessory
from Foundation import NSTimer, NSRunLoop, NSDefaultRunLoopMode
# Initialize app first
app = NSApplication.sharedApplication()
app.setActivationPolicy_(NSApplicationActivationPolicyAccessory)
from overlay import get_overlay, BAR_COUNT
from prompt_overlay import PromptOverlay
class OverlayHarness:
def __init__(self):
self.recording_overlay = get_overlay()
self.prompt_overlay = PromptOverlay(on_select=self._on_prompt_select)
self.phase = 0.0
self.mode = "recording" # recording, transcribing, prompt
self.timer = None
def _on_prompt_select(self, text, enter):
print(f"Selected: {text} (enter={enter})")
def start(self):
print("Overlay Test Harness")
print("=" * 40)
print("Commands (type and press Enter):")
print(" r - Show recording overlay (waveform)")
print(" t - Switch to transcribing animation")
print(" s - Toggle shift-held indicator")
print(" p - Show prompt overlay")
print(" h - Hide all overlays")
print(" q - Quit")
print("=" * 40)
# Start with recording overlay
self._show_recording()
# Start animation timer
self.timer = NSTimer.scheduledTimerWithTimeInterval_repeats_block_(
0.05, True, lambda _: self._animate()
)
# Run with stdin checking
import select
import threading
def input_thread():
while True:
try:
line = sys.stdin.readline().strip().lower()
if line == 'q':
NSApp.terminate_(None)
break
elif line == 'r':
self._show_recording()
elif line == 't':
self._show_transcribing()
elif line == 's':
self._toggle_shift()
elif line == 'p':
self._show_prompt()
elif line == 'h':
self._hide_all()
except:
break
t = threading.Thread(target=input_thread, daemon=True)
t.start()
NSApp.run()
def _show_recording(self):
self.prompt_overlay.hide()
self.recording_overlay.show()
self.recording_overlay.set_transcribing(False)
self.mode = "recording"
print("→ Recording mode (waveform)")
def _show_transcribing(self):
self.prompt_overlay.hide()
self.recording_overlay.show()
self.recording_overlay.set_transcribing(True)
self.mode = "transcribing"
print("→ Transcribing mode (animated)")
def _toggle_shift(self):
if hasattr(self, '_shift_held'):
self._shift_held = not self._shift_held
else:
self._shift_held = True
self.recording_overlay.set_shift_held(self._shift_held)
print(f"→ Shift held: {self._shift_held}")
def _show_prompt(self):
self.recording_overlay.hide()
self.prompt_overlay.show()
self.mode = "prompt"
print("→ Prompt overlay")
def _hide_all(self):
self.recording_overlay.hide()
self.prompt_overlay.hide()
self.mode = "hidden"
print("→ All hidden")
def _animate(self):
if self.mode == "recording":
# Simulate waveform data
self.phase += 0.15
values = []
for i in range(BAR_COUNT):
# Mix of waves for organic look
v = (math.sin(self.phase + i * 0.3) * 0.3 +
math.sin(self.phase * 1.7 + i * 0.5) * 0.2 +
math.sin(self.phase * 0.5 + i * 0.2) * 0.2 + 0.3)
values.append(max(0, min(1, v)))
self.recording_overlay.update_waveform(values, above_threshold=True)
if __name__ == "__main__":
harness = OverlayHarness()
harness.start()