acoular 24.10__py3-none-any.whl → 25.3__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.
- acoular/__init__.py +5 -2
- acoular/aiaa/__init__.py +12 -0
- acoular/{tools → aiaa}/aiaa.py +23 -28
- acoular/base.py +75 -55
- acoular/calib.py +129 -34
- acoular/configuration.py +11 -9
- acoular/demo/__init__.py +1 -0
- acoular/demo/acoular_demo.py +31 -18
- acoular/deprecation.py +85 -0
- acoular/environments.py +481 -229
- acoular/fastFuncs.py +90 -84
- acoular/fbeamform.py +203 -411
- acoular/fprocess.py +233 -123
- acoular/grids.py +793 -424
- acoular/h5cache.py +29 -40
- acoular/h5files.py +2 -6
- acoular/microphones.py +197 -74
- acoular/process.py +660 -149
- acoular/sdinput.py +23 -20
- acoular/signals.py +461 -159
- acoular/sources.py +1311 -489
- acoular/spectra.py +328 -352
- acoular/tbeamform.py +79 -202
- acoular/tfastfuncs.py +21 -21
- acoular/tools/__init__.py +2 -8
- acoular/tools/helpers.py +216 -2
- acoular/tools/metrics.py +4 -4
- acoular/tools/utils.py +106 -200
- acoular/tprocess.py +348 -309
- acoular/traitsviews.py +10 -10
- acoular/trajectory.py +126 -53
- acoular/version.py +2 -2
- {acoular-24.10.dist-info → acoular-25.3.dist-info}/METADATA +39 -17
- acoular-25.3.dist-info/RECORD +56 -0
- {acoular-24.10.dist-info → acoular-25.3.dist-info}/WHEEL +1 -1
- acoular-24.10.dist-info/RECORD +0 -54
- {acoular-24.10.dist-info → acoular-25.3.dist-info}/licenses/AUTHORS.rst +0 -0
- {acoular-24.10.dist-info → acoular-25.3.dist-info}/licenses/LICENSE +0 -0
acoular/sdinput.py
CHANGED
|
@@ -9,16 +9,19 @@
|
|
|
9
9
|
SoundDeviceSamplesGenerator
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
|
-
from traits.api import Any, Bool, Float, Int,
|
|
12
|
+
from traits.api import Any, Bool, Enum, Float, Int, Property, cached_property, observe
|
|
13
13
|
|
|
14
|
+
# acoular imports
|
|
14
15
|
from .base import SamplesGenerator
|
|
15
16
|
from .configuration import config
|
|
17
|
+
from .deprecation import deprecated_alias
|
|
16
18
|
from .internal import digest
|
|
17
19
|
|
|
18
20
|
if config.have_sounddevice:
|
|
19
21
|
import sounddevice as sd
|
|
20
22
|
|
|
21
23
|
|
|
24
|
+
@deprecated_alias({'numchannels': 'num_channels', 'numsamples': 'num_samples', 'collectsamples': 'collect_samples'})
|
|
22
25
|
class SoundDeviceSamplesGenerator(SamplesGenerator):
|
|
23
26
|
"""Controller for sound card hardware using sounddevice library.
|
|
24
27
|
|
|
@@ -37,14 +40,14 @@ class SoundDeviceSamplesGenerator(SamplesGenerator):
|
|
|
37
40
|
device = Int(0, desc='input device index')
|
|
38
41
|
|
|
39
42
|
#: Number of input channels, maximum depends on device
|
|
40
|
-
|
|
43
|
+
num_channels = Int(1, desc='number of analog input channels that collects data')
|
|
41
44
|
|
|
42
|
-
#: Number of samples to collect; defaults to -1.
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
+
#: Number of samples to collect; defaults to -1. If is set to -1 device collects until user
|
|
46
|
+
# breaks streaming by setting Trait: collect_samples = False.
|
|
47
|
+
num_samples = Int(-1, desc='number of samples to collect')
|
|
45
48
|
|
|
46
49
|
#: Indicates if samples are collected, helper trait to break result loop
|
|
47
|
-
|
|
50
|
+
collect_samples = Bool(True, desc='Indicates if samples are collected')
|
|
48
51
|
|
|
49
52
|
#: Sampling frequency of the signal, changes with sinusdevices
|
|
50
53
|
sample_freq = Property(desc='sampling frequency')
|
|
@@ -52,7 +55,7 @@ class SoundDeviceSamplesGenerator(SamplesGenerator):
|
|
|
52
55
|
_sample_freq = Float(default_value=None)
|
|
53
56
|
|
|
54
57
|
#: Datatype (resolution) of the signal, used as `dtype` in a sd `Stream` object
|
|
55
|
-
precision =
|
|
58
|
+
precision = Enum('float32', 'float16', 'int32', 'int16', 'int8', 'uint8', desc='precision (resolution) of signal')
|
|
56
59
|
|
|
57
60
|
#: Indicates that the sounddevice buffer has overflown
|
|
58
61
|
overflow = Bool(False, desc='Indicates if sounddevice buffer overflow')
|
|
@@ -64,16 +67,16 @@ class SoundDeviceSamplesGenerator(SamplesGenerator):
|
|
|
64
67
|
stream = Any
|
|
65
68
|
|
|
66
69
|
# internal identifier
|
|
67
|
-
digest = Property(depends_on=['device', '
|
|
70
|
+
digest = Property(depends_on=['device', 'num_channels', 'num_samples'])
|
|
68
71
|
|
|
69
72
|
@cached_property
|
|
70
73
|
def _get_digest(self):
|
|
71
74
|
return digest(self)
|
|
72
75
|
|
|
73
|
-
# checks that
|
|
74
|
-
@observe('device,
|
|
75
|
-
def
|
|
76
|
-
self.
|
|
76
|
+
# checks that num_channels are not more than device can provide
|
|
77
|
+
@observe('device, num_channels')
|
|
78
|
+
def _get_num_channels(self, event): # noqa ARG002
|
|
79
|
+
self.num_channels = min(self.num_channels, sd.query_devices(self.device)['max_input_channels'])
|
|
77
80
|
|
|
78
81
|
def _get_sample_freq(self):
|
|
79
82
|
if self._sample_freq is None:
|
|
@@ -102,14 +105,14 @@ class SoundDeviceSamplesGenerator(SamplesGenerator):
|
|
|
102
105
|
|
|
103
106
|
Returns
|
|
104
107
|
-------
|
|
105
|
-
Samples in blocks of shape (num, :attr:`
|
|
108
|
+
Samples in blocks of shape (num, :attr:`num_channels`).
|
|
106
109
|
The last block may be shorter than num.
|
|
107
110
|
|
|
108
111
|
"""
|
|
109
112
|
print(self.device_properties(), self.sample_freq)
|
|
110
113
|
self.stream = stream_obj = sd.InputStream(
|
|
111
114
|
device=self.device,
|
|
112
|
-
channels=self.
|
|
115
|
+
channels=self.num_channels,
|
|
113
116
|
clip_off=True,
|
|
114
117
|
samplerate=self.sample_freq,
|
|
115
118
|
dtype=self.precision,
|
|
@@ -117,15 +120,15 @@ class SoundDeviceSamplesGenerator(SamplesGenerator):
|
|
|
117
120
|
|
|
118
121
|
with stream_obj as stream:
|
|
119
122
|
self.running = True
|
|
120
|
-
if self.
|
|
121
|
-
while self.
|
|
123
|
+
if self.num_samples == -1:
|
|
124
|
+
while self.collect_samples: # yield data as long as collect_samples is True
|
|
122
125
|
data, self.overflow = stream.read(num)
|
|
123
126
|
yield data[:num]
|
|
124
127
|
|
|
125
|
-
elif self.
|
|
126
|
-
samples_count = 0 #
|
|
127
|
-
while samples_count < self.
|
|
128
|
-
anz = min(num, self.
|
|
128
|
+
elif self.num_samples > 0: # amount of samples to collect is specified by user
|
|
129
|
+
samples_count = 0 # num_samples counter
|
|
130
|
+
while samples_count < self.num_samples:
|
|
131
|
+
anz = min(num, self.num_samples - samples_count)
|
|
129
132
|
data, self.overflow = stream.read(num)
|
|
130
133
|
yield data[:anz]
|
|
131
134
|
samples_count += anz
|