music.note_with_glissando

music.note_with_glissando(start_freq=220, end_freq=440, duration=2, alpha=1, waveform_table=array([0., 0.0003835, 0.00076699, ..., -0.00115049, -0.00076699, -0.0003835], shape=(16384,)), method='exp', number_of_samples=0, sample_rate=44100)[source]

A note with a pitch transition: a glissando.

Parameters:
start_freqscalar

The starting frequency.

end_freqscalar

The final frequency.

durationscalar

The duration of the sound in seconds.

alphascalar

An index to begin the transition faster or slower. If alpha != 1, the transition is not of linear pitch.

waveform_tablearray_like

The table with the waveform to synthesize the sound.

methodstr

“exp” for an exponential transition of frequency (linear pitch). “lin” for a linear transition of amplitude.

number_of_samplesinteger

The number of samples of the sound. If supplied, duration is not used.

sample_rateinteger

The sample rate.

Returns:
sndarray

A numpy array where each value is a PCM sample of the sound.

Raises:
ValueError

If an exponential glissando is asked to start or end at a frequency that is not positive. It sweeps by a constant ratio, and there is no ratio from zero: a start of zero divided, and a negative frequency raised to a fractional power gave NaN, which was then cast to an integer table index and read as a sound. A linear glissando has no such restriction.

Parameters:
  • start_freq (float)

  • end_freq (float)

  • duration (float)

  • alpha (float)

  • waveform_table (ArrayLike)

  • method (str)

  • number_of_samples (int)

  • sample_rate (int)

Return type:

NDArray[float64]

See also

note

A basic musical note without vibrato or pitch transition.

note_with_vibrato

A musical note with an oscillation of pitch.

tremolo

A tremolo, an oscillation of loudness.

loud

A transition of loudness.

fade

Fade in or out.

Examples

>>> write_wav_mono(note_with_glissando())  # writes file with a glissando
>>> s = horizontal_stack(
...     *[note_with_glissando(i, j) for i, j in zip([220, 440, 4000],
... [440, 220, 220])])
>>> write_wav_mono(s)  # writes a file with glissandi