bedcmmPitch 0.1.0__tar.gz
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.
- bedcmmpitch-0.1.0/LICENSE +42 -0
- bedcmmpitch-0.1.0/LICENSE.ja +44 -0
- bedcmmpitch-0.1.0/MANIFEST.in +2 -0
- bedcmmpitch-0.1.0/PKG-INFO +270 -0
- bedcmmpitch-0.1.0/README.md +255 -0
- bedcmmpitch-0.1.0/bedcmmPitch/__init__.py +19 -0
- bedcmmpitch-0.1.0/bedcmmPitch/_config.py +6 -0
- bedcmmpitch-0.1.0/bedcmmPitch/cy_impl.c +37022 -0
- bedcmmpitch-0.1.0/bedcmmPitch/cy_impl.pyx +459 -0
- bedcmmpitch-0.1.0/bedcmmPitch/py_impl.py +502 -0
- bedcmmpitch-0.1.0/bedcmmPitch.egg-info/PKG-INFO +270 -0
- bedcmmpitch-0.1.0/bedcmmPitch.egg-info/SOURCES.txt +19 -0
- bedcmmpitch-0.1.0/bedcmmPitch.egg-info/dependency_links.txt +1 -0
- bedcmmpitch-0.1.0/bedcmmPitch.egg-info/requires.txt +4 -0
- bedcmmpitch-0.1.0/bedcmmPitch.egg-info/top_level.txt +1 -0
- bedcmmpitch-0.1.0/pic/spike_ratio_1000.png +0 -0
- bedcmmpitch-0.1.0/pic/spike_ratio_measure_ratio.png +0 -0
- bedcmmpitch-0.1.0/pyproject.toml +33 -0
- bedcmmpitch-0.1.0/setup.cfg +4 -0
- bedcmmpitch-0.1.0/setup.py +16 -0
- bedcmmpitch-0.1.0/tests/test_bedcmmPitch.py +280 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Custom Research License v1.0
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Feel a Piece of the World
|
|
4
|
+
|
|
5
|
+
1. Grant of License
|
|
6
|
+
This software (the "Software") is provided for non-commercial research, evaluation, and proof-of-concept (PoC) purposes only.
|
|
7
|
+
|
|
8
|
+
Subject to the terms of this license, you are granted a limited, non-exclusive, non-transferable, non-sublicensable license to use, copy, and modify the Software.
|
|
9
|
+
|
|
10
|
+
2. Permitted Use
|
|
11
|
+
You may use the Software for:
|
|
12
|
+
- Academic or industrial research
|
|
13
|
+
- Internal evaluation and testing
|
|
14
|
+
- Proof-of-concept (PoC) and feasibility studies
|
|
15
|
+
|
|
16
|
+
There is no time limitation for PoC usage under this license.
|
|
17
|
+
|
|
18
|
+
3. Restrictions
|
|
19
|
+
You may NOT:
|
|
20
|
+
- Use the Software for any commercial purpose
|
|
21
|
+
- Use the Software in production systems or operational environments
|
|
22
|
+
- Sell, license, sublicense, distribute, or provide the Software as part of any commercial offering
|
|
23
|
+
|
|
24
|
+
4. Commercial Use
|
|
25
|
+
Any commercial use, including but not limited to incorporation into products or services, requires a separate commercial license agreement with the copyright holder.
|
|
26
|
+
|
|
27
|
+
5. Ownership
|
|
28
|
+
The Software is licensed, not sold. All rights not expressly granted are reserved by the copyright holder.
|
|
29
|
+
|
|
30
|
+
6. Termination
|
|
31
|
+
This license is automatically terminated if you fail to comply with any of its terms.
|
|
32
|
+
Upon termination, you must cease all use of the Software.
|
|
33
|
+
|
|
34
|
+
7. Disclaimer of Warranty
|
|
35
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT.
|
|
36
|
+
|
|
37
|
+
8. Limitation of Liability
|
|
38
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING FROM THE USE OF THE SOFTWARE.
|
|
39
|
+
|
|
40
|
+
9. Patent Notice
|
|
41
|
+
This software includes technology related to a patent granted in Japan.
|
|
42
|
+
No patent license is granted under this license, whether expressly or implicitly.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
カスタム研究ライセンス v1.0(参考訳)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Feel a Piece of the World
|
|
4
|
+
|
|
5
|
+
※本日本語版は参考訳です。法的には英語版が優先されます。
|
|
6
|
+
|
|
7
|
+
1. ライセンスの付与
|
|
8
|
+
本ソフトウェア(以下「本ソフトウェア」)は、非商用の研究、評価、および技術検証(PoC)目的に限り提供されます。
|
|
9
|
+
|
|
10
|
+
本ライセンスの条件に従い、利用者には本ソフトウェアを使用、複製、および改変するための、限定的、非独占的、譲渡不可、再許諾不可のライセンスが付与されます。
|
|
11
|
+
|
|
12
|
+
2. 許可される利用
|
|
13
|
+
利用者は以下の目的で本ソフトウェアを利用できます:
|
|
14
|
+
- 学術または産業上の研究
|
|
15
|
+
- 内部評価および検証
|
|
16
|
+
- 技術検証(PoC)および実現可能性評価
|
|
17
|
+
|
|
18
|
+
PoC利用については、期間制限はありません。
|
|
19
|
+
|
|
20
|
+
3. 禁止事項
|
|
21
|
+
利用者は以下の行為を行ってはなりません:
|
|
22
|
+
- 商用目的での利用
|
|
23
|
+
- 本番環境または運用システムでの利用
|
|
24
|
+
- 本ソフトウェアの販売、ライセンス提供、再許諾、または商用サービスの一部としての提供
|
|
25
|
+
|
|
26
|
+
4. 商用利用
|
|
27
|
+
製品やサービスへの組み込みを含む商用利用には、別途ライセンス契約が必要です。
|
|
28
|
+
|
|
29
|
+
5. 権利帰属
|
|
30
|
+
本ソフトウェアは販売されるものではなく、ライセンスされるものです。明示的に許可されていないすべての権利は著作権者に帰属します。
|
|
31
|
+
|
|
32
|
+
6. ライセンスの終了
|
|
33
|
+
本ライセンスの条件に違反した場合、本ライセンスは自動的に終了します。
|
|
34
|
+
終了後は、本ソフトウェアの使用を直ちに停止しなければなりません。
|
|
35
|
+
|
|
36
|
+
7. 免責事項
|
|
37
|
+
本ソフトウェアは「現状有姿(AS IS)」で提供され、明示または黙示を問わず、商品性、特定目的への適合性、非侵害性を含むいかなる保証も行いません。
|
|
38
|
+
|
|
39
|
+
8. 責任の制限
|
|
40
|
+
本ソフトウェアの使用に起因または関連して生じたいかなる損害についても、著作権者は一切の責任を負いません。
|
|
41
|
+
|
|
42
|
+
9. 特許に関する注意
|
|
43
|
+
本ソフトウェアには、日本において特許が成立している技術に関連する内容が含まれます。
|
|
44
|
+
本ライセンスは、明示的または黙示的に特許ライセンスを付与するものではありません。
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bedcmmPitch
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pitch detection using periodicity analysis
|
|
5
|
+
Author: WATARU YASUHARA
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Requires-Python: >=3.11
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
License-File: LICENSE.ja
|
|
11
|
+
Requires-Dist: numpy>=2.0.2
|
|
12
|
+
Provides-Extra: dev
|
|
13
|
+
Requires-Dist: pytest; extra == "dev"
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
# bedcmmPitch
|
|
17
|
+
**Research / Evaluation / PoC use only.**
|
|
18
|
+
## Pitch Detection Algorithm
|
|
19
|
+
|
|
20
|
+
This repository provides a pitch detection algorithm based on a periodicity analysis method.
|
|
21
|
+
It is intended for research and Proof of Concept (PoC) use.
|
|
22
|
+
Robust to spike-like noise and impulsive artifacts.
|
|
23
|
+
|
|
24
|
+
The implementation includes two main functions:
|
|
25
|
+
- `calc_Pitch`: computes pitch values
|
|
26
|
+
- `calc_bedcmm`: outputs intermediate periodicity analysis results
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
### Install from PyPI
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install bedcmmPitch
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Optional: Build Cython extension from source
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
python setup.py build_ext --inplace
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Example
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
import numpy as np
|
|
46
|
+
from bedcmmPitch import calc_Pitch
|
|
47
|
+
|
|
48
|
+
fs = 44100
|
|
49
|
+
t = np.arange(fs) / fs
|
|
50
|
+
x = np.sin(2*np.pi*440*t)
|
|
51
|
+
|
|
52
|
+
pitch, score = calc_Pitch(x)
|
|
53
|
+
|
|
54
|
+
print(np.nanmean(pitch))
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Robustness to Spike Noise (Comparison with pYIN)
|
|
58
|
+
|
|
59
|
+
We compared this method with pYIN implemented in librosa under spike noise conditions.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Results
|
|
63
|
+
|
|
64
|
+
#### Time-series comparison (spike ratio = 1000)
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
- YIN shows large pitch errors under spike noise
|
|
68
|
+
- pYIN is more stable but still degrades
|
|
69
|
+
- bedcmm remains stable
|
|
70
|
+
|
|
71
|
+
#### Detection rate vs spike noise
|
|
72
|
+

|
|
73
|
+
|
|
74
|
+
Detection rate is defined as the ratio of frames where
|
|
75
|
+
the pitch error is within ±5% of the ground truth.
|
|
76
|
+
|
|
77
|
+
### Experimental Setup
|
|
78
|
+
- Signal: 220 Hz sine wave
|
|
79
|
+
- Sampling rate: 44.1 kHz
|
|
80
|
+
- Spike noise: random impulses with varying amplitude ratio (see `simulation_test.py`)
|
|
81
|
+
- Window size: 2048
|
|
82
|
+
- Hop size: 256
|
|
83
|
+
|
|
84
|
+
### Notes
|
|
85
|
+
- pYIN uses default parameters from librosa
|
|
86
|
+
- bedcmm uses default parameters unless otherwise noted
|
|
87
|
+
- Reproducible scripts are available in `simulation_test.py`.
|
|
88
|
+
|
|
89
|
+
### Summary
|
|
90
|
+
bedcmm shows significantly higher robustness to spike noise compared to pYIN.
|
|
91
|
+
|
|
92
|
+
## About bedcmm
|
|
93
|
+
|
|
94
|
+
`bedcmm` is a periodicity analysis method used as the core of this pitch detection algorithm.
|
|
95
|
+
|
|
96
|
+
For more details, please refer to the original repository:
|
|
97
|
+
https://github.com/YASUHARA-Wataru/bedcmm
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Requirements
|
|
101
|
+
|
|
102
|
+
- numpy
|
|
103
|
+
|
|
104
|
+
Cython is only required when building from source.
|
|
105
|
+
|
|
106
|
+
## Functions
|
|
107
|
+
|
|
108
|
+
### calc_Pitch
|
|
109
|
+
|
|
110
|
+
**Input (default):**
|
|
111
|
+
- `data` : 1D array (signal data)
|
|
112
|
+
- `fs (44100)` : float (sampling rate)
|
|
113
|
+
- `window_size (2048)` : int (window size)
|
|
114
|
+
- `hop_size (256)` : int (hop size)
|
|
115
|
+
- `fmin(65)` : float(calculation min freq)
|
|
116
|
+
- `fmax(2000)` : float(calculation max freq)
|
|
117
|
+
- `pp_mode ('positive+negative')` : str (preprocessing mode: `'positive'`, `'negative'`, `'positive+negative'`, `'threshold_diff'`)
|
|
118
|
+
- `pp_threshold (0)` : float (preprocessing threshold, used in `'threshold_diff'` mode)
|
|
119
|
+
- `bedcmm_smooth (3)` : int (smoothing size for bedcmm result; 1 means no smoothing)
|
|
120
|
+
- `pitch_detect_mode ('peak')` : str (peak detection mode: `'score'`, `'static'`, `'maximum'`, `'peak'`)
|
|
121
|
+
- `pitch_detect_thre (0.85)` : float (threshold for peak detection)
|
|
122
|
+
- `interpolator_mode ('parabolic')` : str (peak interpolation mode: `'parabolic'`, `'centroid'`, `'gaussian'`, `'no'`)
|
|
123
|
+
|
|
124
|
+
**Output:**
|
|
125
|
+
- Pitch data: 1D array
|
|
126
|
+
- Score data: 1D array (bedcmm score)
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### calc_bedcmm
|
|
131
|
+
|
|
132
|
+
**Input:**
|
|
133
|
+
- `data` : 1D array (signal data)
|
|
134
|
+
- `fs (44100)` : float (sampling rate)
|
|
135
|
+
- `window_size (2048)` : int (window size)
|
|
136
|
+
- `hop_size (256)` : int (hop size)
|
|
137
|
+
- `fmin(None)` : float(calculation min freq)
|
|
138
|
+
- `fmax(None)` : float(calculation max freq)
|
|
139
|
+
- `pp_mode ('positive')` : str (preprocessing mode)
|
|
140
|
+
- `pp_threshold (0)` : float (used in `'threshold_diff'` mode)
|
|
141
|
+
|
|
142
|
+
**Output:**
|
|
143
|
+
- bedcmm data: 2D array (time, bedcmm)
|
|
144
|
+
- mean data: 1D array (time)
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Calculation speed
|
|
149
|
+
The benchmark script is ```speed_test.py```.
|
|
150
|
+
Real-time factor ≈ 1.0 indicates near real-time processing.
|
|
151
|
+
Values may slightly vary depending on the execution environment.
|
|
152
|
+
|
|
153
|
+
### Cython
|
|
154
|
+
preprocessing mode 'positive+negative'(default)(Accurate:Robust to noise and outliers)
|
|
155
|
+
```
|
|
156
|
+
=== Benchmark Result ===
|
|
157
|
+
audio_sec proc_sec real_time_factor
|
|
158
|
+
10 10.9753 1.0975
|
|
159
|
+
20 23.1892 1.1595
|
|
160
|
+
30 31.2636 1.0421
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
preprocessing mode 'positive' (Fast:Reduced computation, slightly less robust)
|
|
164
|
+
```
|
|
165
|
+
=== Benchmark Result ===
|
|
166
|
+
audio_sec proc_sec real_time_factor
|
|
167
|
+
10 4.6133 0.4613
|
|
168
|
+
20 11.0052 0.5503
|
|
169
|
+
30 17.7401 0.5913
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Notes
|
|
173
|
+
|
|
174
|
+
It is recommended to use the default parameters.
|
|
175
|
+
|
|
176
|
+
Default calculation pitch range is 65[Hz] to 2000[Hz].
|
|
177
|
+
|
|
178
|
+
You may observe differences depending on parameter settings, so feel free to experiment if needed.
|
|
179
|
+
|
|
180
|
+
- When `pitch_detect_mode = 'score'`, the threshold is calculated as:
|
|
181
|
+
(mean of input signal) × `pitch_detect_threshold`
|
|
182
|
+
|
|
183
|
+
- When `pitch_detect_mode = 'static'`, `pitch_detect_threshold` is used directly as a threshold.
|
|
184
|
+
|
|
185
|
+
- When `pitch_detect_mode = 'peak'`, the threshold is:
|
|
186
|
+
(maximum peak value of bedcmm) × `pitch_detect_threshold`
|
|
187
|
+
|
|
188
|
+
- When `pitch_detect_mode = 'maximum'`, it may not function properly unless `pitch_range` is restricted.
|
|
189
|
+
|
|
190
|
+
- The default `pp_mode` prioritizes accuracy but is computationally expensive.
|
|
191
|
+
For faster computation, you can use `'positive'` or `'negative'`.
|
|
192
|
+
|
|
193
|
+
- When using `pp_mode = 'threshold_diff'`, all values must be non-negative; otherwise, the scoring mechanism may not function correctly.
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## for Development fast Installation
|
|
198
|
+
|
|
199
|
+
1. Copy the `bedcmmPitch` folder into your working directory
|
|
200
|
+
2. Copy `setup.py` into your working directory
|
|
201
|
+
3. Ensure the following libraries are installed:
|
|
202
|
+
- numpy
|
|
203
|
+
- cython
|
|
204
|
+
- setuptools
|
|
205
|
+
- (optional) matplotlib (for visualization)
|
|
206
|
+
|
|
207
|
+
If not installed, use `pip` or `uv` to install them.
|
|
208
|
+
|
|
209
|
+
4. In your working directory, run:
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
python setup.py build_ext --inplace
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
5. Run `main.py` to verify functionality
|
|
217
|
+
|
|
218
|
+
*Note:* Step 4 can be skipped; the pure Python implementation will still work.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
This repository is available **for research, evaluation, and Proof of Concept (PoC) purposes only**.
|
|
225
|
+
|
|
226
|
+
### Permitted Use
|
|
227
|
+
|
|
228
|
+
- Research use
|
|
229
|
+
- Algorithm evaluation and validation
|
|
230
|
+
- Proof of Concept (PoC)
|
|
231
|
+
|
|
232
|
+
PoC usage is allowed **without time limitation**.
|
|
233
|
+
|
|
234
|
+
### Restrictions
|
|
235
|
+
|
|
236
|
+
The following uses are prohibited:
|
|
237
|
+
|
|
238
|
+
- Commercial use (including integration into products or services, or any monetized usage)
|
|
239
|
+
- Use in production environments (including integration into operational systems)
|
|
240
|
+
|
|
241
|
+
### Commercial Use
|
|
242
|
+
|
|
243
|
+
If you wish to use this software for commercial purposes or in a production environment,
|
|
244
|
+
a **separate commercial license agreement is required**.
|
|
245
|
+
|
|
246
|
+
Please contact via Issues or direct email for inquiries.
|
|
247
|
+
|
|
248
|
+
### Disclaimer
|
|
249
|
+
|
|
250
|
+
This software is provided "AS IS", without warranty of any kind.
|
|
251
|
+
The author shall not be held liable for any damages arising from the use of this software.
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
*For detailed terms, please refer to the `LICENSE` file.*
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
## Contact
|
|
260
|
+
For commercial use, please contact us with a brief description of your use case.
|
|
261
|
+
fapow.contact[at]gmail.com
|
|
262
|
+
|
|
263
|
+
## Patent Notice
|
|
264
|
+
|
|
265
|
+
This repository includes technology related to a patented method in Japan.
|
|
266
|
+
|
|
267
|
+
The patent rights are currently granted in Japan only.
|
|
268
|
+
However, this does not grant any rights for commercial use of this software or the underlying technology.
|
|
269
|
+
|
|
270
|
+
For any commercial or production use, please contact the author.
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# bedcmmPitch
|
|
2
|
+
**Research / Evaluation / PoC use only.**
|
|
3
|
+
## Pitch Detection Algorithm
|
|
4
|
+
|
|
5
|
+
This repository provides a pitch detection algorithm based on a periodicity analysis method.
|
|
6
|
+
It is intended for research and Proof of Concept (PoC) use.
|
|
7
|
+
Robust to spike-like noise and impulsive artifacts.
|
|
8
|
+
|
|
9
|
+
The implementation includes two main functions:
|
|
10
|
+
- `calc_Pitch`: computes pitch values
|
|
11
|
+
- `calc_bedcmm`: outputs intermediate periodicity analysis results
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### Install from PyPI
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install bedcmmPitch
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Optional: Build Cython extension from source
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
python setup.py build_ext --inplace
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Example
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import numpy as np
|
|
31
|
+
from bedcmmPitch import calc_Pitch
|
|
32
|
+
|
|
33
|
+
fs = 44100
|
|
34
|
+
t = np.arange(fs) / fs
|
|
35
|
+
x = np.sin(2*np.pi*440*t)
|
|
36
|
+
|
|
37
|
+
pitch, score = calc_Pitch(x)
|
|
38
|
+
|
|
39
|
+
print(np.nanmean(pitch))
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Robustness to Spike Noise (Comparison with pYIN)
|
|
43
|
+
|
|
44
|
+
We compared this method with pYIN implemented in librosa under spike noise conditions.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Results
|
|
48
|
+
|
|
49
|
+
#### Time-series comparison (spike ratio = 1000)
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
- YIN shows large pitch errors under spike noise
|
|
53
|
+
- pYIN is more stable but still degrades
|
|
54
|
+
- bedcmm remains stable
|
|
55
|
+
|
|
56
|
+
#### Detection rate vs spike noise
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
Detection rate is defined as the ratio of frames where
|
|
60
|
+
the pitch error is within ±5% of the ground truth.
|
|
61
|
+
|
|
62
|
+
### Experimental Setup
|
|
63
|
+
- Signal: 220 Hz sine wave
|
|
64
|
+
- Sampling rate: 44.1 kHz
|
|
65
|
+
- Spike noise: random impulses with varying amplitude ratio (see `simulation_test.py`)
|
|
66
|
+
- Window size: 2048
|
|
67
|
+
- Hop size: 256
|
|
68
|
+
|
|
69
|
+
### Notes
|
|
70
|
+
- pYIN uses default parameters from librosa
|
|
71
|
+
- bedcmm uses default parameters unless otherwise noted
|
|
72
|
+
- Reproducible scripts are available in `simulation_test.py`.
|
|
73
|
+
|
|
74
|
+
### Summary
|
|
75
|
+
bedcmm shows significantly higher robustness to spike noise compared to pYIN.
|
|
76
|
+
|
|
77
|
+
## About bedcmm
|
|
78
|
+
|
|
79
|
+
`bedcmm` is a periodicity analysis method used as the core of this pitch detection algorithm.
|
|
80
|
+
|
|
81
|
+
For more details, please refer to the original repository:
|
|
82
|
+
https://github.com/YASUHARA-Wataru/bedcmm
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Requirements
|
|
86
|
+
|
|
87
|
+
- numpy
|
|
88
|
+
|
|
89
|
+
Cython is only required when building from source.
|
|
90
|
+
|
|
91
|
+
## Functions
|
|
92
|
+
|
|
93
|
+
### calc_Pitch
|
|
94
|
+
|
|
95
|
+
**Input (default):**
|
|
96
|
+
- `data` : 1D array (signal data)
|
|
97
|
+
- `fs (44100)` : float (sampling rate)
|
|
98
|
+
- `window_size (2048)` : int (window size)
|
|
99
|
+
- `hop_size (256)` : int (hop size)
|
|
100
|
+
- `fmin(65)` : float(calculation min freq)
|
|
101
|
+
- `fmax(2000)` : float(calculation max freq)
|
|
102
|
+
- `pp_mode ('positive+negative')` : str (preprocessing mode: `'positive'`, `'negative'`, `'positive+negative'`, `'threshold_diff'`)
|
|
103
|
+
- `pp_threshold (0)` : float (preprocessing threshold, used in `'threshold_diff'` mode)
|
|
104
|
+
- `bedcmm_smooth (3)` : int (smoothing size for bedcmm result; 1 means no smoothing)
|
|
105
|
+
- `pitch_detect_mode ('peak')` : str (peak detection mode: `'score'`, `'static'`, `'maximum'`, `'peak'`)
|
|
106
|
+
- `pitch_detect_thre (0.85)` : float (threshold for peak detection)
|
|
107
|
+
- `interpolator_mode ('parabolic')` : str (peak interpolation mode: `'parabolic'`, `'centroid'`, `'gaussian'`, `'no'`)
|
|
108
|
+
|
|
109
|
+
**Output:**
|
|
110
|
+
- Pitch data: 1D array
|
|
111
|
+
- Score data: 1D array (bedcmm score)
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### calc_bedcmm
|
|
116
|
+
|
|
117
|
+
**Input:**
|
|
118
|
+
- `data` : 1D array (signal data)
|
|
119
|
+
- `fs (44100)` : float (sampling rate)
|
|
120
|
+
- `window_size (2048)` : int (window size)
|
|
121
|
+
- `hop_size (256)` : int (hop size)
|
|
122
|
+
- `fmin(None)` : float(calculation min freq)
|
|
123
|
+
- `fmax(None)` : float(calculation max freq)
|
|
124
|
+
- `pp_mode ('positive')` : str (preprocessing mode)
|
|
125
|
+
- `pp_threshold (0)` : float (used in `'threshold_diff'` mode)
|
|
126
|
+
|
|
127
|
+
**Output:**
|
|
128
|
+
- bedcmm data: 2D array (time, bedcmm)
|
|
129
|
+
- mean data: 1D array (time)
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Calculation speed
|
|
134
|
+
The benchmark script is ```speed_test.py```.
|
|
135
|
+
Real-time factor ≈ 1.0 indicates near real-time processing.
|
|
136
|
+
Values may slightly vary depending on the execution environment.
|
|
137
|
+
|
|
138
|
+
### Cython
|
|
139
|
+
preprocessing mode 'positive+negative'(default)(Accurate:Robust to noise and outliers)
|
|
140
|
+
```
|
|
141
|
+
=== Benchmark Result ===
|
|
142
|
+
audio_sec proc_sec real_time_factor
|
|
143
|
+
10 10.9753 1.0975
|
|
144
|
+
20 23.1892 1.1595
|
|
145
|
+
30 31.2636 1.0421
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
preprocessing mode 'positive' (Fast:Reduced computation, slightly less robust)
|
|
149
|
+
```
|
|
150
|
+
=== Benchmark Result ===
|
|
151
|
+
audio_sec proc_sec real_time_factor
|
|
152
|
+
10 4.6133 0.4613
|
|
153
|
+
20 11.0052 0.5503
|
|
154
|
+
30 17.7401 0.5913
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Notes
|
|
158
|
+
|
|
159
|
+
It is recommended to use the default parameters.
|
|
160
|
+
|
|
161
|
+
Default calculation pitch range is 65[Hz] to 2000[Hz].
|
|
162
|
+
|
|
163
|
+
You may observe differences depending on parameter settings, so feel free to experiment if needed.
|
|
164
|
+
|
|
165
|
+
- When `pitch_detect_mode = 'score'`, the threshold is calculated as:
|
|
166
|
+
(mean of input signal) × `pitch_detect_threshold`
|
|
167
|
+
|
|
168
|
+
- When `pitch_detect_mode = 'static'`, `pitch_detect_threshold` is used directly as a threshold.
|
|
169
|
+
|
|
170
|
+
- When `pitch_detect_mode = 'peak'`, the threshold is:
|
|
171
|
+
(maximum peak value of bedcmm) × `pitch_detect_threshold`
|
|
172
|
+
|
|
173
|
+
- When `pitch_detect_mode = 'maximum'`, it may not function properly unless `pitch_range` is restricted.
|
|
174
|
+
|
|
175
|
+
- The default `pp_mode` prioritizes accuracy but is computationally expensive.
|
|
176
|
+
For faster computation, you can use `'positive'` or `'negative'`.
|
|
177
|
+
|
|
178
|
+
- When using `pp_mode = 'threshold_diff'`, all values must be non-negative; otherwise, the scoring mechanism may not function correctly.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## for Development fast Installation
|
|
183
|
+
|
|
184
|
+
1. Copy the `bedcmmPitch` folder into your working directory
|
|
185
|
+
2. Copy `setup.py` into your working directory
|
|
186
|
+
3. Ensure the following libraries are installed:
|
|
187
|
+
- numpy
|
|
188
|
+
- cython
|
|
189
|
+
- setuptools
|
|
190
|
+
- (optional) matplotlib (for visualization)
|
|
191
|
+
|
|
192
|
+
If not installed, use `pip` or `uv` to install them.
|
|
193
|
+
|
|
194
|
+
4. In your working directory, run:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
python setup.py build_ext --inplace
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
5. Run `main.py` to verify functionality
|
|
202
|
+
|
|
203
|
+
*Note:* Step 4 can be skipped; the pure Python implementation will still work.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
This repository is available **for research, evaluation, and Proof of Concept (PoC) purposes only**.
|
|
210
|
+
|
|
211
|
+
### Permitted Use
|
|
212
|
+
|
|
213
|
+
- Research use
|
|
214
|
+
- Algorithm evaluation and validation
|
|
215
|
+
- Proof of Concept (PoC)
|
|
216
|
+
|
|
217
|
+
PoC usage is allowed **without time limitation**.
|
|
218
|
+
|
|
219
|
+
### Restrictions
|
|
220
|
+
|
|
221
|
+
The following uses are prohibited:
|
|
222
|
+
|
|
223
|
+
- Commercial use (including integration into products or services, or any monetized usage)
|
|
224
|
+
- Use in production environments (including integration into operational systems)
|
|
225
|
+
|
|
226
|
+
### Commercial Use
|
|
227
|
+
|
|
228
|
+
If you wish to use this software for commercial purposes or in a production environment,
|
|
229
|
+
a **separate commercial license agreement is required**.
|
|
230
|
+
|
|
231
|
+
Please contact via Issues or direct email for inquiries.
|
|
232
|
+
|
|
233
|
+
### Disclaimer
|
|
234
|
+
|
|
235
|
+
This software is provided "AS IS", without warranty of any kind.
|
|
236
|
+
The author shall not be held liable for any damages arising from the use of this software.
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
*For detailed terms, please refer to the `LICENSE` file.*
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## Contact
|
|
245
|
+
For commercial use, please contact us with a brief description of your use case.
|
|
246
|
+
fapow.contact[at]gmail.com
|
|
247
|
+
|
|
248
|
+
## Patent Notice
|
|
249
|
+
|
|
250
|
+
This repository includes technology related to a patented method in Japan.
|
|
251
|
+
|
|
252
|
+
The patent rights are currently granted in Japan only.
|
|
253
|
+
However, this does not grant any rights for commercial use of this software or the underlying technology.
|
|
254
|
+
|
|
255
|
+
For any commercial or production use, please contact the author.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# bedcmmPitch/__init__.py
|
|
2
|
+
from ._config import implementation
|
|
3
|
+
import warnings
|
|
4
|
+
from .py_impl import calc_Pitch,calc_bedcmm
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
if implementation != 'Cython':
|
|
8
|
+
python_exe = sys.executable
|
|
9
|
+
warnings.warn(
|
|
10
|
+
f"\n{'='*60}\n"
|
|
11
|
+
f"[bedcmm] 高速版(Cython)がビルドされていないか、読み込めません。\n"
|
|
12
|
+
f"現在は低速なPython版で動作しています。\n\n"
|
|
13
|
+
f"高速化を有効にするには、以下のコマンドを実行してビルドしてください:\n"
|
|
14
|
+
f" {python_exe} setup.py build_ext --inplace\n"
|
|
15
|
+
f"{'='*60}\n",
|
|
16
|
+
RuntimeWarning
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
__all__ = ['calc_Pitch','calc_bedcmm']
|