F0 (libsoni.core.f0)
- libsoni.core.f0.sonify_f0(time_f0: ndarray, gains: ndarray | None = None, partials: ndarray = array([1]), partials_amplitudes: ndarray = array([1]), partials_phase_offsets: ndarray | None = None, sonification_duration: int | None = None, fading_duration: float = 0.05, normalize: bool = True, fs: int = 22050) ndarray [source]
Sonifies a F0 trajectory given as 2D Numpy array.
The 2D array must contain time positions and the associated instantaneous frequencies. The sonification is based on the phase information by summation of the instantaneous frequencies. The parameters partials, partials_amplitudes and partials_phase_offsets can be used to shape the sound.
- Parameters:
time_f0 (np.ndarray (np.float32 / np.float64) [shape=(N, 2)]) – 2D array of time positions and f0s.
gains (np.ndarray (np.float32 / np.float64) [shape=(N, )], default = None) – Array containing gain values for f0 values.
partials (np.ndarray (np.float32 / np.float64) [shape=(N, )], default = [1]) – Array containing the desired partials of the fundamental frequencies for sonification. An array [1] leads to sonification with only the fundamental frequency, while an array [1,2] leads to sonification with the fundamental frequency and twice the fundamental frequency.
partials_amplitudes (np.ndarray (np.float32 / np.float64) [shape=(N, )], default = None) – Array containing the amplitudes for partials. An array [1,0.5] causes the first partial to have amplitude 1, while the second partial has amplitude 0.5. If None, the amplitudes for all partials are set to 1.
partials_phase_offsets (np.ndarray (np.float32 / np.float64) [shape=(N, )], default = None) – Array containing the phase offsets for partials. When not defined, the phase offsets for all partials are set to 0.
sonification_duration (int, default = None) – Determines duration of sonification, in samples.
fading_duration (float, default = 0.05) – Determines duration of fade-in and fade-out at beginning and end of the sonification, in seconds.
normalize (bool, default = True) – Determines if output signal is normalized to [-1,1].
fs (int, default = 22050) – Sampling rate, in samples per seconds.
- Returns:
f0_sonification (np.ndarray (np.float32 / np.float64) [shape=(M, )]) – Sonified f0-trajectory.