music.trill¶
- music.trill(freqs=(440, 493.8833012561241), notes_per_second=17, duration=5, sample_rate=None, number_of_samples=None)[source]¶
A trill: notes alternating fast, one after another.
The notes cycle through freqs, notes_per_second of them a second, each a triangle wave under
adsr()’s envelope with a 10 ms release, so that the joins do not click. It is a small example of a figure built from the routines here; one with other envelopes, a vibrato or a tremolo is written the same way.- Parameters:
- freqsiterable
ofscalars Frequencies to the iterated.
- notes_per_secondscalar
The number of notes per second. It may be one or fewer, for notes of a second or longer.
- durationscalar
The maximum duration of the trill in seconds.
- sample_rate
integerorNone The sample rate. Each note is shaped by
adsr()with its default attack, decay and sustain and a 10 ms release, all timed at this rate. None, the default, is the ratemusic.get_sample_rate()returns.- number_of_samples
integerorNone The maximum number of samples, taken instead of duration when given.
- freqsiterable
- Returns:
- s
ndarray The PCM samples of the resulting sound.
- s
- Raises:
ValueErrorIf
notes_per_secondis not positive, or is abovesample_rate. Each note of the trill lastssample_rate / notes_per_secondsamples, so a rate of zero divided, and one above the sample rate left notes shorter than a sample.
See also
note_with_vibratoA note with vibrato.
note_with_vibratos_glissandosa note with an arbitrary sequence of pitch transition and a meta-vibrato.
tremoloA tremolo envelope.
Notes
Cite the following article whenever you use this function.
References
[1]Fabbri, Renato, et al. “Musical elements in the discrete-time representation of sound.” arXiv preprint arXiv:abs/1412.6853 (2017)
Examples
>>> write_wav_mono(trill())