music.fraction_of

music.fraction_of(freq, sample_rate=44100)[source]

A frequency in Hertz, as the fraction of the sample rate a design wants.

Parameters:
freqscalar

The frequency in Hertz.

sample_rateinteger

The sample rate the filter will run at.

Returns:
float

freq / sample_rate, which is in (0, 0.5) for any frequency below the Nyquist limit.

Raises:
ValueError

If freq is not positive.

Parameters:
Return type:

float

Examples

>>> fraction_of(4410, sample_rate=44100)
0.1
>>> a, b = low_pass(fraction_of(1000))