py-mir-toolbox 0.1.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.
mirpy/__init__.py ADDED
@@ -0,0 +1,84 @@
1
+ """mirpy: a Python port of MIRtoolbox for music feature extraction.
2
+
3
+ py-mir-toolbox reproduces the functions and defaults of MIRtoolbox
4
+ (Lartillot & Toiviainen, 2007) in Python. Its code is translated from
5
+ MiningSuite, the BSD-licensed successor of MIRtoolbox, and validated
6
+ numerically against MIRtoolbox 1.8.2.
7
+
8
+ Use :func:`mirpy.cite` to print the references to cite.
9
+ """
10
+
11
+ from mirpy._cite import cite
12
+ from mirpy.core.audio_ops import audio
13
+ from mirpy.core.batch import batch, list_audio
14
+ from mirpy.core.data import Audio, Peaks, Signal, get_data
15
+ from mirpy.core.export import file_table, frame_table, to_arff, to_csv, to_dataframe
16
+ from mirpy.core.framing import frame
17
+ from mirpy.core.options import FrameSpec
18
+ from mirpy.core.peaks import peaks
19
+ from mirpy.features.dynamics import lowenergy, rms
20
+ from mirpy.features.flux import flux
21
+ from mirpy.features.mfcc import Mfcc, mfcc
22
+ from mirpy.features.moments import centroid, entropy, flatness, kurtosis, skewness, spread
23
+ from mirpy.features.spectral import brightness, rolloff
24
+ from mirpy.features.zerocross import zerocross
25
+ from mirpy.signal.autocor import Autocor, autocor
26
+ from mirpy.signal.cepstrum import Cepstrum, cepstrum
27
+ from mirpy.signal.filterbank import filterbank
28
+ from mirpy.signal.spectrum import Spectrum, spectrum
29
+ from mirpy.signal.summation import sum
30
+ from mirpy.stats.histo import Histogram, histo
31
+ from mirpy.stats.summary import mean, median, stat, std
32
+
33
+ try:
34
+ from mirpy._version import __version__
35
+ except ImportError: # running from a source tree without a build
36
+ __version__ = "0.0.0"
37
+
38
+ __all__ = [
39
+ "Audio",
40
+ "Autocor",
41
+ "Cepstrum",
42
+ "FrameSpec",
43
+ "Histogram",
44
+ "Mfcc",
45
+ "Peaks",
46
+ "Signal",
47
+ "Spectrum",
48
+ "__version__",
49
+ "audio",
50
+ "autocor",
51
+ "batch",
52
+ "brightness",
53
+ "centroid",
54
+ "cepstrum",
55
+ "cite",
56
+ "entropy",
57
+ "file_table",
58
+ "filterbank",
59
+ "flatness",
60
+ "flux",
61
+ "frame",
62
+ "frame_table",
63
+ "get_data",
64
+ "histo",
65
+ "kurtosis",
66
+ "list_audio",
67
+ "lowenergy",
68
+ "mean",
69
+ "median",
70
+ "mfcc",
71
+ "peaks",
72
+ "rms",
73
+ "rolloff",
74
+ "skewness",
75
+ "spectrum",
76
+ "spread",
77
+ "stat",
78
+ "std",
79
+ "sum",
80
+ "to_arff",
81
+ "to_csv",
82
+ "to_dataframe",
83
+ "zerocross",
84
+ ]
mirpy/_cite.py ADDED
@@ -0,0 +1,41 @@
1
+ """Citation information for py-mir-toolbox and the original MIRtoolbox."""
2
+
3
+ MIRTOOLBOX_REFERENCES = {
4
+ "lartillot2007": """@inproceedings{lartillot2007,
5
+ author = {Lartillot, Olivier and Toiviainen, Petri},
6
+ title = {A Matlab Toolbox for Musical Feature Extraction from Audio},
7
+ booktitle = {Proceedings of the 10th International Conference on Digital Audio Effects (DAFx-07)},
8
+ address = {Bordeaux, France},
9
+ year = {2007}
10
+ }""",
11
+ "lartillot2008": """@incollection{lartillot2008,
12
+ author = {Lartillot, Olivier and Toiviainen, Petri and Eerola, Tuomas},
13
+ title = {A Matlab Toolbox for Music Information Retrieval},
14
+ booktitle = {Data Analysis, Machine Learning and Applications},
15
+ editor = {Preisach, Christine and Burkhardt, Hans and Schmidt-Thieme, Lars and Decker, Reinhold},
16
+ publisher = {Springer},
17
+ year = {2008}
18
+ }""",
19
+ }
20
+
21
+
22
+ def cite() -> str:
23
+ """Return BibTeX entries for the original MIRtoolbox papers.
24
+
25
+ The citation of py-mir-toolbox itself is in ``CITATION.cff`` in the
26
+ source repository. Please cite both the original MIRtoolbox papers
27
+ and py-mir-toolbox in academic work.
28
+
29
+ Returns
30
+ -------
31
+ str
32
+ BibTeX entries, separated by blank lines.
33
+
34
+ Examples
35
+ --------
36
+ >>> import mirpy
37
+ >>> print(mirpy.cite()) # doctest: +ELLIPSIS
38
+ @inproceedings{lartillot2007,
39
+ ...
40
+ """
41
+ return "\n\n".join(MIRTOOLBOX_REFERENCES.values())
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1 @@
1
+ """Third-party code shipped with mirpy; see each file for its licence."""
@@ -0,0 +1,205 @@
1
+ # Vendored from python_auditory_toolbox 1.0.6 (python_auditory_toolbox/auditory_toolbox.py),
2
+ # https://github.com/MalcolmSlaney/python_auditory_toolbox, by Malcolm Slaney.
3
+ # Licensed under the Apache License, Version 2.0; see LICENSE-APACHE-2.0.txt in this folder.
4
+ #
5
+ # Modified for py-mir-toolbox: only ErbSpace, MakeErbFilters and ErbFilterBank are kept
6
+ # (unchanged); the matplotlib import and the other functions were removed. Vendored
7
+ # because the PyPI package requires jax and torch, which these functions do not use.
8
+ """Gammatone (ERB) filterbank from Slaney's Auditory Toolbox, Python port."""
9
+
10
+ import numpy as np
11
+ from scipy import signal
12
+
13
+ from typing import List
14
+
15
+
16
+ def ErbSpace(low_freq: float = 100, high_freq: float = 44100/4,
17
+ n: int = 100) -> np.ndarray:
18
+ """This function computes an array of N frequencies uniformly spaced between
19
+ high_freq and low_freq on an erb scale. N is set to 100 if not specified.
20
+
21
+ See also linspace, logspace, MakeErbCoeffs, MakeErbFilters.
22
+
23
+ For a definition of erb, see Moore, B. C. J., and Glasberg, B. R. (1983).
24
+ "Suggested formulae for calculating auditory-filter bandwidths and
25
+ excitation patterns," J. Acoust. Soc. Am. 74, 750-753.
26
+
27
+ Args:
28
+ low_freq: The center frequency in Hz of the lowest channel
29
+ high_freq: The upper limit in Hz of the channel bank. The center frequency
30
+ of the highest channel will be below this frequency.
31
+ n: Number of channels
32
+
33
+ Returns:
34
+ An array of center frequencies, equally spaced on the ERB scale.
35
+ """
36
+
37
+ # Change the following three parameters if you wish to use a different
38
+ # erb scale. Must change in MakeerbCoeffs too.
39
+ ear_q = 9.26449 # Glasberg and Moore Parameters
40
+ min_bw = 24.7
41
+
42
+ # All of the follow_freqing expressions are derived in Apple TR #35, "An
43
+ # Efficient Implementation of the Patterson-Holdsworth Cochlear
44
+ # Filter Bank." See pages 33-34.
45
+ cf_array = (-(ear_q*min_bw) +
46
+ np.exp(np.arange(1, 1+n)*
47
+ (-np.log(high_freq + ear_q*min_bw) +
48
+ np.log(low_freq + ear_q*min_bw))/n) * (high_freq +
49
+ ear_q*min_bw))
50
+ return cf_array
51
+
52
+
53
+ def MakeErbFilters(fs: float, num_channels: int,
54
+ low_freq: float = 20) -> List[np.ndarray]:
55
+ """This function computes the filter coefficients for a bank of
56
+ Gammatone filters. These filters were defined by Patterson and
57
+ Holdworth for simulating the cochlea.
58
+
59
+ The result is returned as an array of filter coefficients. Each row
60
+ of the filter arrays contains the coefficients for four second order
61
+ filters. The transfer function for these four filters share the same
62
+ denominator (poles) but have different numerators (zeros). All of these
63
+ coefficients are assembled into one vector that the ErbFilterBank
64
+ can take apart to implement the filter.
65
+
66
+ The filter bank contains "num_channels" channels that extend from
67
+ half the sampling rate (fs) to "low_freq". Alternatively, if the num_channels
68
+ input argument is a vector, then the values of this vector are taken to
69
+ be the center frequency of each desired filter. (The low_freq argument is
70
+ ignored in this case.)
71
+
72
+ Note this implementation fixes a problem in the original code by
73
+ computing four separate second order filters. This avoids a big
74
+ problem with round off errors in cases of very small cfs (100Hz) and
75
+ large sample rates (44kHz). The problem is caused by roundoff error
76
+ when a number of poles are combined, all very close to the unit
77
+ circle. Small errors in the eigth order coefficient, are multiplied
78
+ when the eigth root is taken to give the pole location. These small
79
+ errors lead to poles outside the unit circle and instability. Thanks
80
+ to Julius Smith for leading me to the proper explanation.
81
+
82
+ Execute the following code to evaluate the frequency
83
+ response of a 10 channel filterbank.
84
+ n = 512
85
+ fs = 16000
86
+ fcoefs = pat.MakeErbFilters(16000,10,100)
87
+ y = pat.ErbFilterBank(np.array([1.0] + [0] * (n-1), dtype=float), fcoefs)
88
+ resp = 20*np.log10(np.abs(np.fft.fft(y, axis=1))).T
89
+ freq_scale = np.expand_dims(np.linspace(0, 16000, 512), 1)
90
+ plt.semilogx(freq_scale[:n//2, :], resp[:n//2, :])
91
+ plt.axis((100, fs/2, -60, 0))
92
+ plt.xlabel('Frequency (Hz)')
93
+ plt.ylabel('Filter Response (dB)');
94
+
95
+ Args:
96
+ fs: Sampling rate (in Hz) of the filterbank (needed to determine CFs).
97
+ num_channel: How many channels in the filterbank.
98
+ low_freq: The lowest center frequency of the filterbank.
99
+
100
+ Returns:
101
+ A list of 10 num_channel-D arrays containing the filter parameters.
102
+ """
103
+
104
+ t = 1/fs
105
+ if isinstance(num_channels, int):
106
+ cf = ErbSpace(low_freq, fs/2, num_channels)
107
+ else:
108
+ cf = num_channels
109
+
110
+ # So equations below match the original Matlab syntax
111
+ pi = np.pi
112
+ abs = np.abs # pylint: disable=redefined-builtin
113
+ sqrt = np.sqrt
114
+ sin = np.sin
115
+ cos = np.cos
116
+ exp = np.exp
117
+ i = np.array([1j], dtype=np.csingle)
118
+
119
+ # Change the follow_freqing three parameters if you wish to use a different
120
+ # erb scale. Must change in ErbSpace too.
121
+ ear_q = 9.26449 # Glasberg and Moore Parameters
122
+ min_bw = 24.7
123
+ order = 1
124
+
125
+ erb = ((cf/ear_q)**order + min_bw**order)**(1/order)
126
+ b=1.019*2*pi*erb
127
+
128
+ a0 = t # Feedback coefficients (poles)
129
+ a2 = 0
130
+ b0 = 1 # Feedforward coefficients (zeros)
131
+ b1 = -2*cos(2*cf*pi*t)/exp(b*t)
132
+ b2 = exp(-2*b*t)
133
+
134
+ a11 = -(2*t*cos(2*cf*pi*t)/exp(b*t) + 2*sqrt(3+2**1.5)*t*sin(2*cf*pi*t)/
135
+ exp(b*t))/2
136
+ a12 = -(2*t*cos(2*cf*pi*t)/exp(b*t) - 2*sqrt(3+2**1.5)*t*sin(2*cf*pi*t)/
137
+ exp(b*t))/2
138
+ a13 = -(2*t*cos(2*cf*pi*t)/exp(b*t) + 2*sqrt(3-2**1.5)*t*sin(2*cf*pi*t)/
139
+ exp(b*t))/2
140
+ a14 = -(2*t*cos(2*cf*pi*t)/exp(b*t) - 2*sqrt(3-2**1.5)*t*sin(2*cf*pi*t)/
141
+ exp(b*t))/2
142
+
143
+ gain = abs((-2*exp(4*i*cf*pi*t)*t +
144
+ 2*exp(-(b*t) + 2*i*cf*pi*t)*t*
145
+ (cos(2*cf*pi*t) - sqrt(3 - 2**(3/2))*
146
+ sin(2*cf*pi*t))) *
147
+ (-2*exp(4*i*cf*pi*t)*t +
148
+ 2*exp(-(b*t) + 2*i*cf*pi*t)*t*
149
+ (cos(2*cf*pi*t) + sqrt(3 - 2**(3/2)) *
150
+ sin(2*cf*pi*t)))*
151
+ (-2*exp(4*i*cf*pi*t)*t +
152
+ 2*exp(-(b*t) + 2*i*cf*pi*t)*t*
153
+ (cos(2*cf*pi*t) -
154
+ sqrt(3 + 2**(3/2))*sin(2*cf*pi*t))) *
155
+ (-2*exp(4*i*cf*pi*t)*t + 2*exp(-(b*t) + 2*i*cf*pi*t)*t*
156
+ (cos(2*cf*pi*t) + sqrt(3 + 2**(3/2))*sin(2*cf*pi*t))) /
157
+ (-2 / exp(2*b*t) - 2*exp(4*i*cf*pi*t) +
158
+ 2*(1 + exp(4*i*cf*pi*t))/exp(b*t))**4)
159
+
160
+ allfilts = np.ones(len(cf))
161
+ fcoefs = [a0*allfilts, a11, a12, a13, a14, a2*allfilts,
162
+ b0*allfilts, b1, b2, gain]
163
+ return fcoefs
164
+
165
+
166
+ def ErbFilterBank(x: np.ndarray, fcoefs: List[np.ndarray]) -> np.ndarray:
167
+ """Filter an input signal with a filterbank, producing one output vector
168
+ per channel.
169
+
170
+ Args:
171
+ x: The input signal, one-dimensional
172
+ fcoefs: A list of 10 num-channel-dimensional arrays that describe the
173
+ filterbank.
174
+
175
+ Returns:
176
+ num-channel outputs in a num_channel x time array.
177
+ """
178
+ [a0, a11, a12, a13, a14, a2, b0, b1, b2, gain] = fcoefs
179
+ n_chan = a0.shape[0]
180
+ assert n_chan == a11.shape[0]
181
+ assert n_chan == a12.shape[0]
182
+ assert n_chan == a13.shape[0]
183
+ assert n_chan == a14.shape[0]
184
+ assert n_chan == b0.shape[0]
185
+ assert n_chan == b1.shape[0]
186
+ assert n_chan == b2.shape[0]
187
+ assert n_chan == gain.shape[0]
188
+
189
+ sos = np.stack((np.stack([a0/gain, a0, a0, a0], axis=1),
190
+ np.stack([a11/gain, a12, a13, a14], axis=1),
191
+ np.stack([a2/gain, a2, a2, a2], axis=1),
192
+ np.stack([b0, b0, b0, b0], axis=1),
193
+ np.stack([b1, b1, b1, b1], axis=1),
194
+ np.stack([b2, b2, b2, b2], axis=1)),
195
+ axis=2)
196
+
197
+ all_y = None
198
+ for c in range(n_chan):
199
+ y = signal.sosfilt(sos[c, :, :], x)
200
+ if all_y is None:
201
+ all_y = np.zeros((n_chan, len(y)), dtype=x.dtype)
202
+ all_y[c, :] = y
203
+ return all_y
204
+
205
+
mirpy/_version.py ADDED
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.1.0'
22
+ __version_tuple__ = version_tuple = (0, 1, 0)
23
+
24
+ __commit_id__ = commit_id = None
mirpy/core/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """Core data classes, options and framing shared by all operators."""