music.bandlimited_note

music.bandlimited_note(freq=220.0, duration=2.0, waveform='sine', number_of_samples=None, sample_rate=None, table_size=16384, rolloff_hz=0.0)[source]

Render a static-pitch periodic note with prefiltered harmonics.

Parameters:
freqfloat

Positive fundamental in Hz, strictly below Nyquist.

durationfloat

Seconds, ignored when number_of_samples is given.

waveform{‘sine’, ‘sawtooth’, ‘square’, ‘triangle’}

A primary waveform. Arbitrary arrays are not accepted because their spectrum and source-pitch semantics are unknown.

number_of_samplesint or None

Overrides duration when given, matching music.note; zero is no samples.

sample_rateint or None

Samples per second. None, the default, is the rate music.get_sample_rate() returns.

table_sizeint

Resolution of the periodic prefiltered table: a whole number, at least 4.

rolloff_hzfloat

Optional nonnegative linear transition width below Nyquist. The default zero keeps all allowed harmonics. A smooth rolloff avoids sudden harmonic changes between adjacent static pitches.

Returns:
ndarray

One-dimensional float64 samples. The method preserves the periodic waveform’s fundamental, not its original peak level; truncated discontinuous waves may exhibit Gibbs overshoot.

Raises:
ValueError

For invalid sampling parameters, frequency, duration, table size, or waveform name.

Parameters:
  • freq (float)

  • duration (float)

  • waveform (str)

  • number_of_samples (int | None)

  • sample_rate (int | None)

  • table_size (int)

  • rolloff_hz (float)

Return type:

NDArray[float64]

Notes

This is opt-in: music.note remains sample-identical to MASS. Band-limiting is frequency-dependent. Do not reuse one filtered table for glissandi or FM. Hard-gated isochronic envelopes, clipping, nonlinear effects and subsequent resampling can still introduce aliasing. Inspect downstream output separately.

Examples

>>> x = bandlimited_note(10000, duration=0.01, waveform="sawtooth")
>>> x.shape
(441,)