Chroma (libsoni.core.chroma)

libsoni.core.chroma.sonify_chroma_vector(chroma_vector: ndarray, pitch_range: Tuple[int, int] = (20, 108), filter: bool = False, f_center: float = 440.0, octave_cutoff: int = 1, tuning_frequency: float = 440.0, fading_duration: float = 0.05, sonification_duration: int | None = None, normalize: bool = True, fs: int = 22050) ndarray[source]

Sonifies a chroma vector using sound synthesis based on shepard tones.

The sound can be changed either by the filter option or by the specified pitch-range. Both options can also be used in combination. Using the filter option shapes the spectrum like a bell curve centered around the center frequency, while the octave cutoff determines at which octave the amplitude of the corresponding sinusoid is 0.5.

Parameters:
  • chroma_vector (np.ndarray (np.float32 / np.float64) [shape=(N, 12)]) – Chroma vector to sonify.

  • pitch_range (Tuple[int, int], default = [20,108]) – Determines the pitches to encounter for shepard tones.

  • filter (bool, default: False) – Enables filtering of shepard tones.

  • f_center (float, default: 440.0) – Determines filter center frequency, in Hertz.

  • octave_cutoff (int, default: 1) – Determines the width of the filter.

  • tuning_frequency (float, default: 440.0) – Tuning frequency, in Hertz.

  • 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:

chroma_sonification (np.ndarray (np.float32 / np.float64) [shape=(M, )]) – Sonified chroma vector.

libsoni.core.chroma.sonify_chromagram(chromagram: ndarray, H: int = 0, pitch_range: Tuple[int, int] = (20, 108), filter: bool = False, f_center: float = 440.0, octave_cutoff: int = 1, tuning_frequency: float = 440.0, fading_duration: float = 0.05, sonification_duration: int | None = None, normalize: bool = True, fs: int = 22050) ndarray[source]

Sonifies a chromagram using sound synthesis based on shepard tones.

The sound can be changed either by the filter option or by the specified pitch-range. Both options can also be used in combination. Using the filter option shapes the spectrum like a bell curve centered around the center frequency, while the octave cutoff determines at which octave the amplitude of the corresponding sinusoid is 0.5.

Parameters:
  • chromagram (np.ndarray (np.float32 / np.float64) [shape=(N, 12)]) – Chromagram to sonify.

  • H (int, default = 0) – Hop size of STFT used to calculate chromagram.

  • pitch_range (Tuple[int, int], default = [20,108]) – Determines the pitch range to encounter for shepard tones.

  • filter (bool, default: False) – Enables filtering of shepard tones.

  • f_center (float, default: 440.0) – Determines filter center frequency, in Hertz.

  • octave_cutoff (int, default: 1) – Determines the width of the filter. For octave_cutoff of 1, the magnitude of the filter reaches 0.5 at half the center_frequency and twice the center_frequency.

  • tuning_frequency (float, default: 440.0) – Tuning frequency, in Hertz.

  • 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:

chroma_sonification (np.ndarray (np.float32 / np.float64) [shape=(M, )]) – Sonified chromagram.