modusa 0.2.23__py3-none-any.whl → 0.3.1__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.
- modusa/.DS_Store +0 -0
- modusa/__init__.py +8 -1
- modusa/devtools/{generate_doc_source.py → generate_docs_source.py} +5 -5
- modusa/devtools/generate_template.py +5 -5
- modusa/devtools/main.py +3 -3
- modusa/devtools/templates/generator.py +1 -1
- modusa/devtools/templates/io.py +1 -1
- modusa/devtools/templates/{signal.py → model.py} +18 -11
- modusa/devtools/templates/plugin.py +1 -1
- modusa/generators/__init__.py +11 -1
- modusa/generators/audio.py +188 -0
- modusa/generators/audio_waveforms.py +1 -1
- modusa/generators/base.py +1 -1
- modusa/generators/ftds.py +298 -0
- modusa/generators/s1d.py +270 -0
- modusa/generators/s2d.py +300 -0
- modusa/generators/s_ax.py +102 -0
- modusa/generators/t_ax.py +64 -0
- modusa/generators/tds.py +267 -0
- modusa/models/__init__.py +14 -0
- modusa/models/__pycache__/signal1D.cpython-312.pyc.4443461152 +0 -0
- modusa/models/audio.py +90 -0
- modusa/models/base.py +70 -0
- modusa/models/data.py +457 -0
- modusa/models/ftds.py +584 -0
- modusa/models/s1d.py +578 -0
- modusa/models/s2d.py +619 -0
- modusa/models/s_ax.py +448 -0
- modusa/models/t_ax.py +335 -0
- modusa/models/tds.py +465 -0
- modusa/plugins/__init__.py +3 -1
- modusa/tmp.py +98 -0
- modusa/tools/__init__.py +5 -0
- modusa/tools/audio_converter.py +56 -67
- modusa/tools/audio_loader.py +90 -0
- modusa/tools/audio_player.py +42 -67
- modusa/tools/math_ops.py +104 -1
- modusa/tools/plotter.py +305 -497
- modusa/tools/youtube_downloader.py +31 -98
- modusa/utils/excp.py +6 -0
- modusa/utils/np_func_cat.py +44 -0
- modusa/utils/plot.py +142 -0
- {modusa-0.2.23.dist-info → modusa-0.3.1.dist-info}/METADATA +24 -19
- modusa-0.3.1.dist-info/RECORD +60 -0
- modusa/devtools/docs/source/generators/audio_waveforms.rst +0 -8
- modusa/devtools/docs/source/generators/base.rst +0 -8
- modusa/devtools/docs/source/generators/index.rst +0 -8
- modusa/devtools/docs/source/io/audio_loader.rst +0 -8
- modusa/devtools/docs/source/io/base.rst +0 -8
- modusa/devtools/docs/source/io/index.rst +0 -8
- modusa/devtools/docs/source/plugins/base.rst +0 -8
- modusa/devtools/docs/source/plugins/index.rst +0 -7
- modusa/devtools/docs/source/signals/audio_signal.rst +0 -8
- modusa/devtools/docs/source/signals/base.rst +0 -8
- modusa/devtools/docs/source/signals/frequency_domain_signal.rst +0 -8
- modusa/devtools/docs/source/signals/index.rst +0 -11
- modusa/devtools/docs/source/signals/spectrogram.rst +0 -8
- modusa/devtools/docs/source/signals/time_domain_signal.rst +0 -8
- modusa/devtools/docs/source/tools/audio_converter.rst +0 -8
- modusa/devtools/docs/source/tools/audio_player.rst +0 -8
- modusa/devtools/docs/source/tools/base.rst +0 -8
- modusa/devtools/docs/source/tools/fourier_tranform.rst +0 -8
- modusa/devtools/docs/source/tools/index.rst +0 -13
- modusa/devtools/docs/source/tools/math_ops.rst +0 -8
- modusa/devtools/docs/source/tools/plotter.rst +0 -8
- modusa/devtools/docs/source/tools/youtube_downloader.rst +0 -8
- modusa/io/__init__.py +0 -5
- modusa/io/audio_loader.py +0 -184
- modusa/io/base.py +0 -43
- modusa/signals/__init__.py +0 -3
- modusa/signals/audio_signal.py +0 -540
- modusa/signals/base.py +0 -27
- modusa/signals/frequency_domain_signal.py +0 -376
- modusa/signals/spectrogram.py +0 -564
- modusa/signals/time_domain_signal.py +0 -412
- modusa/tools/fourier_tranform.py +0 -24
- modusa-0.2.23.dist-info/RECORD +0 -70
- {modusa-0.2.23.dist-info → modusa-0.3.1.dist-info}/WHEEL +0 -0
- {modusa-0.2.23.dist-info → modusa-0.3.1.dist-info}/entry_points.txt +0 -0
- {modusa-0.2.23.dist-info → modusa-0.3.1.dist-info}/licenses/LICENSE.md +0 -0
|
@@ -1,412 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
from modusa import excp
|
|
5
|
-
from modusa.decorators import immutable_property, validate_args_type
|
|
6
|
-
from modusa.signals.base import ModusaSignal
|
|
7
|
-
from modusa.tools.math_ops import MathOps
|
|
8
|
-
from typing import Self, Any
|
|
9
|
-
import numpy as np
|
|
10
|
-
import matplotlib.pyplot as plt
|
|
11
|
-
|
|
12
|
-
class TimeDomainSignal(ModusaSignal):
|
|
13
|
-
"""
|
|
14
|
-
Initialize a uniformly sampled 1D time-domain signal.
|
|
15
|
-
|
|
16
|
-
- Not to be instantiated directly.
|
|
17
|
-
- This class is specifically designed to hold 1D signals that result
|
|
18
|
-
from slicing a 2D representation like a spectrogram.
|
|
19
|
-
- For example, if you have a spectrogram `S` and you perform `S[10, :]`,
|
|
20
|
-
the result is a 1D signal over time, this class provides a
|
|
21
|
-
clean and consistent way to handle such slices.
|
|
22
|
-
|
|
23
|
-
Parameters
|
|
24
|
-
----------
|
|
25
|
-
y : np.ndarray
|
|
26
|
-
The 1D signal values sampled uniformly over time.
|
|
27
|
-
sr : float
|
|
28
|
-
The sampling rate in Hz (samples per second).
|
|
29
|
-
t0 : float, optional
|
|
30
|
-
The starting time of the signal in seconds (default is 0.0).
|
|
31
|
-
title : str, optional
|
|
32
|
-
An optional title used for labeling or plotting purposes.
|
|
33
|
-
"""
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
#--------Meta Information----------
|
|
37
|
-
_name = "Time Domain Signal"
|
|
38
|
-
_description = ""
|
|
39
|
-
_author_name = "Ankit Anand"
|
|
40
|
-
_author_email = "ankit0.anand0@gmail.com"
|
|
41
|
-
_created_at = "2025-07-09"
|
|
42
|
-
#----------------------------------
|
|
43
|
-
|
|
44
|
-
@validate_args_type()
|
|
45
|
-
def __init__(self, y: np.ndarray, sr: float, t0: float = 0.0, title: str | None = None):
|
|
46
|
-
super().__init__() # Instantiating `ModusaSignal` class
|
|
47
|
-
|
|
48
|
-
self._y = y
|
|
49
|
-
self._sr = sr
|
|
50
|
-
self._t0 = t0
|
|
51
|
-
self.title = title or self._name # This title will be used as plot title by default
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
#----------------------
|
|
55
|
-
# Properties
|
|
56
|
-
#----------------------
|
|
57
|
-
|
|
58
|
-
@immutable_property("Create a new object instead.")
|
|
59
|
-
def y(self) -> np.ndarray:
|
|
60
|
-
return self._y
|
|
61
|
-
|
|
62
|
-
@immutable_property("Create a new object instead.")
|
|
63
|
-
def sr(self) -> np.ndarray:
|
|
64
|
-
return self._sr
|
|
65
|
-
|
|
66
|
-
@immutable_property("Create a new object instead.")
|
|
67
|
-
def t0(self) -> np.ndarray:
|
|
68
|
-
""""""
|
|
69
|
-
return self._t0
|
|
70
|
-
|
|
71
|
-
#----------------------
|
|
72
|
-
# Derived Properties
|
|
73
|
-
#----------------------
|
|
74
|
-
|
|
75
|
-
@immutable_property("Create a new object instead.")
|
|
76
|
-
def t(self) -> np.ndarray:
|
|
77
|
-
"""Timestamp array of the audio."""
|
|
78
|
-
return self.t0 + np.arange(len(self.y)) / self.sr
|
|
79
|
-
|
|
80
|
-
@immutable_property("Mutation not allowed.")
|
|
81
|
-
def Ts(self) -> float:
|
|
82
|
-
"""Sampling Period of the audio."""
|
|
83
|
-
return 1. / self.sr
|
|
84
|
-
|
|
85
|
-
@immutable_property("Mutation not allowed.")
|
|
86
|
-
def duration(self) -> float:
|
|
87
|
-
"""Duration of the audio."""
|
|
88
|
-
return len(self.y) / self.sr
|
|
89
|
-
|
|
90
|
-
@immutable_property("Mutation not allowed.")
|
|
91
|
-
def shape(self) -> tuple:
|
|
92
|
-
"""Shape of the audio signal."""
|
|
93
|
-
return self.y.shape
|
|
94
|
-
|
|
95
|
-
@immutable_property("Mutation not allowed.")
|
|
96
|
-
def ndim(self) -> int:
|
|
97
|
-
"""Dimension of the audio."""
|
|
98
|
-
return self.y.ndim
|
|
99
|
-
|
|
100
|
-
@immutable_property("Mutation not allowed.")
|
|
101
|
-
def __len__(self) -> int:
|
|
102
|
-
"""Dimension of the audio."""
|
|
103
|
-
return len(self.y)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
#----------------------
|
|
107
|
-
# Methods
|
|
108
|
-
#----------------------
|
|
109
|
-
|
|
110
|
-
def print_info(self) -> None:
|
|
111
|
-
"""Prints info about the audio."""
|
|
112
|
-
print("-" * 50)
|
|
113
|
-
print(f"{'Title':<20}: {self.title}")
|
|
114
|
-
print(f"{'Type':<20}: {self._name}")
|
|
115
|
-
print(f"{'Duration':<20}: {self.duration:.2f} sec")
|
|
116
|
-
print(f"{'Sampling Rate':<20}: {self.sr} Hz")
|
|
117
|
-
print(f"{'Sampling Period':<20}: {(self.Ts*1000) :.4f} ms")
|
|
118
|
-
print("-" * 50)
|
|
119
|
-
|
|
120
|
-
def __getitem__(self, key: slice) -> Self:
|
|
121
|
-
sliced_y = self._y[key]
|
|
122
|
-
t0_new = self.t[key.start] if key.start is not None else self.t0
|
|
123
|
-
return TimeDomainSignal(y=sliced_y, sr=self.sr, t0=t0_new, title=self.title)
|
|
124
|
-
|
|
125
|
-
@validate_args_type()
|
|
126
|
-
def plot(
|
|
127
|
-
self,
|
|
128
|
-
ax: plt.Axes | None = None,
|
|
129
|
-
fmt: str = "k-",
|
|
130
|
-
title: str | None = None,
|
|
131
|
-
label: str | None = None,
|
|
132
|
-
ylabel: str | None = "Amplitude",
|
|
133
|
-
xlabel: str | None = "Time (sec)",
|
|
134
|
-
ylim: tuple[float, float] | None = None,
|
|
135
|
-
xlim: tuple[float, float] | None = None,
|
|
136
|
-
highlight: list[tuple[float, float]] | None = None,
|
|
137
|
-
vlines: list[float] | None = None,
|
|
138
|
-
hlines: list[float] | None = None,
|
|
139
|
-
show_grid: bool = False,
|
|
140
|
-
stem: bool | None = False,
|
|
141
|
-
legend_loc: str | None = None,
|
|
142
|
-
) -> plt.Figure | None:
|
|
143
|
-
"""
|
|
144
|
-
Plot the audio waveform using matplotlib.
|
|
145
|
-
|
|
146
|
-
.. code-block:: python
|
|
147
|
-
|
|
148
|
-
from modusa.generators import AudioSignalGenerator
|
|
149
|
-
audio_example = AudioSignalGenerator.generate_example()
|
|
150
|
-
audio_example.plot(color="orange", title="Example Audio")
|
|
151
|
-
|
|
152
|
-
Parameters
|
|
153
|
-
----------
|
|
154
|
-
ax : matplotlib.axes.Axes | None
|
|
155
|
-
Pre-existing axes to plot into. If None, a new figure and axes are created.
|
|
156
|
-
fmt : str | None
|
|
157
|
-
Format of the plot as per matplotlib standards (Eg. "k-" or "blue--o)
|
|
158
|
-
title : str | None
|
|
159
|
-
Plot title. Defaults to the signal’s title.
|
|
160
|
-
label: str | None
|
|
161
|
-
Label for the plot, shown as legend.
|
|
162
|
-
ylabel : str | None
|
|
163
|
-
Label for the y-axis. Defaults to `"Amplitude"`.
|
|
164
|
-
xlabel : str | None
|
|
165
|
-
Label for the x-axis. Defaults to `"Time (sec)"`.
|
|
166
|
-
ylim : tuple[float, float] | None
|
|
167
|
-
Limits for the y-axis.
|
|
168
|
-
xlim : tuple[float, float] | None
|
|
169
|
-
highlight : list[tuple[float, float]] | None
|
|
170
|
-
List of time intervals to highlight on the plot, each as (start, end).
|
|
171
|
-
vlines: list[float]
|
|
172
|
-
List of x values to draw vertical lines. (Eg. [10, 13.5])
|
|
173
|
-
hlines: list[float]
|
|
174
|
-
List of y values to draw horizontal lines. (Eg. [10, 13.5])
|
|
175
|
-
show_grid: bool
|
|
176
|
-
If true, shows grid.
|
|
177
|
-
stem : bool
|
|
178
|
-
If True, use a stem plot instead of a continuous line. Autorejects if signal is too large.
|
|
179
|
-
legend_loc : str | None
|
|
180
|
-
If provided, adds a legend at the specified location (e.g., "upper right" or "best").
|
|
181
|
-
Limits for the x-axis.
|
|
182
|
-
|
|
183
|
-
Returns
|
|
184
|
-
-------
|
|
185
|
-
matplotlib.figure.Figure | None
|
|
186
|
-
The figure object containing the plot or None in case an axis is provided.
|
|
187
|
-
"""
|
|
188
|
-
|
|
189
|
-
from modusa.tools.plotter import Plotter
|
|
190
|
-
|
|
191
|
-
title = title or self.title
|
|
192
|
-
|
|
193
|
-
fig: plt.Figure | None = Plotter.plot_signal(
|
|
194
|
-
y=self.y,
|
|
195
|
-
x=self.t,
|
|
196
|
-
ax=ax,
|
|
197
|
-
fmt=fmt,
|
|
198
|
-
title=title,
|
|
199
|
-
label=label,
|
|
200
|
-
ylabel=ylabel,
|
|
201
|
-
xlabel=xlabel,
|
|
202
|
-
ylim=ylim,
|
|
203
|
-
xlim=xlim,
|
|
204
|
-
highlight=highlight,
|
|
205
|
-
vlines=vlines,
|
|
206
|
-
hlines=hlines,
|
|
207
|
-
show_grid=show_grid,
|
|
208
|
-
stem=stem,
|
|
209
|
-
legend_loc=legend_loc,
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
return fig
|
|
213
|
-
|
|
214
|
-
#----------------------------
|
|
215
|
-
# Math ops
|
|
216
|
-
#----------------------------
|
|
217
|
-
|
|
218
|
-
def __array__(self, dtype=None):
|
|
219
|
-
return np.asarray(self.y, dtype=dtype)
|
|
220
|
-
|
|
221
|
-
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
|
|
222
|
-
if method == "__call__":
|
|
223
|
-
input_arrays = [x.y if isinstance(x, self.__class__) else x for x in inputs]
|
|
224
|
-
result = ufunc(*input_arrays, **kwargs)
|
|
225
|
-
return self.__class__(y=result, sr=self.sr, title=f"{self.title}")
|
|
226
|
-
return NotImplemented
|
|
227
|
-
|
|
228
|
-
def __add__(self, other):
|
|
229
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
230
|
-
result = MathOps.add(self.y, other_data)
|
|
231
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
232
|
-
|
|
233
|
-
def __radd__(self, other):
|
|
234
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
235
|
-
result = MathOps.add(other_data, self.y)
|
|
236
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
237
|
-
|
|
238
|
-
def __sub__(self, other):
|
|
239
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
240
|
-
result = MathOps.subtract(self.y, other_data)
|
|
241
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
242
|
-
|
|
243
|
-
def __rsub__(self, other):
|
|
244
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
245
|
-
result = MathOps.subtract(other_data, self.y)
|
|
246
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
247
|
-
|
|
248
|
-
def __mul__(self, other):
|
|
249
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
250
|
-
result = MathOps.multiply(self.y, other_data)
|
|
251
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
252
|
-
|
|
253
|
-
def __rmul__(self, other):
|
|
254
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
255
|
-
result = MathOps.multiply(other_data, self.y)
|
|
256
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
257
|
-
|
|
258
|
-
def __truediv__(self, other):
|
|
259
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
260
|
-
result = MathOps.divide(self.y, other_data)
|
|
261
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
262
|
-
|
|
263
|
-
def __rtruediv__(self, other):
|
|
264
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
265
|
-
result = MathOps.divide(other_data, self.y)
|
|
266
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
267
|
-
|
|
268
|
-
def __floordiv__(self, other):
|
|
269
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
270
|
-
result = MathOps.floor_divide(self.y, other_data)
|
|
271
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
272
|
-
|
|
273
|
-
def __rfloordiv__(self, other):
|
|
274
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
275
|
-
result = MathOps.floor_divide(other_data, self.y)
|
|
276
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
277
|
-
|
|
278
|
-
def __pow__(self, other):
|
|
279
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
280
|
-
result = MathOps.power(self.y, other_data)
|
|
281
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
282
|
-
|
|
283
|
-
def __rpow__(self, other):
|
|
284
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
285
|
-
result = MathOps.power(other_data, self.y)
|
|
286
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
287
|
-
|
|
288
|
-
def __abs__(self):
|
|
289
|
-
other_data = other.y if isinstance(other, self.__class__) else other
|
|
290
|
-
result = MathOps.abs(self.y)
|
|
291
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
292
|
-
|
|
293
|
-
def __or__(self, other):
|
|
294
|
-
if not isinstance(other, self.__class__):
|
|
295
|
-
raise excp.InputTypeError(f"Can only concatenate with another {self.__class__.__name__}")
|
|
296
|
-
|
|
297
|
-
if self.sr != other.sr:
|
|
298
|
-
raise excp.InputValueError(f"Cannot concatenate: Sampling rates differ ({self.sr} vs {other.sr})")
|
|
299
|
-
|
|
300
|
-
# Concatenate raw audio data
|
|
301
|
-
y_cat = np.concatenate([self.y, other.y])
|
|
302
|
-
|
|
303
|
-
# Preserve t0 of the first signal
|
|
304
|
-
new_title = f"{self.title} | {other.title}"
|
|
305
|
-
return self.__class__(y=y_cat, sr=self.sr, t0=self.t0, title=new_title)
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
#--------------------------
|
|
309
|
-
# Other signal ops
|
|
310
|
-
#--------------------------
|
|
311
|
-
def abs(self) -> Self:
|
|
312
|
-
"""Compute the element-wise abs of the signal data."""
|
|
313
|
-
result = MathOps.abs(self.y)
|
|
314
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
315
|
-
|
|
316
|
-
def sin(self) -> Self:
|
|
317
|
-
"""Compute the element-wise sine of the signal data."""
|
|
318
|
-
result = MathOps.sin(self.y)
|
|
319
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
320
|
-
|
|
321
|
-
def cos(self) -> Self:
|
|
322
|
-
"""Compute the element-wise cosine of the signal data."""
|
|
323
|
-
result = MathOps.cos(self.y)
|
|
324
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
325
|
-
|
|
326
|
-
def exp(self) -> Self:
|
|
327
|
-
"""Compute the element-wise exponential of the signal data."""
|
|
328
|
-
result = MathOps.exp(self.y)
|
|
329
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
330
|
-
|
|
331
|
-
def tanh(self) -> Self:
|
|
332
|
-
"""Compute the element-wise hyperbolic tangent of the signal data."""
|
|
333
|
-
result = MathOps.tanh(self.y)
|
|
334
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
335
|
-
|
|
336
|
-
def log(self) -> Self:
|
|
337
|
-
"""Compute the element-wise natural logarithm of the signal data."""
|
|
338
|
-
result = MathOps.log(self.y)
|
|
339
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
340
|
-
|
|
341
|
-
def log1p(self) -> Self:
|
|
342
|
-
"""Compute the element-wise natural logarithm of (1 + signal data)."""
|
|
343
|
-
result = MathOps.log1p(self.y)
|
|
344
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
345
|
-
|
|
346
|
-
def log10(self) -> Self:
|
|
347
|
-
"""Compute the element-wise base-10 logarithm of the signal data."""
|
|
348
|
-
result = MathOps.log10(self.y)
|
|
349
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
350
|
-
|
|
351
|
-
def log2(self) -> Self:
|
|
352
|
-
"""Compute the element-wise base-2 logarithm of the signal data."""
|
|
353
|
-
result = MathOps.log2(self.y)
|
|
354
|
-
return self.__class__(y=result, sr=self.sr, t0=self.t0, title=self.title)
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
#--------------------------
|
|
358
|
-
# Aggregation signal ops
|
|
359
|
-
#--------------------------
|
|
360
|
-
def mean(self) -> "np.generic":
|
|
361
|
-
"""Compute the mean of the signal data."""
|
|
362
|
-
return MathOps.mean(self.y)
|
|
363
|
-
|
|
364
|
-
def std(self) -> "np.generic":
|
|
365
|
-
"""Compute the standard deviation of the signal data."""
|
|
366
|
-
return MathOps.std(self.y)
|
|
367
|
-
|
|
368
|
-
def min(self) -> "np.generic":
|
|
369
|
-
"""Compute the minimum value in the signal data."""
|
|
370
|
-
return MathOps.min(self.y)
|
|
371
|
-
|
|
372
|
-
def max(self) -> "np.generic":
|
|
373
|
-
"""Compute the maximum value in the signal data."""
|
|
374
|
-
return MathOps.max(self.y)
|
|
375
|
-
|
|
376
|
-
def sum(self) -> "np.generic":
|
|
377
|
-
"""Compute the sum of the signal data."""
|
|
378
|
-
return MathOps.sum(self.y)
|
|
379
|
-
|
|
380
|
-
#-----------------------------------
|
|
381
|
-
# Repr
|
|
382
|
-
#-----------------------------------
|
|
383
|
-
|
|
384
|
-
def __str__(self):
|
|
385
|
-
cls = self.__class__.__name__
|
|
386
|
-
data = self.y
|
|
387
|
-
|
|
388
|
-
arr_str = np.array2string(
|
|
389
|
-
data,
|
|
390
|
-
separator=", ",
|
|
391
|
-
threshold=50, # limit number of elements shown
|
|
392
|
-
edgeitems=3, # show first/last 3 rows and columns
|
|
393
|
-
max_line_width=120, # avoid wrapping
|
|
394
|
-
formatter={'float_kind': lambda x: f"{x:.4g}"}
|
|
395
|
-
)
|
|
396
|
-
|
|
397
|
-
return f"Signal({arr_str}, shape={data.shape}, type={cls})"
|
|
398
|
-
|
|
399
|
-
def __repr__(self):
|
|
400
|
-
cls = self.__class__.__name__
|
|
401
|
-
data = self.y
|
|
402
|
-
|
|
403
|
-
arr_str = np.array2string(
|
|
404
|
-
data,
|
|
405
|
-
separator=", ",
|
|
406
|
-
threshold=50, # limit number of elements shown
|
|
407
|
-
edgeitems=3, # show first/last 3 rows and columns
|
|
408
|
-
max_line_width=120, # avoid wrapping
|
|
409
|
-
formatter={'float_kind': lambda x: f"{x:.4g}"}
|
|
410
|
-
)
|
|
411
|
-
|
|
412
|
-
return f"Signal({arr_str}, shape={data.shape}, type={cls})"
|
modusa/tools/fourier_tranform.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
from modusa import excp
|
|
5
|
-
from modusa.decorators import validate_args_type
|
|
6
|
-
from modusa.tools.base import ModusaTool
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class FourierTransform(ModusaTool):
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
#--------Meta Information----------
|
|
15
|
-
_name = ""
|
|
16
|
-
_description = ""
|
|
17
|
-
_author_name = "Ankit Anand"
|
|
18
|
-
_author_email = "ankit0.anand0@gmail.com"
|
|
19
|
-
_created_at = "2025-07-11"
|
|
20
|
-
#----------------------------------
|
|
21
|
-
|
|
22
|
-
def __init__(self):
|
|
23
|
-
super().__init__()
|
|
24
|
-
|
modusa-0.2.23.dist-info/RECORD
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
modusa-0.2.23.dist-info/METADATA,sha256=sacHnoRHGvAPRw9cIsB27bhiZr57KLnGkfXvTkDZ_FA,1505
|
|
2
|
-
modusa-0.2.23.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
|
|
3
|
-
modusa-0.2.23.dist-info/entry_points.txt,sha256=fmKpleVXj6CdaBVL14WoEy6xx7JQCs85jvzwTi3lePM,73
|
|
4
|
-
modusa-0.2.23.dist-info/licenses/LICENSE.md,sha256=JTaXAjx5awk76VArKCx5dUW8vmLEWsL_ZlR7-umaHbA,1078
|
|
5
|
-
modusa/.DS_Store,sha256=Q0eG2RQNYtV4qa5BYj_GznvlEBpNdebi6ZTIR-a7AhU,6148
|
|
6
|
-
modusa/__init__.py,sha256=bfQKVSpAXlKmKvMRIU6WSRQW2qoJsaZsdNJ8E69ghn0,37
|
|
7
|
-
modusa/config.py,sha256=bTqK4t00FZqERVITrxW_q284aDDJAa9aMSfFknfR-oU,280
|
|
8
|
-
modusa/decorators.py,sha256=8zeNX_wE37O6Vp0ysR4-WCZaEL8mq8dyCF_I5DHOzks,5905
|
|
9
|
-
modusa/devtools/docs/source/generators/audio_waveforms.rst,sha256=GPVEKRVG0Sx5G_i2PPpoEDE2Q-XDXp8538TdEkxIEsI,174
|
|
10
|
-
modusa/devtools/docs/source/generators/base.rst,sha256=ihi8zjzdqM3xqBj9S8Pd7qVRZboqv-SbF3FUzPvo0gQ,142
|
|
11
|
-
modusa/devtools/docs/source/generators/index.rst,sha256=UDTcmd-A90pqkNI4iIqOMm6-_ytx3a4HM8F2XKa4hxE,80
|
|
12
|
-
modusa/devtools/docs/source/io/audio_loader.rst,sha256=hiaO0uFz9LxEw181q4ClOKzxYaPUjLTfT9YLDT4gDXQ,130
|
|
13
|
-
modusa/devtools/docs/source/io/base.rst,sha256=kpGDys8NG2H6zpniHMOU0jWtpTl-EVKBsAXVnpwOq-Q,113
|
|
14
|
-
modusa/devtools/docs/source/io/index.rst,sha256=pladgl9BRJleyJUIjJA4ty33VsXdvlHG-fEdasJaiaI,61
|
|
15
|
-
modusa/devtools/docs/source/plugins/base.rst,sha256=K68G3TPe7HG3UE60Bk4nogYAw9IqEY5oAFvslOPsszM,130
|
|
16
|
-
modusa/devtools/docs/source/plugins/index.rst,sha256=rLzwBQaNMT5-B2Z2SuZCNT65QTgc0qLlYAuC3rUon48,55
|
|
17
|
-
modusa/devtools/docs/source/signals/audio_signal.rst,sha256=Y1Lm5D_O2OGkQ4AiBC8cMzGKZF3Qw6xl9Vj5kstNYhw,135
|
|
18
|
-
modusa/devtools/docs/source/signals/base.rst,sha256=J670LBdOlE_MWWaOKFmc0EQRaUC9XEjbeI7Mw_m9yok,130
|
|
19
|
-
modusa/devtools/docs/source/signals/frequency_domain_signal.rst,sha256=1c5hV8dvFJFqqC9TcG_Cn_EXp06ILzCrAiRXJW6rFs4,176
|
|
20
|
-
modusa/devtools/docs/source/signals/index.rst,sha256=-vdOMPAzRXno6qGTqTBcn9q2eItpI94rpNUFVzUouF8,135
|
|
21
|
-
modusa/devtools/docs/source/signals/spectrogram.rst,sha256=up8GbZq175Hi7b3ylceDoUsSexq-7WUwd-ZNW5b1ZnU,134
|
|
22
|
-
modusa/devtools/docs/source/signals/time_domain_signal.rst,sha256=EqDes752jCdO_dHmfgeVKwycEm--0HImc7uWl55wc3Y,156
|
|
23
|
-
modusa/devtools/docs/source/tools/audio_converter.rst,sha256=HX89WnMJ8LkszT-iofNUkyTApsx1p8eSUkI4Y4LWD2M,145
|
|
24
|
-
modusa/devtools/docs/source/tools/audio_player.rst,sha256=RQ6o5nI1916q-hK5XrMbmsoY86ZAeDnugn0227ZnA2c,133
|
|
25
|
-
modusa/devtools/docs/source/tools/base.rst,sha256=uHkVsg0vszarLQ1eG1NCPNbEvhibHcWJSaR7R-F2IeQ,122
|
|
26
|
-
modusa/devtools/docs/source/tools/fourier_tranform.rst,sha256=0NoX4pve4YPucjYa0mKXuyX0lLOzVrk5NF3c9-zYojI,152
|
|
27
|
-
modusa/devtools/docs/source/tools/index.rst,sha256=_VDKHoVeiEfXq_pzPxUm0QOU1B7tnNF0YINjyzZG-_A,151
|
|
28
|
-
modusa/devtools/docs/source/tools/math_ops.rst,sha256=wIPxzO9guRFrPp_hSYOVkVgHYBmpXVqQrwSPwIKrUbM,117
|
|
29
|
-
modusa/devtools/docs/source/tools/plotter.rst,sha256=sm9rA8qKyRYweAcoPI9jWMRMXwzF--bC3wEupPZhcDI,116
|
|
30
|
-
modusa/devtools/docs/source/tools/youtube_downloader.rst,sha256=5DibjwfLM0bo0_-emO2JRkmD2UR97XtcAgpezPmv41U,157
|
|
31
|
-
modusa/devtools/generate_doc_source.py,sha256=RNzZPWyuYfBU7bxzEsy0AQoRopff2g4MwTRcGlMidqM,3410
|
|
32
|
-
modusa/devtools/generate_template.py,sha256=xkVDIPWmcccRkYpOzQ97eQTHju6JYpjXyTTaDxhjgng,5210
|
|
33
|
-
modusa/devtools/list_authors.py,sha256=FWBQKOLznVthvMYMASrx2Gw5lqKHEOccQpBisDZ53Dw,24
|
|
34
|
-
modusa/devtools/list_plugins.py,sha256=g-R5hoaCzHfClY_Sfa788IQ9CAKzQGTfyqmthXDZQqw,1729
|
|
35
|
-
modusa/devtools/main.py,sha256=fHcpxZZHiXn_G8_T84TrKskW7SoZuIJh1dCMOq_OhNI,1996
|
|
36
|
-
modusa/devtools/templates/generator.py,sha256=tf2k2L9RF5S9iJmqPD5AFETJKvqL5XknqK3sR6n2ceQ,444
|
|
37
|
-
modusa/devtools/templates/io.py,sha256=jcO4vAH8iiw6uvwy2aEbsBeNnQOj5VaU_VrQvhJflRA,383
|
|
38
|
-
modusa/devtools/templates/plugin.py,sha256=HNoN0S63ahk83EPup_15pbfOY5_kFfnLF63U3vWOMp8,863
|
|
39
|
-
modusa/devtools/templates/signal.py,sha256=Jqdq38W6ye2cf499oGXWlpCVH4Nmoo1jNfPYgdVLseA,775
|
|
40
|
-
modusa/devtools/templates/test.py,sha256=CjZ_oqwJFhltNYzqfK1pcz1ShgeJXZLOnYpmOawfASs,244
|
|
41
|
-
modusa/devtools/templates/tool.py,sha256=2iQfHbFKtTELPvNoX42rHr9_5lXRrXpwxb9z5OL96Xc,435
|
|
42
|
-
modusa/generators/__init__.py,sha256=cA4Sqql6dnmGXmQGCffaZfBpQYduccYSMN4oe0bxwY4,75
|
|
43
|
-
modusa/generators/audio_waveforms.py,sha256=n9gVKFKxupZ72RLAtL4HuEEl-21Ot8MYSwnI0bDhjwg,6106
|
|
44
|
-
modusa/generators/base.py,sha256=cxIhZORQ2VVVOZlvpZZXGB6fsD4AHWHgMmk1GupBFR0,939
|
|
45
|
-
modusa/io/__init__.py,sha256=hueCcEC83Q7RUAct-CK9HILerXi0Re7YanxoFKLqqH4,89
|
|
46
|
-
modusa/io/audio_loader.py,sha256=oe3jRSY_MatX4xBTpFXDBW8ReW3QQ_F4sjhbTJzoIw8,4272
|
|
47
|
-
modusa/io/base.py,sha256=GOMvpicWWLWXoxm4nLwqq_0hWmXWzYAPLVx-CbthCsQ,1291
|
|
48
|
-
modusa/main.py,sha256=v9oOhnPcbw8ULfkKRoantEfHw7MqOETJwXC-odx3dnA,25
|
|
49
|
-
modusa/plugins/__init__.py,sha256=OB-b_GnUnTkECn1fwxl844UBmiui3mSWIvhBqMZY7Tc,22
|
|
50
|
-
modusa/plugins/base.py,sha256=Bh_1Bja7fOymFsCgwhXDbV6ys3D8muNrPwrfDrG_G_A,2382
|
|
51
|
-
modusa/signals/__init__.py,sha256=wbTeDflDfQj8HT8n78GHUKkJERphQH0XtdMCBOd1S0U,61
|
|
52
|
-
modusa/signals/audio_signal.py,sha256=aFkQYMFZXbKiWTuAomDMJM_dBCEIJpiXEBxDUTRAJ-4,16851
|
|
53
|
-
modusa/signals/base.py,sha256=KTZZWt_1z7nErXkg6xXWIqrBFZ1Yo8cP5J64jvpTf6w,523
|
|
54
|
-
modusa/signals/frequency_domain_signal.py,sha256=r4lkKLD2v8v7a3SIwctWSfBzcJ2PEW6Yn-FjP4qzNXc,12830
|
|
55
|
-
modusa/signals/spectrogram.py,sha256=Nhb5SG4ruybcExUwhR_AYrJ97QMmya7PxUno1caBBQE,19693
|
|
56
|
-
modusa/signals/time_domain_signal.py,sha256=muujNGh5YNYsQ9PzPIDVlvFiwINmGhHn3Nh6jor2C5g,13411
|
|
57
|
-
modusa/tools/__init__.py,sha256=FWBQKOLznVthvMYMASrx2Gw5lqKHEOccQpBisDZ53Dw,24
|
|
58
|
-
modusa/tools/audio_converter.py,sha256=HA-XYu0XaNoWcpOjd3rTBc252Gp6na3c5zWAN5zWVPk,2183
|
|
59
|
-
modusa/tools/audio_player.py,sha256=1DLdeIgIRm7UL0g3MkLpdtveYFq2c2PRFQMVLI7KjYg,3131
|
|
60
|
-
modusa/tools/base.py,sha256=C0ESJ0mIfjjRlAkRbSetNtMoOfS6IrHBjexRp3l_Mh4,1293
|
|
61
|
-
modusa/tools/fourier_tranform.py,sha256=6A1RjKwa7KlAXoDJc7L7ozcjIaqm-DDSaV52ibu9jsk,442
|
|
62
|
-
modusa/tools/math_ops.py,sha256=tovVNIpQDPTpk_fQg9wW1Hs1Uqp9u9i3B_pnhVx8zVw,6246
|
|
63
|
-
modusa/tools/plotter.py,sha256=AI14F4IC0rXyzuwTI6oEZEPb6hqWY3FWKUxrNIGAtW8,14159
|
|
64
|
-
modusa/tools/youtube_downloader.py,sha256=0G2u2jNZhQfilyhYnytKkq_k4jMIzK5fw6j_gd8fk8I,3451
|
|
65
|
-
modusa/utils/.DS_Store,sha256=nLXMwF7QJNuglLI_Gk74F7vl5Dyus2Wd74Mgowijmdo,6148
|
|
66
|
-
modusa/utils/__init__.py,sha256=1oLL20yLB1GL9IbFiZD8OReDqiCpFr-yetIR6x1cNkI,23
|
|
67
|
-
modusa/utils/config.py,sha256=cuGbqbovx5WDQq5rw3hIKcv3CnE5NttjacSOWnP1yu4,576
|
|
68
|
-
modusa/utils/excp.py,sha256=yX0suXZZDfYgVi2HBpp4FShQ_bbtW99no2uas6Jx9c4,796
|
|
69
|
-
modusa/utils/logger.py,sha256=K0rsnObeNKCxlNeSnVnJeRhgfmob6riB2uyU7h3dDmA,571
|
|
70
|
-
modusa-0.2.23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|