Skip to content

music 1.9.0

Choose a tag to compare

@ttm ttm released this 24 Sep 21:07
· 159 commits to master since this release
pip install -U music

Tutorial · 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 default x and y rather than on the right ear's side,
    and localize2(theta=0) put a source meant to be straight ahead far to
    one side. None now leaves the angle out.

  • isochronic_tones requires a positive pulse_rate. At zero a
    ramp divided by the pulse period and raised ZeroDivisionError; a
    negative rate ran the gate backwards, so each period began silent.

  • amplitude_modulation and frequency_modulation refuse a negative
    rate.
    modulated_noise already 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, but amplitude_modulation held its modulator at the
    table's first entry and scaled the carrier by it (by half, for the
    default sine at full depth), and frequency_modulation shifted its
    pitch the same way for a table that does not start at zero.

  • spatial_motion refuses 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 behind localize_linear and spatial_motion read 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,
    as localize pads.

  • A source on an ear is heard by that ear alone. At zero distance the
    intensity ratio was 0 / 0, and localize_linear and spatial_motion
    returned NaN for that channel. Its limit, which localize already
    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.

  • localize accepts a list, as documented. It raised TypeError
    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_linear and
    localize2 rendered the default note at 44.1 kHz whatever
    sample_rate was: at 8 kHz, eleven seconds of it at 40 Hz.

  • pan_transitions pans 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.

  • louds given sample counts uses the deviations it was given. That
    branch passed its arguments by position one place over, so each
    alpha became a deviation in decibels and trans_devs was 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.

  • reverb handles a response that is all first period, or one sample
    long.
    The first failed with a broadcast error, because noise reads
    zero samples as "not given"; the second divided 0 / 0. A duration of
    less than a sample is refused by name.

  • trill refuses notes shorter than a sample. They rounded to zero
    samples, which note also reads as "not given": a millisecond at
    50,000 notes a second came back as twelve seconds.

  • localize2 answers an empty sound with an empty stereo array. The
    other localizers already did; its FFT refused zero points.

  • sing names a note outside the range it can write. That range is
    MIDI 12 to 96, and it raised a bare KeyError. It also accepts
    effect="flite" for the voice it loads, keeping "flint".

  • stretches makes 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 than ZeroDivisionError.

  • Sequencer.add_note refuses a note that starts before zero.
    Rendering placed it at a negative offset and failed with a broadcast
    error.

  • convert_to_stereo duplicates 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 asked noise for 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
    localization area checks each routine's delays and gains against
    geometry computed independently: the far ear of a ramp, exact tones
    through both localize2 methods either side of the 4 kHz crossover,
    the fractional delay on a parabola, and the energy brute keeps.

Documentation

  • sing has a docstring, as do the helpers that write its score. It
    was the one public routine that raised without saying so.
  • Only localize2 measures an angle from straight ahead, and hrir
    and spatial_motion no longer say that every routine measures from
    the ear axis.
  • localize2 says how it measures an angle. From straight ahead and
    positive to the left, where localize and the other routines measure
    from the ear axis; and it has no distance, which its docstring used to
    ask for. localize states 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,
    and localize_hrtf no longer claims to use its sample_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.py refuses 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.