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.
- apps/__init__.py +5 -0
- apps/about/__init__.py +257 -0
- apps/about/app.json +1 -0
- apps/about/credits.py +12 -0
- apps/about/facts.py +398 -0
- apps/about/fonts/OFL.txt +93 -0
- apps/about/fonts/latin1_14.bin +0 -0
- apps/about/fonts/latin1_16.bin +0 -0
- apps/about/fonts/latin1_24.bin +0 -0
- apps/about/fonts/latin1_32.bin +0 -0
- apps/about/fonts/latin1_40.bin +0 -0
- apps/backline/__init__.py +58 -0
- apps/backline/app.json +1 -0
- apps/backline/app.py +475 -0
- apps/backline/art.py +717 -0
- apps/backline/ask.py +781 -0
- apps/backline/box.py +502 -0
- apps/backline/cast.py +137 -0
- apps/backline/desk/__init__.py +329 -0
- apps/backline/desk/editor.py +331 -0
- apps/backline/desk/grid.py +154 -0
- apps/backline/desk/look.py +169 -0
- apps/backline/desk/pedals.py +102 -0
- apps/backline/desk/perform.py +157 -0
- apps/backline/desk/prompt.py +210 -0
- apps/backline/desk/strip.py +159 -0
- apps/backline/desk_main.py +226 -0
- apps/backline/engine.py +622 -0
- apps/backline/floor.py +509 -0
- apps/backline/footswitch.py +119 -0
- apps/backline/glyphs.py +82 -0
- apps/backline/kits.py +428 -0
- apps/backline/midipedal.py +362 -0
- apps/backline/page_data.py +413 -0
- apps/backline/parts.py +145 -0
- apps/backline/pedal.py +107 -0
- apps/backline/remote.py +134 -0
- apps/backline/songs/ballad_68.json +1 -0
- apps/backline/songs/bossa.json +1 -0
- apps/backline/songs/country_train.json +1 -0
- apps/backline/songs/funk.json +1 -0
- apps/backline/songs/metal.json +1 -0
- apps/backline/songs/pop.json +1 -0
- apps/backline/songs/rock.json +1 -0
- apps/backline/songs/shuffle.json +1 -0
- apps/battery/__init__.py +101 -0
- apps/battery/app.json +1 -0
- apps/bit_world/act_deck.py +683 -0
- apps/bit_world/act_game.py +762 -0
- apps/bit_world/act_pet.py +1032 -0
- apps/bit_world/app.json +1 -0
- apps/bit_world/bit_output.py +45 -0
- apps/bit_world/bit_palette.py +503 -0
- apps/bit_world/bit_sound.py +431 -0
- apps/bit_world/bit_sprites.py +632 -0
- apps/bit_world/bit_world.py +534 -0
- apps/btreceiver/__init__.py +690 -0
- apps/btreceiver/app.json +1 -0
- apps/btreceiver/chime.py +155 -0
- apps/btreceiver/demo.py +529 -0
- apps/btreceiver/screen.py +633 -0
- apps/camera/__init__.py +316 -0
- apps/camera/app.json +1 -0
- apps/card/__init__.py +113 -0
- apps/card/app.json +1 -0
- apps/cast/__init__.py +631 -0
- apps/cast/app.json +1 -0
- apps/cast/receivers.py +193 -0
- apps/chess/__init__.py +18 -0
- apps/chess/app.json +1 -0
- apps/chess/app.py +922 -0
- apps/chess/art.py +323 -0
- apps/chess/ble.py +411 -0
- apps/chess/engine.py +925 -0
- apps/chess/game.py +327 -0
- apps/chess/net.py +261 -0
- apps/clock/__init__.py +38 -0
- apps/clock/app.json +1 -0
- apps/detect/__init__.py +214 -0
- apps/detect/app.json +1 -0
- apps/fmsynth/__init__.py +41 -0
- apps/fmsynth/algorithms.py +61 -0
- apps/fmsynth/app.json +1 -0
- apps/fmsynth/app.py +355 -0
- apps/fmsynth/editor.py +206 -0
- apps/fmsynth/engine.py +257 -0
- apps/fmsynth/meters.py +262 -0
- apps/fmsynth/midi.py +375 -0
- apps/fmsynth/panel_view.py +1071 -0
- apps/fmsynth/patches/fmsynth-01.syx +0 -0
- apps/fmsynth/settings.py +138 -0
- apps/fmsynth/voice.py +398 -0
- apps/gamepad/__init__.py +685 -0
- apps/gamepad/app.json +1 -0
- apps/gamepad/pad.py +94 -0
- apps/gamepad/watch.py +352 -0
- apps/hidden/__init__.py +72 -0
- apps/hidden/app.json +1 -0
- apps/home/__init__.py +483 -0
- apps/home/app.json +1 -0
- apps/home/main.py +36 -0
- apps/homeassistant/__init__.py +213 -0
- apps/homeassistant/api.py +104 -0
- apps/homeassistant/app.json +1 -0
- apps/huey/__init__.py +287 -0
- apps/huey/acting.py +184 -0
- apps/huey/actor.py +194 -0
- apps/huey/app.json +1 -0
- apps/huey/client.py +125 -0
- apps/huey/servers.py +121 -0
- apps/huey/settings.example.json +8 -0
- apps/huey/settings.py +97 -0
- apps/huey/turn.py +504 -0
- apps/huey/voice.py +217 -0
- apps/info/__init__.py +810 -0
- apps/info/app.json +1 -0
- apps/lora/__init__.py +62 -0
- apps/lora/app.json +1 -0
- apps/manifest.py +71 -0
- apps/medialink_baby_monitor/__init__.py +222 -0
- apps/medialink_baby_monitor/app.json +1 -0
- apps/medialink_doorbell/__init__.py +251 -0
- apps/medialink_doorbell/app.json +1 -0
- apps/medialink_hands_free/__init__.py +217 -0
- apps/medialink_hands_free/app.json +1 -0
- apps/medialink_surveillance_camera/__init__.py +258 -0
- apps/medialink_surveillance_camera/app.json +1 -0
- apps/medialink_video_doorbell/__init__.py +289 -0
- apps/medialink_video_doorbell/app.json +1 -0
- apps/medialink_videophone/__init__.py +273 -0
- apps/medialink_videophone/app.json +1 -0
- apps/medialink_walkie_talkie/__init__.py +228 -0
- apps/medialink_walkie_talkie/app.json +1 -0
- apps/midicontroller/__init__.py +774 -0
- apps/midicontroller/app.json +1 -0
- apps/midicontroller/links.py +421 -0
- apps/midicontroller/surface.py +343 -0
- apps/midiengine/__init__.py +977 -0
- apps/midiengine/app.json +1 -0
- apps/midiengine/banks.py +85 -0
- apps/midiengine/midiin.py +165 -0
- apps/midiengine/player.py +392 -0
- apps/midiengine/umidiparser.py +1413 -0
- apps/mp3/__init__.py +240 -0
- apps/mp3/app.json +1 -0
- apps/perch/__init__.py +119 -0
- apps/perch/app.json +1 -0
- apps/perch/huey.py +481 -0
- apps/perch/huey_props.py +386 -0
- apps/perch/huey_shift.py +42 -0
- apps/perch/huey_views.py +296 -0
- apps/perch/scene_bench.py +680 -0
- apps/perch/scene_coast.py +479 -0
- apps/perch/scene_desk.py +492 -0
- apps/perch/stage.py +1274 -0
- apps/perch/vec.py +366 -0
- apps/repl/__init__.py +325 -0
- apps/repl/app.json +1 -0
- apps/roku/__init__.py +156 -0
- apps/roku/app.json +1 -0
- apps/rokucam/__init__.py +362 -0
- apps/rokucam/app.json +1 -0
- apps/security/__init__.py +261 -0
- apps/security/app.json +1 -0
- apps/settings/__init__.py +221 -0
- apps/settings/app.json +1 -0
- apps/shell/__init__.py +33 -0
- apps/shell/app.json +1 -0
- apps/spotify/__init__.py +669 -0
- apps/spotify/app.json +1 -0
- apps/spotify/screen.py +82 -0
- apps/steps/__init__.py +58 -0
- apps/steps/app.json +1 -0
- apps/stompbox/__init__.py +31 -0
- apps/stompbox/app.json +1 -0
- apps/stompbox/app.py +668 -0
- apps/stompbox/boards.json +20 -0
- apps/stompbox/effects.py +241 -0
- apps/stompbox/engine.py +340 -0
- apps/stompbox/footswitch.py +331 -0
- apps/stompbox/inputs.py +449 -0
- apps/stompbox/meter.py +72 -0
- apps/stompbox/outputs.py +135 -0
- apps/stompbox/pedals.txt +45 -0
- apps/stompbox/presets.py +106 -0
- apps/stompbox/styles.py +135 -0
- apps/stompbox/ui.py +817 -0
- apps/stompbox/wavfile.py +73 -0
- apps/synthstation/__init__.py +20 -0
- apps/synthstation/app.json +1 -0
- apps/synthstation/audio.py +397 -0
- apps/synthstation/catalog.py +50 -0
- apps/synthstation/meters.py +136 -0
- apps/synthstation/midi.py +380 -0
- apps/synthstation/pads.py +177 -0
- apps/synthstation/parts.py +128 -0
- apps/synthstation/station.py +1069 -0
- apps/system/__init__.py +11 -0
- apps/system/app.json +1 -0
- apps/touchcal/__init__.py +324 -0
- apps/touchcal/app.json +1 -0
- apps/touchcal/fit.py +262 -0
- apps/wake/__init__.py +268 -0
- apps/wake/app.json +1 -0
- apps/wake/feed.py +155 -0
- apps/watch/__init__.py +355 -0
- apps/watch/app.json +1 -0
- apps/watch/faces.py +35 -0
- apps/watch/wheel.py +157 -0
- apps/weather/__init__.py +278 -0
- apps/weather/app.json +1 -0
- apps/weather/icons.py +172 -0
- apps/weather/sizing.py +71 -0
- apps/weather/zippad.py +172 -0
- omnipython_apps-0.1.4.dev8.dist-info/METADATA +33 -0
- omnipython_apps-0.1.4.dev8.dist-info/RECORD +218 -0
- omnipython_apps-0.1.4.dev8.dist-info/WHEEL +5 -0
- 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()
|