Pitch
- class audioflux.PitchCEP(samplate=32000, low_fre=32.0, high_fre=2000.0, radix2_exp=12, slide_length=1024, window_type=WindowType.HAMM)
Pitch CEP algorithm
- Parameters
- samplate: int
Sampling rate of the incoming audio.
- low_fre: float
Lowest frequency. Default is 32.0.
- high_fre: float
Highest frequency. Default is 2000.0.
- radix2_exp: int
fft_length=2**radix2_exp
- slide_length: int
Window sliding length.
- window_type: WindowType
Window type for each frame.
See:
type.WindowType
Examples
Read 220Hz audio data
>>> import audioflux as af >>> audio_path = af.utils.sample_path('220') >>> audio_arr, sr = af.read(audio_path)
Extract pitch
>>> pitch_obj = af.PitchCEP(samplate=sr) >>> fre_arr = pitch_obj.pitch(audio_arr)
Show pitch plot
>>> import matplotlib.pyplot as plt >>> from audioflux.display import fill_plot >>> times = np.arange(fre_arr.shape[-1]) * (pitch_obj.slide_length / sr) >>> fig, ax = plt.subplots() >>> ax.set_title('PitchCEP') >>> fill_plot(times, fre_arr, axes=ax) >>> ax.set_ylim(0, 300)
Methods
cal_time_length
(data_length)Calculate the length of a frame from audio data.
pitch
(data_arr)Compute pitch
- cal_time_length(data_length)
Calculate the length of a frame from audio data.
fft_length = 2 ** radix2_exp
(data_length - fft_length) // slide_length + 1
- Parameters
- data_length: int
The length of the data to be calculated.
- Returns
- out: int
- pitch(data_arr)
Compute pitch
- Parameters
- data_arr: np.ndarray [shape=(…, n)]
Input audio array
- Returns
- fre_arr: np.ndarray [shape=(…, time)]
- class audioflux.PitchHPS(samplate=32000, low_fre=32.0, high_fre=2000.0, radix2_exp=12, slide_length=1024, window_type=WindowType.HAMM, harmonic_count=5)
Pitch HPS algorithm
- Parameters
- samplate: int
Sampling rate of the incoming audio.
- low_fre: float
Lowest frequency. Default is 32.0.
- high_fre: float
Highest frequency. Default is 2000.0.
- radix2_exp: int
fft_length=2**radix2_exp
- slide_length: int
Window sliding length.
- window_type: WindowType
Window type for each frame.
See:
type.WindowType
- harmonic_count: int
Harmonic count. Default is 5.
Examples
Read 220Hz audio data
>>> import audioflux as af >>> audio_path = af.utils.sample_path('220') >>> audio_arr, sr = af.read(audio_path)
Extract pitch
>>> pitch_obj = af.PitchHPS(samplate=sr) >>> fre_arr = pitch_obj.pitch(audio_arr)
Show pitch plot
>>> import matplotlib.pyplot as plt >>> from audioflux.display import fill_plot >>> times = np.arange(fre_arr.shape[-1]) * (pitch_obj.slide_length / sr) >>> fig, ax = plt.subplots() >>> ax.set_title('PitchHPS') >>> fill_plot(times, fre_arr, axes=ax) >>> ax.set_ylim(0, 300)
Methods
cal_time_length
(data_length)Calculate the length of a frame from audio data.
pitch
(data_arr)Compute pitch
- cal_time_length(data_length)
Calculate the length of a frame from audio data.
fft_length = 2 ** radix2_exp
(data_length - fft_length) // slide_length + 1
- Parameters
- data_length: int
The length of the data to be calculated.
- Returns
- out: int
- pitch(data_arr)
Compute pitch
- Parameters
- data_arr: np.ndarray [shape=(…, n)]
Input audio array
- Returns
- fre_arr: np.ndarray [shape=(…, time)]
- class audioflux.PitchLHS(samplate=32000, low_fre=32.0, high_fre=2000.0, radix2_exp=12, slide_length=1024, window_type=WindowType.HAMM, harmonic_count=5)
Pitch LHS algorithm
- Parameters
- samplate: int
Sampling rate of the incoming audio.
- low_fre: float
Lowest frequency. Default is 32.0.
- high_fre: float
Highest frequency. Default is 2000.0.
- radix2_exp: int
fft_length=2**radix2_exp
- slide_length: int
Window sliding length.
- window_type: WindowType
Window type for each frame.
See:
type.WindowType
- harmonic_count: int
Harmonic count. Default is 5.
Examples
Read 220Hz audio data
>>> import audioflux as af >>> audio_path = af.utils.sample_path('220') >>> audio_arr, sr = af.read(audio_path)
Extract pitch
>>> pitch_obj = af.PitchLHS(samplate=sr) >>> fre_arr = pitch_obj.pitch(audio_arr)
Show pitch plot
>>> import matplotlib.pyplot as plt >>> from audioflux.display import fill_plot >>> times = np.arange(fre_arr.shape[-1]) * (pitch_obj.slide_length / sr) >>> fig, ax = plt.subplots() >>> ax.set_title('PitchLHS') >>> fill_plot(times, fre_arr, axes=ax) >>> ax.set_ylim(0, 300)
Methods
cal_time_length
(data_length)Calculate the length of a frame from audio data.
pitch
(data_arr)Compute pitch
- cal_time_length(data_length)
Calculate the length of a frame from audio data.
fft_length = 2 ** radix2_exp
(data_length - fft_length) / slide_length + 1
- Parameters
- data_length: int
The length of the data to be calculated.
- Returns
- out: int
- pitch(data_arr)
Compute pitch
- Parameters
- data_arr: np.ndarray [shape=(…, n)]
Input audio array
- Returns
- fre_arr: np.ndarray [shape=(…, time)]
- class audioflux.PitchNCF(samplate=32000, low_fre=32.0, high_fre=2000.0, radix2_exp=12, slide_length=1024, window_type=WindowType.RECT)
Pitch NCF algorithm
- Parameters
- samplate: int
Sampling rate of the incoming audio.
- low_fre: float
Lowest frequency. Default is 32.0.
- high_fre: float
Highest frequency. Default is 2000.0.
- radix2_exp: int
fft_length=2**radix2_exp
- slide_length: int
Window sliding length.
- window_type: WindowType
Window type for each frame.
See:
type.WindowType
Examples
Read 220Hz audio data
>>> import audioflux as af >>> audio_path = af.utils.sample_path('220') >>> audio_arr, sr = af.read(audio_path)
Extract pitch
>>> pitch_obj = af.PitchNCF(samplate=sr) >>> fre_arr = pitch_obj.pitch(audio_arr)
Show pitch plot
>>> import matplotlib.pyplot as plt >>> from audioflux.display import fill_plot >>> times = np.arange(fre_arr.shape[-1]) * (pitch_obj.slide_length / sr) >>> fig, ax = plt.subplots() >>> ax.set_title('PitchNCF') >>> fill_plot(times, fre_arr, axes=ax) >>> ax.set_ylim(0, 300)
Methods
cal_time_length
(data_length)Calculate the length of a frame from audio data.
pitch
(data_arr)Compute pitch
- cal_time_length(data_length)
Calculate the length of a frame from audio data.
fft_length = 2 ** radix2_exp
(data_length - fft_length) / slide_length + 1
- Parameters
- data_length: int
The length of the data to be calculated.
- Returns
- out: int
- pitch(data_arr)
Compute pitch
- Parameters
- data_arr: np.ndarray [shape=(…, n)]
Input audio array
- Returns
- fre_arr: np.ndarray [shape=(…, time)]
- class audioflux.PitchPEF(samplate=32000, low_fre=32.0, high_fre=2000.0, cut_fre=4000.0, radix2_exp=12, slide_length=1024, window_type=WindowType.HAMM, alpha=10.0, beta=0.5, gamma=1.8)
Pitch PEF algorithm
- Parameters
- samplate: int
Sampling rate of the incoming audio.
- low_fre: float
Lowest frequency. Default is 32.0.
- high_fre: float
Highest frequency. Default is 2000.0.
- cut_fre: float
Cut frequency. Default is 4000.0, and must be greater than high_fre.
- radix2_exp: int
fft_length=2**radix2_exp
- slide_length: int
Window sliding length.
- window_type: WindowType
Window type for each frame.
See:
type.WindowType
- alpha: float, > 0
alpha. Default if 10.0..
- beta: float, 0~1
beta. Default if 0.5..
- gamma: float, > 1
gamma. Default if 1.8.
Examples
Read 220Hz audio data
>>> import audioflux as af >>> audio_path = af.utils.sample_path('220') >>> audio_arr, sr = af.read(audio_path)
Extract pitch
>>> pitch_obj = af.PitchPEF(samplate=sr) >>> fre_arr = pitch_obj.pitch(audio_arr)
Show pitch plot
>>> import matplotlib.pyplot as plt >>> from audioflux.display import fill_plot >>> times = np.arange(fre_arr.shape[-1]) * (pitch_obj.slide_length / sr) >>> fig, ax = plt.subplots() >>> ax.set_title('PitchPEF') >>> fill_plot(times, fre_arr, axes=ax) >>> ax.set_ylim(0, 300)
Methods
cal_time_length
(data_length)Calculate the length of a frame from audio data.
pitch
(data_arr)Compute pitch
set_filter_params
(alpha, beta, gamma)Set filter params
- cal_time_length(data_length)
Calculate the length of a frame from audio data.
fft_length = 2 ** radix2_exp
(data_length - fft_length) // slide_length + 1
- Parameters
- data_length: int
The length of the data to be calculated.
- Returns
- out: int
- set_filter_params(alpha, beta, gamma)
Set filter params
- Parameters
- alpha: float
alpha
- beta: float
beta
- gamma: float
gamma
- pitch(data_arr)
Compute pitch
- Parameters
- data_arr: np.ndarray [shape=(…, n)]
Input audio array
- Returns
- fre_arr: np.ndarray [shape=(…, time)]
- class audioflux.PitchSTFT(samplate=32000, low_fre=32.0, high_fre=2000.0, radix2_exp=12, slide_length=1024, window_type=WindowType.HAMM)
Pitch STFT algorithm
- Parameters
- samplate: int
Sampling rate of the incoming audio.
- low_fre: float
Lowest frequency. Default is 32.0.
- high_fre: float
Highest frequency. Default is 2000.0.
- radix2_exp: int
fft_length=2**radix2_exp
- slide_length: int
Window sliding length.
- window_type: WindowType
Window type for each frame.
See:
type.WindowType
Examples
Read 220Hz audio data
>>> import audioflux as af >>> audio_path = af.utils.sample_path('220') >>> audio_arr, sr = af.read(audio_path)
Extract pitch
>>> pitch_obj = af.PitchSTFT(samplate=sr) >>> fre_arr, db_arr = pitch_obj.pitch(audio_arr)
Show pitch plot
>>> import matplotlib.pyplot as plt >>> from audioflux.display import fill_plot >>> times = np.arange(fre_arr.shape[-1]) * (pitch_obj.slide_length / sr) >>> fig, ax = plt.subplots() >>> ax.set_title('PitchSTFT') >>> fill_plot(times, fre_arr, axes=ax) >>> ax.set_ylim(0, 300)
Methods
cal_time_length
(data_length)Calculate the length of a frame from audio data.
pitch
(data_arr)Compute pitch
- cal_time_length(data_length)
Calculate the length of a frame from audio data.
fft_length = 2 ** radix2_exp
(data_length - fft_length) // slide_length + 1
- Parameters
- data_length: int
The length of the data to be calculated.
- Returns
- out: int
- pitch(data_arr)
Compute pitch
- Parameters
- data_arr: np.ndarray [shape=(…, n)]
Input audio array
- Returns
- fre_arr: np.ndarray [shape=(…, time)]
- db_arr: np.ndarray [shape=(…, time)]
- class audioflux.PitchYIN(samplate=32000, low_fre=27.0, high_fre=2000.0, radix2_exp=12, slide_length=1024, auto_length=2048)
Pitch YIN algorithm
- Parameters
- samplate: int
Sampling rate of the incoming audio.
- low_fre: float
Lowest frequency. Default is 27.0.
- high_fre: float
Highest frequency. Default is 2000.0.
- radix2_exp: int
fft_length=2**radix2_exp
- slide_length: int
Window sliding length.
- auto_length: int
Auto correlation length. Default is 2048.
Examples
Read 220Hz audio data
>>> import audioflux as af >>> audio_path = af.utils.sample_path('220') >>> audio_arr, sr = af.read(audio_path)
Extract pitch
>>> pitch_obj = af.PitchYIN(samplate=sr) >>> fre_arr, v1_arr, v2_arr = pitch_obj.pitch(audio_arr)
Show pitch plot
>>> import matplotlib.pyplot as plt >>> from audioflux.display import fill_plot >>> times = np.arange(fre_arr.shape[-1]) * (pitch_obj.slide_length / sr) >>> fig, ax = plt.subplots() >>> ax.set_title('PitchYIN') >>> fill_plot(times, fre_arr, axes=ax) >>> ax.set_ylim(0, 300)
Methods
cal_time_length
(data_length)Calculate the length of a frame from audio data.
pitch
(data_arr)Compute pitch
set_thresh
(thresh)Set thresh
- set_thresh(thresh)
Set thresh
- Parameters
- thresh: float
- cal_time_length(data_length)
Calculate the length of a frame from audio data.
fft_length = 2 ** radix2_exp
(data_length - fft_length) // slide_length + 1
- Parameters
- data_length: int
The length of the data to be calculated.
- Returns
- out: int
- pitch(data_arr)
Compute pitch
- Parameters
- data_arr: np.ndarray [shape=(…, n)]
Input audio array
- Returns
- fre_arr: np.ndarray [shape=(…, time)]
- value1_arr: np.ndarray [shape=(…, time)]
- value2_arr: np.ndarray [shape=(…, time)]