audioflux.utils.synth_f0

audioflux.utils.synth_f0(times, frequencies, samplate, amplitudes=None)

Generate an audio array based on the frequency f0.

Parameters
times: ndarray [shape=(n)]

Time points for each frequency, in seconds.

frequencies: ndarray [shape=(n)]

Array of frequencies, in Hz.

samplate: int

The output sampling rate.

amplitudes: ndarray [shape=(n)]

The amplitude of each frequency, ranging from 0 to 1.

Default is None, which means that the amplitude is 1. Like: np.ones((n,))

Returns
out: ndarray

Return the audio array generated based on the frequencies

Examples

>>> import audioflux as af
>>> import numpy as np
>>> f0_arr = np.ones((1024,)) * 220
>>> times = np.arange(0, f0_arr.shape[0]) * (1024 / 32000)
>>> amplitude_arr = np.ones_like(f0_arr) * 0.4
>>> audio_arr = af.utils.synth_f0(times, f0_arr, 32000, amplitude_arr)