omnipython-apps 0.1.4.dev8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. apps/__init__.py +5 -0
  2. apps/about/__init__.py +257 -0
  3. apps/about/app.json +1 -0
  4. apps/about/credits.py +12 -0
  5. apps/about/facts.py +398 -0
  6. apps/about/fonts/OFL.txt +93 -0
  7. apps/about/fonts/latin1_14.bin +0 -0
  8. apps/about/fonts/latin1_16.bin +0 -0
  9. apps/about/fonts/latin1_24.bin +0 -0
  10. apps/about/fonts/latin1_32.bin +0 -0
  11. apps/about/fonts/latin1_40.bin +0 -0
  12. apps/backline/__init__.py +58 -0
  13. apps/backline/app.json +1 -0
  14. apps/backline/app.py +475 -0
  15. apps/backline/art.py +717 -0
  16. apps/backline/ask.py +781 -0
  17. apps/backline/box.py +502 -0
  18. apps/backline/cast.py +137 -0
  19. apps/backline/desk/__init__.py +329 -0
  20. apps/backline/desk/editor.py +331 -0
  21. apps/backline/desk/grid.py +154 -0
  22. apps/backline/desk/look.py +169 -0
  23. apps/backline/desk/pedals.py +102 -0
  24. apps/backline/desk/perform.py +157 -0
  25. apps/backline/desk/prompt.py +210 -0
  26. apps/backline/desk/strip.py +159 -0
  27. apps/backline/desk_main.py +226 -0
  28. apps/backline/engine.py +622 -0
  29. apps/backline/floor.py +509 -0
  30. apps/backline/footswitch.py +119 -0
  31. apps/backline/glyphs.py +82 -0
  32. apps/backline/kits.py +428 -0
  33. apps/backline/midipedal.py +362 -0
  34. apps/backline/page_data.py +413 -0
  35. apps/backline/parts.py +145 -0
  36. apps/backline/pedal.py +107 -0
  37. apps/backline/remote.py +134 -0
  38. apps/backline/songs/ballad_68.json +1 -0
  39. apps/backline/songs/bossa.json +1 -0
  40. apps/backline/songs/country_train.json +1 -0
  41. apps/backline/songs/funk.json +1 -0
  42. apps/backline/songs/metal.json +1 -0
  43. apps/backline/songs/pop.json +1 -0
  44. apps/backline/songs/rock.json +1 -0
  45. apps/backline/songs/shuffle.json +1 -0
  46. apps/battery/__init__.py +101 -0
  47. apps/battery/app.json +1 -0
  48. apps/bit_world/act_deck.py +683 -0
  49. apps/bit_world/act_game.py +762 -0
  50. apps/bit_world/act_pet.py +1032 -0
  51. apps/bit_world/app.json +1 -0
  52. apps/bit_world/bit_output.py +45 -0
  53. apps/bit_world/bit_palette.py +503 -0
  54. apps/bit_world/bit_sound.py +431 -0
  55. apps/bit_world/bit_sprites.py +632 -0
  56. apps/bit_world/bit_world.py +534 -0
  57. apps/btreceiver/__init__.py +690 -0
  58. apps/btreceiver/app.json +1 -0
  59. apps/btreceiver/chime.py +155 -0
  60. apps/btreceiver/demo.py +529 -0
  61. apps/btreceiver/screen.py +633 -0
  62. apps/camera/__init__.py +316 -0
  63. apps/camera/app.json +1 -0
  64. apps/card/__init__.py +113 -0
  65. apps/card/app.json +1 -0
  66. apps/cast/__init__.py +631 -0
  67. apps/cast/app.json +1 -0
  68. apps/cast/receivers.py +193 -0
  69. apps/chess/__init__.py +18 -0
  70. apps/chess/app.json +1 -0
  71. apps/chess/app.py +922 -0
  72. apps/chess/art.py +323 -0
  73. apps/chess/ble.py +411 -0
  74. apps/chess/engine.py +925 -0
  75. apps/chess/game.py +327 -0
  76. apps/chess/net.py +261 -0
  77. apps/clock/__init__.py +38 -0
  78. apps/clock/app.json +1 -0
  79. apps/detect/__init__.py +214 -0
  80. apps/detect/app.json +1 -0
  81. apps/fmsynth/__init__.py +41 -0
  82. apps/fmsynth/algorithms.py +61 -0
  83. apps/fmsynth/app.json +1 -0
  84. apps/fmsynth/app.py +355 -0
  85. apps/fmsynth/editor.py +206 -0
  86. apps/fmsynth/engine.py +257 -0
  87. apps/fmsynth/meters.py +262 -0
  88. apps/fmsynth/midi.py +375 -0
  89. apps/fmsynth/panel_view.py +1071 -0
  90. apps/fmsynth/patches/fmsynth-01.syx +0 -0
  91. apps/fmsynth/settings.py +138 -0
  92. apps/fmsynth/voice.py +398 -0
  93. apps/gamepad/__init__.py +685 -0
  94. apps/gamepad/app.json +1 -0
  95. apps/gamepad/pad.py +94 -0
  96. apps/gamepad/watch.py +352 -0
  97. apps/hidden/__init__.py +72 -0
  98. apps/hidden/app.json +1 -0
  99. apps/home/__init__.py +483 -0
  100. apps/home/app.json +1 -0
  101. apps/home/main.py +36 -0
  102. apps/homeassistant/__init__.py +213 -0
  103. apps/homeassistant/api.py +104 -0
  104. apps/homeassistant/app.json +1 -0
  105. apps/huey/__init__.py +287 -0
  106. apps/huey/acting.py +184 -0
  107. apps/huey/actor.py +194 -0
  108. apps/huey/app.json +1 -0
  109. apps/huey/client.py +125 -0
  110. apps/huey/servers.py +121 -0
  111. apps/huey/settings.example.json +8 -0
  112. apps/huey/settings.py +97 -0
  113. apps/huey/turn.py +504 -0
  114. apps/huey/voice.py +217 -0
  115. apps/info/__init__.py +810 -0
  116. apps/info/app.json +1 -0
  117. apps/lora/__init__.py +62 -0
  118. apps/lora/app.json +1 -0
  119. apps/manifest.py +71 -0
  120. apps/medialink_baby_monitor/__init__.py +222 -0
  121. apps/medialink_baby_monitor/app.json +1 -0
  122. apps/medialink_doorbell/__init__.py +251 -0
  123. apps/medialink_doorbell/app.json +1 -0
  124. apps/medialink_hands_free/__init__.py +217 -0
  125. apps/medialink_hands_free/app.json +1 -0
  126. apps/medialink_surveillance_camera/__init__.py +258 -0
  127. apps/medialink_surveillance_camera/app.json +1 -0
  128. apps/medialink_video_doorbell/__init__.py +289 -0
  129. apps/medialink_video_doorbell/app.json +1 -0
  130. apps/medialink_videophone/__init__.py +273 -0
  131. apps/medialink_videophone/app.json +1 -0
  132. apps/medialink_walkie_talkie/__init__.py +228 -0
  133. apps/medialink_walkie_talkie/app.json +1 -0
  134. apps/midicontroller/__init__.py +774 -0
  135. apps/midicontroller/app.json +1 -0
  136. apps/midicontroller/links.py +421 -0
  137. apps/midicontroller/surface.py +343 -0
  138. apps/midiengine/__init__.py +977 -0
  139. apps/midiengine/app.json +1 -0
  140. apps/midiengine/banks.py +85 -0
  141. apps/midiengine/midiin.py +165 -0
  142. apps/midiengine/player.py +392 -0
  143. apps/midiengine/umidiparser.py +1413 -0
  144. apps/mp3/__init__.py +240 -0
  145. apps/mp3/app.json +1 -0
  146. apps/perch/__init__.py +119 -0
  147. apps/perch/app.json +1 -0
  148. apps/perch/huey.py +481 -0
  149. apps/perch/huey_props.py +386 -0
  150. apps/perch/huey_shift.py +42 -0
  151. apps/perch/huey_views.py +296 -0
  152. apps/perch/scene_bench.py +680 -0
  153. apps/perch/scene_coast.py +479 -0
  154. apps/perch/scene_desk.py +492 -0
  155. apps/perch/stage.py +1274 -0
  156. apps/perch/vec.py +366 -0
  157. apps/repl/__init__.py +325 -0
  158. apps/repl/app.json +1 -0
  159. apps/roku/__init__.py +156 -0
  160. apps/roku/app.json +1 -0
  161. apps/rokucam/__init__.py +362 -0
  162. apps/rokucam/app.json +1 -0
  163. apps/security/__init__.py +261 -0
  164. apps/security/app.json +1 -0
  165. apps/settings/__init__.py +221 -0
  166. apps/settings/app.json +1 -0
  167. apps/shell/__init__.py +33 -0
  168. apps/shell/app.json +1 -0
  169. apps/spotify/__init__.py +669 -0
  170. apps/spotify/app.json +1 -0
  171. apps/spotify/screen.py +82 -0
  172. apps/steps/__init__.py +58 -0
  173. apps/steps/app.json +1 -0
  174. apps/stompbox/__init__.py +31 -0
  175. apps/stompbox/app.json +1 -0
  176. apps/stompbox/app.py +668 -0
  177. apps/stompbox/boards.json +20 -0
  178. apps/stompbox/effects.py +241 -0
  179. apps/stompbox/engine.py +340 -0
  180. apps/stompbox/footswitch.py +331 -0
  181. apps/stompbox/inputs.py +449 -0
  182. apps/stompbox/meter.py +72 -0
  183. apps/stompbox/outputs.py +135 -0
  184. apps/stompbox/pedals.txt +45 -0
  185. apps/stompbox/presets.py +106 -0
  186. apps/stompbox/styles.py +135 -0
  187. apps/stompbox/ui.py +817 -0
  188. apps/stompbox/wavfile.py +73 -0
  189. apps/synthstation/__init__.py +20 -0
  190. apps/synthstation/app.json +1 -0
  191. apps/synthstation/audio.py +397 -0
  192. apps/synthstation/catalog.py +50 -0
  193. apps/synthstation/meters.py +136 -0
  194. apps/synthstation/midi.py +380 -0
  195. apps/synthstation/pads.py +177 -0
  196. apps/synthstation/parts.py +128 -0
  197. apps/synthstation/station.py +1069 -0
  198. apps/system/__init__.py +11 -0
  199. apps/system/app.json +1 -0
  200. apps/touchcal/__init__.py +324 -0
  201. apps/touchcal/app.json +1 -0
  202. apps/touchcal/fit.py +262 -0
  203. apps/wake/__init__.py +268 -0
  204. apps/wake/app.json +1 -0
  205. apps/wake/feed.py +155 -0
  206. apps/watch/__init__.py +355 -0
  207. apps/watch/app.json +1 -0
  208. apps/watch/faces.py +35 -0
  209. apps/watch/wheel.py +157 -0
  210. apps/weather/__init__.py +278 -0
  211. apps/weather/app.json +1 -0
  212. apps/weather/icons.py +172 -0
  213. apps/weather/sizing.py +71 -0
  214. apps/weather/zippad.py +172 -0
  215. omnipython_apps-0.1.4.dev8.dist-info/METADATA +33 -0
  216. omnipython_apps-0.1.4.dev8.dist-info/RECORD +218 -0
  217. omnipython_apps-0.1.4.dev8.dist-info/WHEEL +5 -0
  218. omnipython_apps-0.1.4.dev8.dist-info/top_level.txt +1 -0
apps/huey/voice.py ADDED
@@ -0,0 +1,217 @@
1
+ # SPDX-FileCopyrightText: 2026 Brad Barnett
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ """Record a question from the board's microphone, and play speech as it arrives.
5
+
6
+ A `Recorder` fills one buffer, a little on every tick of the app, and a
7
+ `Player` writes sound to the speaker the same way, so neither holds the
8
+ screen. Both say how loud the sound just handled was, which is what the
9
+ ring round Huey and his mouth follow.
10
+ """
11
+
12
+ from multimer import ticks_diff, ticks_ms
13
+
14
+ import boarddev
15
+ from audiodev import AudioFormat
16
+
17
+ _LAG_MS = 10 # a microphone is asked only for sound it has surely taken by now
18
+ _TAIL_MS = 600 # what a speaker may still hold after the last write
19
+
20
+
21
+ def level(data):
22
+ """How loud 16-bit *data* is, 0 to 1: the largest of a sample in every eight."""
23
+ most = 0
24
+ for i in range(1, len(data), 16):
25
+ high = data[i]
26
+ if high > 127:
27
+ high = 255 - high
28
+ if high > most:
29
+ most = high
30
+ return most / 127
31
+
32
+
33
+ def open_microphone(rate):
34
+ """The board's microphone, open at *rate*, mono."""
35
+ mic = boarddev.pcm_in(AudioFormat(rate, 1, 16))
36
+ mic.open()
37
+ return mic
38
+
39
+
40
+ def open_speaker(rate, channels):
41
+ """The board's speaker, open at *rate*."""
42
+ speaker = boarddev.pcm_out(AudioFormat(rate, channels, 16))
43
+ speaker.open()
44
+ return speaker
45
+
46
+
47
+ class Recorder:
48
+ """A question being recorded, 16-bit mono at *rate*, *seconds* at most.
49
+
50
+ Args:
51
+ rate (int): Samples a second.
52
+ seconds (int): The longest recording; its buffer is made once, here.
53
+ opener: What opens the microphone; `open_microphone` unless given.
54
+ """
55
+
56
+ def __init__(self, rate, seconds, opener=open_microphone):
57
+ self.rate = rate
58
+ #: The longest recording, in seconds.
59
+ self.most = seconds
60
+ self._opener = opener
61
+ self._buffer = bytearray(rate * 2 * seconds)
62
+ self._view = memoryview(self._buffer)
63
+ self._mic = None
64
+ self._got = 0
65
+ self._began = 0
66
+ #: How loud the newest sound was, 0 to 1, and the loudest of the recording.
67
+ self.level = 0.0
68
+ self.loudest = 0.0
69
+
70
+ @property
71
+ def recording(self):
72
+ return self._mic is not None
73
+
74
+ @property
75
+ def full(self):
76
+ return self._got >= len(self._buffer)
77
+
78
+ def start(self):
79
+ """Open the microphone and begin."""
80
+ self._got = 0
81
+ self.level = self.loudest = 0.0
82
+ self._mic = self._opener(self.rate)
83
+ self._began = ticks_ms()
84
+
85
+ def _take(self):
86
+ due = (ticks_diff(ticks_ms(), self._began) - _LAG_MS) * self.rate // 1000 * 2
87
+ want = min(due, len(self._buffer)) - self._got
88
+ want -= want % 2
89
+ if want <= 0:
90
+ return
91
+ piece = self._view[self._got : self._got + want]
92
+ self._mic.readinto(piece)
93
+ self._got += want
94
+ self.level = level(piece)
95
+ if self.level > self.loudest:
96
+ self.loudest = self.level
97
+
98
+ def poll(self):
99
+ """Take the sound that has come in since the last call."""
100
+ if self._mic is not None:
101
+ self._take()
102
+
103
+ def stop(self):
104
+ """Close the microphone.
105
+
106
+ Returns:
107
+ The recording, a view of this recorder's buffer: use it before the next `start`.
108
+ """
109
+ if self._mic is not None:
110
+ try:
111
+ self._take()
112
+ finally:
113
+ mic, self._mic = self._mic, None
114
+ mic.close()
115
+ return self._view[: self._got]
116
+
117
+ def seconds(self):
118
+ return self._got / (self.rate * 2)
119
+
120
+
121
+ class Player:
122
+ """Speech played as it arrives.
123
+
124
+ A worker `put`s sound in and calls `end` after the last of it; the app
125
+ calls `play` on every tick, which hands the speaker what it has room for.
126
+
127
+ Args:
128
+ volume (int): 0 to 100.
129
+ opener: What opens the speaker; `open_speaker` unless given.
130
+ """
131
+
132
+ #: Bytes that may wait here; the worker stops reading from the network while it is full.
133
+ ROOM = 256 * 1024
134
+
135
+ def __init__(self, volume, opener=open_speaker):
136
+ self._opener = opener
137
+ self._volume = volume
138
+ self._speaker = None
139
+ self._queue = []
140
+ self._put = 0 # bytes put in: only the worker adds to it
141
+ self._odd = b"" # the start of a frame whose end hasn't arrived
142
+ #: Bytes in a frame of the speech: the worker sets it before the first `put`.
143
+ self.frame = 2
144
+ self._part = None # what is left of the piece being written
145
+ self._ended = False
146
+ self._last = 0
147
+ #: How loud the newest sound written was, 0 to 1.
148
+ self.level = 0.0
149
+ #: Bytes written to the speaker.
150
+ self.played = 0
151
+
152
+ # -- from the worker -------------------------------------------------
153
+
154
+ def has_room(self):
155
+ return self._put - self.played < self.ROOM
156
+
157
+ def put(self, data):
158
+ """Take *data* as it came off the network, and queue the whole frames in it."""
159
+ if self._odd:
160
+ data = self._odd + data
161
+ over = len(data) % self.frame
162
+ self._odd = bytes(data[len(data) - over :]) if over else b""
163
+ if over:
164
+ data = data[: len(data) - over]
165
+ if data:
166
+ self._queue.append(data)
167
+ self._put += len(data)
168
+
169
+ def end(self):
170
+ self._ended = True
171
+
172
+ # -- from the app ----------------------------------------------------
173
+
174
+ def open(self, rate, channels):
175
+ """Open the speaker for speech at *rate*."""
176
+ self._speaker = self._opener(rate, channels)
177
+ self._speaker.set_volume(self._volume)
178
+
179
+ @property
180
+ def is_open(self):
181
+ return self._speaker is not None
182
+
183
+ def play(self):
184
+ """Hand the speaker what it will take now.
185
+
186
+ Returns:
187
+ True once the last of the speech has been played.
188
+ """
189
+ while True:
190
+ if self._part is None:
191
+ if not self._queue:
192
+ break
193
+ self._part = memoryview(self._queue.pop(0))
194
+ taken = self._speaker.try_write(self._part)
195
+ if taken:
196
+ self.level = level(self._part[:taken])
197
+ self.played += taken
198
+ self._last = ticks_ms()
199
+ if taken < len(self._part):
200
+ self._part = self._part[taken:]
201
+ return False
202
+ self._part = None
203
+ # a write of nothing moves on what the speaker holds back
204
+ self._speaker.try_write(b"")
205
+ if not self._ended:
206
+ return False
207
+ self.level = 0.0
208
+ return self.played == 0 or ticks_diff(ticks_ms(), self._last) > _TAIL_MS
209
+
210
+ def close(self):
211
+ """Stop at once and let the speaker go."""
212
+ self._queue = []
213
+ self._part = None
214
+ self._ended = True
215
+ if self._speaker is not None:
216
+ speaker, self._speaker = self._speaker, None
217
+ speaker.close()