Repository navigation
music 1.9.0
pip install -U musicTutorial · API reference · Changelog
Note for anyone upgrading
This one changes what some calls return. Nothing is removed or
renamed and no import breaks.
Angles. localize and localize2 read theta=0 as "no angle given"
and placed the source at x and y. Zero is now an angle: the right
ear's side for localize, straight ahead for localize2. None means
no angle, and is localize's new default; localize2 keeps its default
of -70, so a caller who passed theta=0 to give a position now passes
theta=None.
Rates. amplitude_modulation at a zero rate returns the carrier at
full level, where it scaled it by the modulator table's first entry:
by half, for the default sine at full depth. frequency_modulation at a
zero rate holds the carrier's pitch. A negative modulation rate, a
pulse_rate that is not positive, and a trill of more notes a second
than the sample rate raise ValueError.
Renders. The far ear in localize_linear and spatial_motion is
silent until the sound reaches it, which changes its first samples for a
sound that does not start at zero. localize2(method="brute") returns
each partial in phase, and an output shorter by some thirty samples.
reverb at a rate other than 44.1 kHz has a tail spanning the whole band.
pan_transitions given a sound returns it panned, where it returned the
sound with the envelopes added to it, and louds given sample counts
uses the deviations it was given. Each repeat stretches makes is exactly
as long as its duration, where it could fall short.
Fixed
-
A zero angle is an angle.
localize(theta=0, distance=1)placed the
source at the defaultxandyrather than on the right ear's side,
andlocalize2(theta=0)put a source meant to be straight ahead far to
one side.Nonenow leaves the angle out. -
isochronic_tonesrequires a positivepulse_rate. At zero a
ramp divided by the pulse period and raisedZeroDivisionError; a
negative rate ran the gate backwards, so each period began silent. -
amplitude_modulationandfrequency_modulationrefuse a negative
rate.modulated_noisealready did: for an asymmetric modulator
table it is a different modulation, not the same one reversed. -
A zero modulation rate leaves the carrier unmodulated. It did in
modulated_noise, butamplitude_modulationheld its modulator at the
table's first entry and scaled the carrier by it (by half, for the
default sine at full depth), andfrequency_modulationshifted its
pitch the same way for a table that does not start at zero. -
spatial_motionrefuses a sound that is not mono. Its message
says so, where it used to be one about broadcasting, and a zero
duration no longer renders two seconds of tone before returning
nothing. -
The far ear hears nothing before the sound reaches it. The
fractional delay behindlocalize_linearandspatial_motionread the
first sample for every position before the start, so the far ear held
it for the whole interaural delay: a click at the start arrived as a
plateau some 27 samples long. Outside the signal it now reads silence,
aslocalizepads. -
A source on an ear is heard by that ear alone. At zero distance the
intensity ratio was 0 / 0, andlocalize_linearandspatial_motion
returned NaN for that channel. Its limit, whichlocalizealready
renders, is the near ear in full and the far one silent. -
localize2's brute-force method resynthesizes each partial in
phase. The FFT's angles are a cosine's and it read a sine table, so
every partial came back a quarter cycle early: a sine as minus a
cosine, and a sound of several partials as a different waveform. Its
output is now longer than the input by the largest interaural delay,
rather than by some thirty samples more. -
localizeaccepts a list, as documented. It raisedTypeError
when scaling one by the intensity ratio. -
The localization routines render their default sound at the rate
asked for. Called without a sound,localize,localize_linearand
localize2rendered the default note at 44.1 kHz whatever
sample_ratewas: at 8 kHz, eleven seconds of it at 40 Hz. -
pan_transitionspans the sound it is given. It mixed the
envelopes into it rather than scaling it by them, so the sound came
back unpanned under full-scale ramps, and panning silence returned the
envelopes themselves. The result now has the sound's length, holding
the final position past the end of the transitions, and each leg is a
whole number of samples as other durations are. -
loudsgiven sample counts uses the deviations it was given. That
branch passed its arguments by position one place over, so each
alphabecame a deviation in decibels andtrans_devswas never
read: a 6 dB rise came out as 1 dB. A transition with no samples is
refused by name, where both branches failed on its missing last value. -
reverbhandles a response that is all first period, or one sample
long. The first failed with a broadcast error, becausenoisereads
zero samples as "not given"; the second divided 0 / 0. A duration of
less than a sample is refused by name. -
trillrefuses notes shorter than a sample. They rounded to zero
samples, whichnotealso reads as "not given": a millisecond at
50,000 notes a second came back as twelve seconds. -
localize2answers an empty sound with an empty stereo array. The
other localizers already did; its FFT refused zero points. -
singnames a note outside the range it can write. That range is
MIDI 12 to 96, and it raised a bareKeyError. It also accepts
effect="flite"for the voice it loads, keeping"flint". -
stretchesmakes each repeat as long as its duration. Positions
that rounded to one past the fragment's end were dropped rather than
held, so a repeat fell short by half a fragment sample's worth of
output: ten samples stretched to twelve seconds lost 26,460. An empty
fragment gives an empty result rather thanZeroDivisionError. -
Sequencer.add_noterefuses a note that starts before zero.
Rendering placed it at a negative offset and failed with a broadcast
error. -
convert_to_stereoduplicates a single channel written as one row.
It returned the row unchanged, one channel from a routine promising
two. -
reverb's tail spans the band at any rate. It askednoisefor a
band up to half its own rate without passing the rate, so the band was
built at 44.1 kHz: at 8 kHz the tail held 95% of its energy below
680 Hz rather than near 4 kHz.
Tests
- The stimulus generators have a mutation audit. The new
stimuli
area measures carriers at 8 kHz, the amplitude envelope, the isochronic
gate and ramp sample by sample, the band and rate of modulated noise,
the direction of a frequency sweep, the orbit's azimuth through several
cycles, and every routine's declared defaults. - The localization filters have a mutation audit. The new
localizationarea checks each routine's delays and gains against
geometry computed independently: the far ear of a ramp, exact tones
through bothlocalize2methods either side of the 4 kHz crossover,
the fractional delay on a parabola, and the energybrutekeeps.
Documentation
singhas a docstring, as do the helpers that write its score. It
was the one public routine that raised without saying so.- Only
localize2measures an angle from straight ahead, andhrir
andspatial_motionno longer say that every routine measures from
the ear axis. localize2says how it measures an angle. From straight ahead and
positive to the left, wherelocalizeand the other routines measure
from the ear axis; and it has no distance, which its docstring used to
ask for.localizestates the speed of sound it uses (331.3 m/s at
0 °C, not 331.2) and a diffraction delay of 0.7 ms rather than 0.7 s,
andlocalize_hrtfno longer claims to use itssample_rate.
Maintenance
- An entry without a headline stops the release. The Zenodo record
summarises a release by each changelog entry's bold headline, and
silently left out the entries without one: four of eight at 1.8.1.
The release gate refuses them,tools/zenodo_sync.pyrefuses to send
such a summary, and a test checks the newest section on every push. A
headline whose bold ends at a comma is carried to the end of its
sentence, rather than shown cut off there. - The subject check tries a vocabulary service three times. GEMET
failed now and then and answered a moment later, and twice that
stopped a release gate that had passed everything else. A 4xx is
still an answer, and is not retried.
Maintained in the open since 2016. If music is useful to you or your institution, consider sponsoring its development; commissioned features and sponsored development are available too.