# `Mx.Signal`
[🔗](https://github.com/mx-music/mx/blob/main/lib/mx/signal.ex#L1)

The pieces the measuring of plucked notes, held notes and hits share: filtering, spectra, finding where sounds start, and fitting a fade.

Levels are in dB, and a spectrum is a tuple of the magnitudes of its frequency bins.

# `bands`

The frequency bands measurements are given in, each a third of an octave or wider, as `{low, high}` in Hz.

# `db`

A level in dB for a magnitude.

# `fade`

The seconds a level takes to fade 60 dB, from a straight line through the levels above `above`, or nil when it does not fade.

# `filter_loss`

What the high-pass, run forward and backward, takes from a frequency, in dB: each run multiplies the amplitude by 1 / √(1 + (cutoff / freq)⁸).

# `high_pass`

A fourth-order Butterworth high-pass at `hz`, run forward and then backward so it shifts nothing in time.

# `hz`

The frequency of a note number.

# `low_pass`

A fourth-order Butterworth low-pass at `hz`, run forward and then backward so it shifts nothing in time.

# `magnitude_at`

The magnitude of a spectrum at a position between bins, by a straight line between the two bins around it.

# `measure_file`

Reads a recording and measures its samples and rate with `measure`, and returns `{:ok, found}`, or `{:error, message}` naming the file when it is refused or `measure` finds nothing.

# `median`

The middle value of a list of numbers, or the mean of the two middle ones.

# `onsets`

The sample each sound starts at: a 5 ms level within 30 dB of the loudest, and 20 dB above the quietest of the 40 before it, at least `gap` seconds after the start before it.

# `refine`

A peak's position between bins and its level in dB, from a parabola through the log magnitudes around it.

# `slope`

The slope of the straight line that best fits a list of `{x, y}` points.

# `spectrum`

The spectrum of `size` samples of a sound, given as a tuple, from the sample `from`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
