Mx.Signal (mx v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

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

A level in dB for a magnitude.

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.

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

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

The frequency of a note number.

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

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

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.

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

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.

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

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

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

Functions

bands()

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

db(magnitude)

A level in dB for a magnitude.

fade(times, track, above)

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(freq, cutoff)

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(samples, rate, hz)

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

hz(note)

The frequency of a note number.

low_pass(samples, rate, hz)

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

magnitude_at(spectrum, position)

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

measure_file(path, what, measure)

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(values)

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

onsets(samples, rate, gap)

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(spectrum, peak)

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

slope(points)

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

spectrum(sound, from, size)

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