Methods (libsoni.core.methods)
- libsoni.core.methods.generate_click(pitch: int = 69, amplitude: float = 1.0, tuning_frequency: float = 440.0, click_fading_duration: float = 0.2, fs: int = 22050) ndarray [source]
Generates a click signal.
- Parameters:
pitch (int, default = 69) – Pitch for colored click.
amplitude (float, default = 1.0) – Amplitude of click signal.
click_fading_duration (float, default = 0.2) – Fading duration of click signal, in seconds.
tuning_frequency (float, default = 440.0) – Tuning frequency, in Hertz.
fs (int, default = 22050) – Sampling rate, in samples per seconds.
- Returns:
click (np.ndarray (np.float32) [shape=(M, )]) – Generated click signal.
- libsoni.core.methods.generate_shepard_tone(pitch_class: int = 0, pitch_range: Tuple[int, int] = (20, 108), filter: bool = False, f_center: float = 440.0, octave_cutoff: int = 1, gain: float = 1.0, duration: float = 1.0, tuning_frequency: float = 440, fading_duration: float = 0.05, fs: int = 22050) ndarray [source]
Generates shepard tone.
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:
pitch_class (int, default: 0) – Pitch class for shepard tone.
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.
gain (float, default: 1.0) – Gain of shepard tone.
duration (float, default: 1.0) – Determines duration of shepard tone, in seconds.
tuning_frequency (float, default: 440.0) – Tuning frequency, in Hertz.
fading_duration (float, default: 0.01) – Determines duration of fade-in and fade-out, in seconds.
fs (int, default = 22050) – Sampling rate, in samples per seconds.
- Returns:
shepard_tone (np.ndarray (np.float32) [shape=(M, )]) – Generated shepard tone.
- libsoni.core.methods.generate_sinusoid(frequency: float = 440.0, phase: float = 0.0, amplitude: float = 1.0, duration: float = 1.0, fading_duration: float = 0.01, fs: int = 22050) ndarray [source]
Generates sinusoid.
- Parameters:
frequency (float, default: 440.0) – Frequency of sinusoid, in Hertz.
phase (float, default: 0.0) – Phase of sinusoid.
amplitude (float, default: 1.0) – Amplitude of sinusoid.
duration (float, default: 1.0) – Duration of generated signal, in seconds.
fading_duration (float, default: 0.01) – Determines duration of fade-in and fade-out, in seconds.
fs (int, default = 22050) – Sampling rate, in samples per seconds.
- Returns:
sinusoid (np.ndarray (np.float32) [shape=(M, )]) – Generated sinusoid.
- libsoni.core.methods.generate_tone_additive_synthesis(pitch: int = 69, partials: ndarray = array([1]), partials_amplitudes: ndarray | None = None, partials_phase_offsets: ndarray | None = None, gain: float = 1.0, duration: float = 1.0, tuning_frequency: float = 440, fading_duration: float = 0.05, fs: int = 22050) ndarray [source]
Generates tone signal using additive synthesis.
The sound can be customized using parameters partials, partials_amplitudes and partials_phase_offsets.
- Parameters:
pitch (int, default = 69) – Pitch of the generated tone.
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. When not defined, 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.
gain (float, default = 1.0) – Gain of generated tone.
duration (float, default: 1.0) – Determines duration of shepard tone, given in seconds.
tuning_frequency (float, default: 440.0) – Tuning frequency, in Hertz.
fading_duration (float, default: 0.01) – Determines duration of fade-in and fade-out, given in seconds.
fs (int, default = 22050) – Sampling rate, in samples per seconds.
- Returns:
generated_tone (np.ndarray (np.float32 / np.float64) [shape=(M, )]) – Generated tone signal.
- libsoni.core.methods.generate_tone_fm_synthesis(pitch: int = 69, modulation_rate_relative: float = 0.0, modulation_amplitude: float = 0.0, gain: float = 1.0, duration: float = 1.0, tuning_frequency: float = 440.0, fading_duration: float = 0.05, fs: int = 22050) ndarray [source]
Generates tone signal using frequency modulation synthesis.
The sound can be customized using parameters modulation_rate_relative and modulation_amplitude.
- Parameters:
pitch (int, default = 69) – Pitch of the synthesized tone.
modulation_rate_relative (float, default = 0.0) – Determines the modulation frequency as multiple or fraction of the frequency for the given pitch.
modulation_amplitude (float, default = 0.0) – Determines the amount of modulation in the generated signal.
gain (float, default = 1.0) – Gain for generated signal
duration (float, default: 1.0) – Determines duration of shepard tone, given in seconds.
tuning_frequency (float, default: 440.0) – Tuning frequency, in Hertz.
fading_duration (float, default: 0.01) – Determines duration of fade-in and fade-out, given in seconds.
fs (int, default = 22050) – Sampling rate, in samples per seconds.
- Returns:
generated_tone (np.ndarray (np.float32 / np.float64) [shape=(M, )]) – Generated tone signal.
- libsoni.core.methods.generate_tone_instantaneous_phase(frequency_vector: ndarray, gain_vector: ndarray | None = None, partials: ndarray = array([1]), partials_amplitudes: ndarray | None = None, partials_phase_offsets: ndarray | None = None, fading_duration: float = 0.05, fs: int = 22050) ndarray [source]
Generates signal out of instantaneous frequency.
The sound can be customized using parameters partials, partials_amplitudes and partials_phase_offsets.
- Parameters:
frequency_vector (np.ndarray (np.float32 / np.float64) [shape=(N, )]) – Array containing sample-wise instantaneous frequencies.
gain_vector (np.ndarray (np.float32 / np.float64) [shape=(N, )], default = None) – Array containing sample-wise gains.
partials (np.ndarray (np.float32 / np.float64) [shape=(N, )], default = [1]) –
- An array containing the desired partials of the fundamental frequencies for sonification.
An array [1] leads to sonification with only the fundamental frequency core, while an array [1,2] causes sonification with the fundamental frequency and twice the fundamental frequency.
partials_amplitudes (np.ndarray (np.float32 / np.float64) [shape=(N, )], default = [1]) –
- Array containing the amplitudes for partials.
An array [1,0.5] causes the sinusoid with frequency core to have amplitude 1, while the sinusoid with frequency 2*core has amplitude 0.5.
partials_phase_offsets (np.ndarray (np.float32 / np.float64) [shape=(N, )], default = [0]) – Array containing the phase offsets for partials.
fading_duration (float, default: 0.01) – Determines duration of fade-in and fade-out, given in seconds.
fs (int, default = 22050) – Sampling rate, in samples per seconds.
- Returns:
generated_tone (np.ndarray (np.float32 / np.float64) [shape=(M, )]) – Generated signal
- libsoni.core.methods.generate_tone_wavetable(pitch: int = 69, wavetable: ndarray | None = None, gain: float = 1.0, duration: float = 1.0, tuning_frequency: float = 440.0, fading_duration: float = 0.05, fs: int = 22050) ndarray [source]
Generates tone using wavetable synthesis.
The sound depends on the given wavetable.
- Parameters:
pitch (int, default = 69) – Pitch of the synthesized tone.
wavetable (np.ndarray (np.float32 / np.float64) [shape=(N, )], default = None) – Wavetable to be resampled.
gain (float, default = 1.0) – Gain for generated signal
duration (float, default: 1.0) – Determines duration of tone, given in seconds.
tuning_frequency (float, default: 440.0) – Tuning frequency, in Hertz.
fading_duration (float, default: 0.01) – Determines duration of fade-in and fade-out, in seconds.
fs (int, default = 22050) – Sampling rate, in samples per seconds.
- Returns:
generated_tone (np.ndarray (np.float32 / np.float64) [shape=(M, )]) – Generated signal