Skip to content

Commit 93a270e

Browse files
activate swipe
1 parent 26398c1 commit 93a270e

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pytch"
7-
version = "0.3.0"
7+
version = "2.2.0"
88
description = "A Real-Time Pitch Analysis Tool For Polyphonic Music"
99
authors = [
1010
{name = "Pytch Contributors"}

pytch/audio.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,12 @@ def compute_f0(self, audio, lvl):
342342
if lvl[0, c] < self.f0_lvl_threshold:
343343
continue
344344

345+
audio_tmp = np.concatenate(
346+
(audio[:, c][::-1], audio[:, c], audio[:, c][::-1])
347+
)
345348
if self.f0_algorithm == "YIN":
346-
# TODO: replace with real-time version, add real-time SWIPE, relax min/max limits
347349
f0_tmp, _, conf_tmp = libf0.yin(
348-
np.concatenate((audio[:, c][::-1], audio[:, c], audio[:, c][::-1])),
350+
audio_tmp,
349351
Fs=self.fs,
350352
N=self.fft_len,
351353
H=self.fft_len,
@@ -356,7 +358,13 @@ def compute_f0(self, audio, lvl):
356358
)
357359
f0[:, c] = np.mean(f0_tmp) # take the center frame
358360
conf[:, c] = 1 - np.mean(conf_tmp)
359-
361+
elif self.f0_algorithm == "SWIPE":
362+
# TODO: replace with real-time version when available
363+
f0_tmp, _, conf_tmp = libf0.swipe(
364+
audio[:, c], Fs=self.fs, H=self.fft_len, F_min=80.0, F_max=640.0
365+
)
366+
f0[:, c] = np.mean(f0_tmp)
367+
conf[:, c] = 1 - np.mean(conf_tmp)
360368
else:
361369
f0[:, c] = np.zeros(f0.shape[0])
362370
conf[:, c] = np.zeros(f0.shape[0])

pytch/gui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def __init__(self, sounddevice_idx, channels, fs, fft_size, out_path):
189189
self.fs = fs
190190
self.fft_size = fft_size
191191
self.out_path = out_path
192-
self.f0_algorithms = ["YIN"]
192+
self.f0_algorithms = ["YIN", "SWIPE"]
193193
self.buf_len_sec = 30.0
194194
self.spec_scale_types = ["log", "linear"]
195195
self.ref_freq_modes = ["fixed", "highest", "lowest"]

0 commit comments

Comments
 (0)