Skip to content

Commit

Permalink
fixed #332, pitch contour sonification supports nans
Browse files Browse the repository at this point in the history
  • Loading branch information
bmcfee committed Apr 1, 2024
1 parent ca6d7b2 commit 5a3b369
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mir_eval/sonify.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def pitch_contour(
time indices for each frequency measurement, in seconds
frequencies : np.ndarray
frequency measurements, in Hz.
Non-positive measurements will be interpreted as un-voiced samples.
Non-positive measurements or NaNs will be interpreted as un-voiced samples.
fs : int
desired sampling rate of the output signal
amplitudes : np.ndarray
Expand Down Expand Up @@ -252,6 +252,8 @@ def pitch_contour(
# Squash the negative frequencies.
# wave(0) = 0, so clipping here will un-voice the corresponding instants
frequencies = np.maximum(frequencies, 0.0)
# Convert nans to zeros to unvoice
frequencies = np.nan_to_num(frequencies, copy=False)

# Build a frequency interpolator
f_interp = interp1d(
Expand Down

0 comments on commit 5a3b369

Please sign in to comment.