Skip to content

Commit 1da3ada

Browse files
committed
some small formatting
1 parent 665bd65 commit 1da3ada

2 files changed

Lines changed: 23 additions & 7 deletions

File tree

smstools/models/dftModel.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
# - `dftSynth`: synthesis of a time-domain frame from magnitude/phase
77
# - `dftModel`: convenience analysis+synthesis round-trip for one frame
88

9-
__all__ = ["dftAnal", "dftSynth", "dftModel"]
9+
10+
__all__ = [
11+
"dftAnal",
12+
"dftSynth",
13+
"dftModel",
14+
]
1015

1116

1217
import numpy as np
@@ -29,9 +34,13 @@ def _validate_window_fft_size(w: np.ndarray, N: int) -> None:
2934
ValueError: If N is not a power of 2 or w is larger than N.
3035
"""
3136
if not UF.isPower2(N):
32-
raise ValueError(f"FFT size (N={N}) is not a power of 2. Provided window size: {w.size}.")
37+
raise ValueError(
38+
f"FFT size (N={N}) is not a power of 2. Provided window size: {w.size}."
39+
)
3340
if w.size > N:
34-
raise ValueError(f"Window size (M={w.size}) is bigger than FFT size (N={N}).")
41+
raise ValueError(
42+
f"Window size (M={w.size}) is bigger than FFT size (N={N})."
43+
)
3544

3645
def _positive_spectrum_from_fft(X: np.ndarray, hN: int) -> np.ndarray:
3746
"""
@@ -107,7 +116,9 @@ def dftSynth(mX: np.ndarray, pX: np.ndarray, M: int) -> np.ndarray:
107116
hN = mX.size
108117
N = (hN - 1) * 2
109118
if not UF.isPower2(N):
110-
raise ValueError(f"size of mX ({mX.size}) is not (N/2)+1 for N={N}. Check input spectrum size.")
119+
raise ValueError(
120+
f"size of mX ({mX.size}) is not (N/2)+1 for N={N}. Check input spectrum size."
121+
)
111122
hM1 = (M + 1) // 2
112123
hM2 = M // 2
113124
y = np.zeros(M)

smstools/models/harmonicModel.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# - `harmonicModel`: analysis+synthesis round-trip
77
# - `harmonicModelAnal` / `harmonicModelSynth`: separated analysis/synthesis APIs
88

9+
910
import math
1011

1112
import numpy as np
@@ -77,7 +78,7 @@ def f0Detection(
7778
ipfreq = fs * iploc / N # convert locations to Hz
7879
f0t = UF.f0Twm(ipfreq, ipmag, f0et, minf0, maxf0, f0stable, fs=fs) # find f0
7980
f0stable = f0t if f0t > 0 and abs(f0t - f0stable) < f0et else 0
80-
f0candidate = f0t
81+
# f0candidate = f0t # unused variable
8182
f0 = np.append(f0, f0t) # add f0 to output array
8283
pin += H # advance sound pointer
8384
return f0
@@ -206,7 +207,9 @@ def harmonicModelAnal(
206207
# f0candidate = f0t # unused variable
207208
f0.append(f0t) # add f0 to output list
208209
# Harmonic detection
209-
hfreq, hmag, hphase = harmonicDetection(ipfreq, ipmag, ipphase, f0t, nH, hfreqp, fs, harmDevSlope)
210+
hfreq, hmag, hphase = harmonicDetection(
211+
ipfreq, ipmag, ipphase, f0t, nH, hfreqp, fs, harmDevSlope
212+
)
210213
xhfreq.append(hfreq)
211214
xhmag.append(hmag)
212215
xhphase.append(hphase)
@@ -256,7 +259,9 @@ def harmonicModel(
256259
# User can specify N for analysis
257260
H = 128
258261
Ns = 512
259-
hfreq, hmag, hphase = harmonicModelAnal(x, fs, w, N, H, t, nH, minf0, maxf0, f0et)
262+
hfreq, hmag, hphase = harmonicModelAnal(
263+
x, fs, w, N, H, t, nH, minf0, maxf0, f0et
264+
)
260265
# Synthesize using fixed synthesis parameters
261266
y = SM.sineModelSynth(hfreq, hmag, hphase, Ns, H, fs)
262267
# Ensure output length matches input

0 commit comments

Comments
 (0)