Chroma Features (synctoolbox.feature.chroma)¶
- synctoolbox.feature.chroma.pitch_to_CENS(f_pitch: ndarray, input_feature_rate: float, win_len_smooth: int = 0, downsamp_smooth: int = 1, quant_steps: ndarray = np.array([40, 20, 10, 5]) / 100, quant_weights: ndarray = np.array([1, 1, 1, 1]) / 4, norm_thresh: float = 0.001, midi_min: int = 21, midi_max: int = 108) Tuple[ndarray, float] [source]¶
Generate CENS features from pitch features (CENS: Chroma Energy Normalized Statistics).
The following is computed:
Energy for each chroma band
l1-normalization of the chroma vectors
Local statistics:
Component-wise quantization of the normalized chroma vectors
Smoothing and downsampling of the feature sequence
l2-normalization of the resulting vectors
Individual steps of this procedure can be computed with the remaining functions in this module.
- Parameters
f_pitch (np.ndarray [shape=(128, N)]) – MIDI pitch-based feature representation, obtained e.g. through
audio_to_pitch_features
.input_feature_rate (float) – Feature rate of the input pitch features
f_pitch
win_len_smooth (int) – Smoothing window length, default: no smoothing
downsamp_smooth (int) – Downsampling factor, default: no downsampling
quant_steps (np.ndarray) – After l1-normalization, all entries are quantized into bins defined by these boundaries. The default values correspond to the standard definition of CENS features.
quant_weights (np.ndarray) – The individual quantization bins can be given weights. Default is equal weight for all bins.
norm_thresh (float) – For l1-normalization, chroma entries below this threshold are considered as noise and set to 0. For l2-normalization, chroma vectors with norm below this threshold are replaced with uniform vectors.
midi_min (int) – Minimum MIDI pitch index to consider (default: 21)
midi_max (int) – Maximum MIDI pitch index to consider (default: 108)
- Returns
f_CENS (np.ndarray) – CENS (Chroma Energy Normalized Statistics) features
CENS_feature_rate (float) – Feature rate of the CENS features
- synctoolbox.feature.chroma.pitch_to_chroma(f_pitch: ndarray, midi_min: int = 21, midi_max: int = 108) ndarray [source]¶
Aggregate pitch-based features into chroma bands.
- Parameters
f_pitch (np.ndarray [shape=(128, N)]) – MIDI pitch-based feature representation, obtained e.g. through
audio_to_pitch_features
.midi_min (int) – Minimum MIDI pitch index to consider (default: 21)
midi_max (int) – Maximum MIDI pitch index to consider (default: 108)
- Returns
f_chroma (np.ndarray [shape=(12, N)]) – Rows of ‘f_pitch’ between
midi_min
andmidi_max
, aggregated into chroma bands.
- synctoolbox.feature.chroma.quantize_chroma(f_chroma, quant_steps: ndarray = np.array([40, 20, 10, 5]) / 100, quant_weights: ndarray = np.array([1, 1, 1, 1]) / 4, norm_thresh: float = 0.001) ndarray [source]¶
Computes thresholded l1-normalization of the chroma vectors and then applies component-wise quantization of the normalized chroma vectors.
- Parameters
f_chroma (np.ndarray [shape=(12, N)]) – Chroma representation
quant_steps (np.ndarray) – After l1-normalization, all entries are quantized into bins defined by these boundaries. The default values correspond to the standard definition of CENS features.
quant_weights (np.ndarray) – The individual quantization bins can be given weights. Default is equal weight for all bins.
norm_thresh (float) – For l1-normalization, chroma entries below this threshold are considered as noise and set to 0.
- Returns
f_chroma_quantized (np.ndarray [shape=(12, N)]) – Quantized chroma representation
- synctoolbox.feature.chroma.quantized_chroma_to_CENS(f_chroma_quantized: ndarray, win_len_smooth: int, downsamp_smooth: int, input_feature_rate: float, norm_thresh: float = 0.001)[source]¶
Smooths, downsamples, and normalizes a chroma sequence obtained e.g. through
quantize_chroma
.- Parameters
f_chroma_quantized (np.ndarray [shape=(12, N)]) – Quantized chroma representation
win_len_smooth (int) – Smoothing window length. Setting this to 0 applies no smoothing.
downsamp_smooth (int) – Downsampling factor. Setting this to 1 applies no downsampling.
input_feature_rate (float) – Feature rate of
f_chroma_quantized
norm_thresh (float) – For the final l2-normalization, chroma vectors with norm below this threshold are replaced with uniform vectors.
- Returns
f_CENS (np.ndarray) – CENS (Chroma Energy Normalized Statistics) features
CENS_feature_rate (float) – Feature rate of the CENS features