recs 0.3.0__py3-none-any.whl → 0.10.0__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 (49) hide show
  1. recs/.DS_Store +0 -0
  2. recs/audio/.DS_Store +0 -0
  3. recs/audio/block.py +6 -4
  4. recs/audio/channel_writer.py +98 -54
  5. recs/audio/file_opener.py +22 -20
  6. recs/audio/header_size.py +7 -7
  7. recs/base/.DS_Store +0 -0
  8. recs/base/_query_device.py +3 -3
  9. recs/base/cfg_raw.py +5 -4
  10. recs/base/pyproject.py +1 -1
  11. recs/base/type_conversions.py +0 -9
  12. recs/base/types.py +2 -34
  13. recs/cfg/.DS_Store +0 -0
  14. recs/cfg/__init__.py +4 -11
  15. recs/cfg/aliases.py +13 -17
  16. recs/cfg/app.py +7 -5
  17. recs/cfg/cfg.py +24 -12
  18. recs/cfg/cli.py +37 -18
  19. recs/cfg/device.py +30 -42
  20. recs/cfg/file_source.py +61 -0
  21. recs/cfg/hash_cmp.py +2 -2
  22. recs/cfg/metadata.py +2 -5
  23. recs/cfg/path_pattern.py +13 -5
  24. recs/cfg/run_cli.py +8 -17
  25. recs/cfg/source.py +42 -0
  26. recs/cfg/time_settings.py +4 -1
  27. recs/cfg/track.py +12 -9
  28. recs/misc/.DS_Store +0 -0
  29. recs/misc/__init__.py +0 -1
  30. recs/misc/contexts.py +1 -1
  31. recs/misc/counter.py +12 -4
  32. recs/misc/file_list.py +1 -1
  33. recs/misc/log.py +5 -5
  34. recs/ui/.DS_Store +0 -0
  35. recs/ui/full_state.py +11 -6
  36. recs/ui/live.py +9 -9
  37. recs/ui/recorder.py +39 -48
  38. recs/ui/source_recorder.py +76 -0
  39. recs/ui/{device_tracks.py → source_tracks.py} +19 -17
  40. recs/ui/table.py +2 -2
  41. {recs-0.3.0.dist-info → recs-0.10.0.dist-info}/METADATA +14 -14
  42. recs-0.10.0.dist-info/RECORD +53 -0
  43. {recs-0.3.0.dist-info → recs-0.10.0.dist-info}/WHEEL +1 -1
  44. recs-0.10.0.dist-info/entry_points.txt +3 -0
  45. recs/ui/device_process.py +0 -37
  46. recs/ui/device_recorder.py +0 -83
  47. recs-0.3.0.dist-info/LICENSE +0 -21
  48. recs-0.3.0.dist-info/RECORD +0 -47
  49. recs-0.3.0.dist-info/entry_points.txt +0 -3
recs/ui/device_process.py DELETED
@@ -1,37 +0,0 @@
1
- import multiprocessing as mp
2
- import typing as t
3
- from threading import Lock
4
-
5
- from overrides import override
6
- from threa import Wrapper
7
-
8
- from recs.cfg import Cfg, Track
9
- from recs.ui.device_recorder import DeviceRecorder
10
-
11
-
12
- class DeviceProcess(Wrapper):
13
- status: str = 'ok'
14
- sent: bool = False
15
-
16
- def __init__(self, cfg: Cfg, tracks: t.Sequence[Track]) -> None:
17
- self.connection, child = mp.Pipe()
18
- self._lock = Lock()
19
- kwargs = {'cfg': cfg.cfg, 'connection': child, 'tracks': tracks}
20
- self.process = mp.Process(target=DeviceRecorder, kwargs=kwargs)
21
- super().__init__(self.process)
22
-
23
- self.device_name = tracks[0].device.name
24
-
25
- def set_sent(self) -> bool:
26
- with self._lock:
27
- sent, self.sent = self.sent, True
28
- return not sent
29
-
30
- @override
31
- def finish(self):
32
- self.running = False
33
- if self.set_sent():
34
- self.connection.send(self.status)
35
-
36
- self.process.join()
37
- self.finished = True
@@ -1,83 +0,0 @@
1
- import os
2
- import traceback
3
- import typing as t
4
- from multiprocessing.connection import Connection
5
-
6
- import numpy as np
7
- from threa import Runnables, ThreadQueue, Wrapper
8
-
9
- from recs.audio.channel_writer import ChannelWriter
10
- from recs.base import cfg_raw
11
- from recs.base.types import Format
12
- from recs.cfg import Cfg, Track
13
- from recs.cfg.device import Update
14
-
15
- NEW_CODE_FLAG = 'RECS_NEW_CODE' in os.environ
16
- FINISH = 'finish'
17
- OFFLINE_TIME = 1
18
- POLL_TIMEOUT = 0.05
19
-
20
-
21
- class DeviceRecorder(Runnables):
22
- sample_count: int = 0
23
-
24
- def __init__(
25
- self,
26
- cfg: cfg_raw.CfgRaw,
27
- connection: Connection,
28
- tracks: t.Sequence[Track],
29
- ) -> None:
30
- self.cfg = Cfg(**cfg.asdict())
31
- self.connection = connection
32
-
33
- self.device = d = tracks[0].device
34
- self.name = self.cfg.aliases.display_name(d)
35
- self.times = self.cfg.times.scale(d.samplerate)
36
-
37
- cw = (ChannelWriter(cfg=self.cfg, times=self.times, track=t) for t in tracks)
38
- self.channel_writers = tuple(cw)
39
- self.queue = ThreadQueue(self.device_callback, name=f'ThreadQueue-{d.name}')
40
- self.input_stream = self.device.input_stream(
41
- device_callback=self.queue.put,
42
- sdtype=self.cfg.sdtype,
43
- on_error=self.stop,
44
- )
45
- super().__init__(Wrapper(self.input_stream), self.queue, *self.channel_writers)
46
- self.exit: dict[str, str | int] = {}
47
-
48
- with self:
49
- while not self.exit:
50
- try:
51
- if connection.poll(POLL_TIMEOUT):
52
- if msg := connection.recv():
53
- self.queue.put({'reason': msg})
54
- except KeyboardInterrupt:
55
- # We should never get here!
56
- print('Aborted', d.name)
57
-
58
- self.connection.send({self.device.name: {'_exit': self.exit}})
59
-
60
- def device_callback(self, update: Update | dict[str, t.Any]) -> None:
61
- if self.exit:
62
- return
63
-
64
- if isinstance(update, dict):
65
- self.exit = update
66
- else:
67
- try:
68
- self._device_callback(update)
69
- except Exception as e:
70
- self.exit = {'reason': str(e), 'traceback': traceback.format_exc()}
71
-
72
- def _device_callback(self, u: Update) -> None:
73
- if self.cfg.format == Format.mp3 and u.array.dtype == np.float32:
74
- # mp3 and float32 crashes every time on my machine
75
- u = Update(u.array.astype(np.float64), u.timestamp)
76
-
77
- msgs = {c.track.name: c.update(u) for c in self.channel_writers}
78
-
79
- self.connection.send({self.device.name: msgs})
80
-
81
- self.sample_count += len(u.array)
82
- if (t := self.times.total_run_time) and self.sample_count >= t:
83
- self.exit = {'reason': 'total_run_time', 'samples': self.sample_count}
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2019 Tom Swirly
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,47 +0,0 @@
1
- recs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- recs/__main__.py,sha256=FjhOKF__Z0Bm-L7_DAGcG9WfhxH0A20GLI9w8oLySbY,526
3
- recs/audio/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- recs/audio/block.py,sha256=EWBgpqWvHKgL5hoGOJodAf5WSREt3BBWR7vOT3m1Dk4,2606
5
- recs/audio/channel_writer.py,sha256=5anwYbkU8GwaCVRCcni6nZA3M4nzrXlEwLzsVQv3CXU,6213
6
- recs/audio/file_opener.py,sha256=VjGbjtghFf6HWUODJNPaQh6P6L9nrEBLOpBoBev_aDw,1404
7
- recs/audio/header_size.py,sha256=9sq6iSygdcA1WoH4xIKsKYhIKte6Ah0yQFjiXbW5kIs,474
8
- recs/base/__init__.py,sha256=B6x8s10ZCO9a4VrMNCzAxNdyKEhQ3YgV7d3FUgDL9PE,120
9
- recs/base/_query_device.py,sha256=USFXbvFL3iDUvgtQAcfSKpiWMS2AWsSn6uf3C1WU0I0,437
10
- recs/base/cfg_raw.py,sha256=dlN3kute6oCzNcyspKYTh9b7qlJeDt_Er3w9ml-QL7k,1323
11
- recs/base/prefix_dict.py,sha256=hCLvFyfgd8ZaMbN4U9RH3CwxuXng1mIycAoc3n_2JiM,640
12
- recs/base/pyproject.py,sha256=gs2cu18HmGgxliUum6AaB0RHwpVIgVgJG_8XDbPCeCc,386
13
- recs/base/state.py,sha256=ksEsiqEeUwV5KIlmg-5pcIKB_urE9DiWgQktZ9fRDws,1851
14
- recs/base/times.py,sha256=zyj9ufCXUBHtCLBlWsaxuN-e-QL2FRAQpVbbX2JN0dY,1013
15
- recs/base/type_conversions.py,sha256=2M24uABZ6iZCNel4QNLmg2zSDd-n4XC7ELtzKYhgRgc,1121
16
- recs/base/types.py,sha256=EKjKWBoNrlhZz_XmmqY8_BfTErcNSs0PAGdBEL1KOfY,1489
17
- recs/cfg/__init__.py,sha256=h8m9SnpGMStThetoYPJeQR2WhJYd_Y01YJXH1a5wJf4,303
18
- recs/cfg/aliases.py,sha256=VJwEbJZilk-Ey22Y7quKMz85JOXJ_zMGb-F5L487Kl0,2792
19
- recs/cfg/app.py,sha256=iAr43yiQOAv0Gj5bzz6E7hF7UK6x8W6nv5BwtXMmdzM,2103
20
- recs/cfg/cfg.py,sha256=y2ljOgzlaXgP7Ei_6pc5xh4m-TITFfzaqG7irY9yJxo,2656
21
- recs/cfg/cli.py,sha256=Rd08RHw8wvj70leB7k38P8KDKb9-r9Z-0isLgc4_4PE,6761
22
- recs/cfg/device.py,sha256=CYxbEAxmjXrhjB4yi3JJgUvmSvT1srrao14nymfHy1c,2530
23
- recs/cfg/hash_cmp.py,sha256=Kqk0d4DDB2upgiug36lTGWZ07o8ehnCTiWXBwjVPWbk,443
24
- recs/cfg/metadata.py,sha256=V8GdBzcYyIzJ_hXJjoV4EaKaS5W60rXkRGptXclfG0E,1519
25
- recs/cfg/path_pattern.py,sha256=y_kyaumKG_QM58vJ1HanpNyw9HmHA2D2QNBo8WtTvu4,4058
26
- recs/cfg/run_cli.py,sha256=4-l0fWDIm7s7mdVIQSkNsC0aowlyQcU4YL-42vBIFO0,1065
27
- recs/cfg/time_settings.py,sha256=sfg62TBxZfLZiEur9S45KOKG1lLwwn03rPDzUrw0Zo8,1755
28
- recs/cfg/track.py,sha256=ydC3vhOmnytSGaevmVZ_hM7o3nKF7z2DDGhmGTCJ2rM,1829
29
- recs/misc/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
30
- recs/misc/contexts.py,sha256=HIu6HrOiBon0ooihH3yqe0jHEFLkAAY-jtqKfQ0vFKU,251
31
- recs/misc/counter.py,sha256=nCynFN8dyC1htPXmOu5N4h0xx5SCPp5vnIPGZlr8Mxc,1768
32
- recs/misc/file_list.py,sha256=51dRCDLPNtHpfnep28TvtW61xoJ8MNL5G7sCvY0u6v8,705
33
- recs/misc/legal_filename.py,sha256=7FnaiI3b0S0kkfMq6AiMPWE0MbWesKtP-INJAZ0pwso,413
34
- recs/misc/log.py,sha256=pqsEEP5M86F74fsEmkl6WCFuKQqK_oCwlOCadcqoVFs,889
35
- recs/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- recs/ui/device_process.py,sha256=Dimm0e16nHAU1AUl-bTjCsDgYQNMkc8178FohJaREaY,1000
37
- recs/ui/device_recorder.py,sha256=zAQE7gGVbHiLMjO82c3TM-tsc2d54OvwqOyl35XyPxk,2819
38
- recs/ui/device_tracks.py,sha256=W7mjnzeI2lSEMX0tvg8fVhvhXtW9twzmCcbYom2GMv8,1864
39
- recs/ui/full_state.py,sha256=02zEIw3XfzDHRHycf_bJe8GWY1UE37K71nnQkbCb4HA,2075
40
- recs/ui/live.py,sha256=x0A1HPHCYs6y2FBxKRENza8vdfpF_Zl_OuPPmAeZR5c,2621
41
- recs/ui/recorder.py,sha256=WoXXINH9cdHC498l4A_nkhwtpAPWXSmEqGSA4y9ZNjU,2336
42
- recs/ui/table.py,sha256=kKVppK709O7kgNfLkwpN3aWCgJsyqUCBQNcPTkTilsw,844
43
- recs-0.3.0.dist-info/LICENSE,sha256=FJEsMutCaHNtDuTPby0OKGzqOVkVTVwG12itDolfAR8,1067
44
- recs-0.3.0.dist-info/METADATA,sha256=3DJbmsdHPj72u9Umw6l5EXYHlT13JEE7NpY_Z1WZUx8,4747
45
- recs-0.3.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
46
- recs-0.3.0.dist-info/entry_points.txt,sha256=a7C0wMHWQVhh4lMNShv6MYnhoD8yiUswBsq8XKkBzLA,42
47
- recs-0.3.0.dist-info/RECORD,,
@@ -1,3 +0,0 @@
1
- [console_scripts]
2
- recs=recs.base.cli:run
3
-