Skip to main content

Module notes

Module notes 

Source
Expand description

The note list that every layer reads, the transcriber, the f0 track and the MIDI files that produce and store it, and the harmonic masks built from it.

A note has an onset, an offset, a pitch and, once a pitch track has run, an f0 contour. Three more fields stay unset until a later step fills them: the octave flag, the velocity and the overlap flag. The transcriber and the MIDI reader both produce this type, and every later step consumes it.

The transcriber runs the model once per stem (Transcriber::run) and decodes that run with DecodeSettings, as many times as needed (ModelRun::decode). A Profile gives fixed settings per kind of stem; detect() derives them from the stem instead, from a probe decode and the PitchTrack, the stem’s f0 track, which also fills the note contours. drop_quiet drops notes that sound only far below the stem’s loudest passage. write_midi stores a list as a format 0 file, and finish() rewrites a list with the layer report into the final notes.mid.

Structs§

CleanupSteps
The note counts of the cleanup, one per step.
Contour
The f0 of a note over time, so masks follow bends and glides. Points are sorted by time; between two points the pitch moves linearly in log-frequency, and outside them it holds the end value.
ContourPoint
One point of an f0 contour.
DecodeSettings
Everything the decoder needs besides its thresholds, which keep their defaults: the pitch range, the minimum note length and the melodia pass. Pitch bends stay off, because the notes file writes none.
Detection
What the detection found and the settings it chose.
DropSpan
A pitch drop of the pitch layer.
FinalNote
One note of the final list, in ticks.
FinalNotes
The final note list.
FinishInput
What finish reads.
FrameMask
The masks of one frame: for each bin the note that claims it and whether a second note claims it too.
GlideSpan
A glide of the pitch layer.
MaskParams
Settings of the harmonic masks.
Masker
Builds the masks of a note list on the bins of an STFT layout.
MidiError
A MIDI file that cannot give a note list.
ModelRun
The posteriorgrams of one model run over a stem.
Note
One note: onset, offset, pitch, and the fields later steps fill.
NoteFacts
What the layer report says of one note of the list.
NoteList
The notes of a stem, sorted by onset.
OctaveCheck
What the octave check did.
PitchRange
A range of whole MIDI pitches the decoder may create, both ends kept, within the model’s range A0 to C8.
PitchTrack
The f0 track of a stem.
StemLevels
The stem’s level in QUIET_FRAME frames at its own rate, with a quarter-frame hop, frame m centred at m hops. The quiet-note guard, the attack split and the split join read the same frames.
TrackFrame
One frame of the track.
Transcriber
The transcription model with its inference engine, built once and used for every stem, and the f0 tracker of the notes step.
Transcription
Everything the notes step of a stem found.
TranscriptionRecord
The transcriber’s model and settings, as the transcription group of layers.json records them.
Velocity
A MIDI velocity from 1 to 127. Velocity 0 means a note-off in MIDI, so it is not a velocity.
VibratoSpan
A vibrato of the pitch layer.

Enums§

EndRule
Which rule set the end of a final note.
MidiWriteError
A note list that cannot become a MIDI file.
NoteError
A note or contour that breaks a rule.
NotesError
A notes step that failed.
Profile
A fixed set of decode settings for one kind of stem.
RangeError
A pitch range that the decoder cannot use.
RegisterSource
Where the register came from.
TrackError
An f0 track that could not be built.
TranscribeError
A model run or a decode that failed.
Velocities
Which velocity each note gets.
Voicing
Whether a part plays one note at a time or chords.

Constants§

ATTACK_AFTER
How far after a note’s onset its loudest frame may lie: frames centred from the onset to 50 ms after it, and not past its end. The attack split’s piece after a cut lasts at least this long.
ATTACK_BEFORE
How far before a note’s onset the quiet frames of its attack lie: frames centred from 75 ms before the onset to the onset, and not before the earlier note starts.
ATTACK_DIP
How far the stem’s level, with any DC offset removed, must dip below the loudest frame in the quiet frames of an attack.
BEND_MIN
A note of a mono line gets bends when its contour leaves its key by this much outside every route’s span, over the tracker’s reach.
BEND_RANGE
The bend range the file assumes; a host must set the synth to it, and render reads no bend.
BPM_TOLERANCE
How far a tempo in the file may lie from --bpm. A tempo is stored in whole microseconds per beat, which rounds 140 BPM to 140.00003.
CHORD_OVERLAP
How much of a note’s span another pitch class must share with it for the note to sound in a chord.
CHORD_SHARE
The share of probe notes that sound with another pitch class from which a part counts as chords. It sits midway between the highest line (0.56) and the lowest chord part (0.79) of the generated set.
COPY_SLACK
How far a note may reach past the note one octave below it and still lie inside it: two model frames.
DEFAULT_MIN_NOTE_FRAMES
The decoder’s default minimum length in frames, 127.7 ms. A kept note lasts at least one frame more, 139.3 ms.
DEFAULT_VELOCITY
The velocity that the notes command passes to Velocities::Constant.
DROP_SLACK
A pitch drop takes in the notes that start from this long before its onset until it settles.
DRUM_CHANNEL
The General MIDI percussion channel, channel 10, counted from 0. Its keys name drums, not pitches.
FUNDAMENTAL_DIP
How far the level at the note’s fundamental alone must dip across a cut of the attack split.
GLIDE_OVERLAP
A glide join overlaps the two notes by at least this long, rounded up to whole ticks.
GLIDE_SLACK
A glide joins two notes when the later onset lies this close to the glide’s motion, from its start to its end.
HARMONICS
The harmonics of a note that StemLevels::harmonic_level sums.
HARMONIC_DIP
How far the level at the note’s own harmonics must dip in the same frames.
HIGHEST_MODEL_PITCH
The highest pitch the model can give, C8.
HOLD_BEFORE
How long the stem must hold above the first share of HOLD_SPAN before it last fell below the second share ahead of a rise.
HOLD_RATIO
How many times longer than its dip the stem must hold before it.
HOLD_SEARCH
How far back from the start of a rise the hold may end.
HOLD_SPAN
The share of the loudest reading the hold must stay above, and the share at which it ends.
HOLD_WINDOW
How far below the reference level a probe note’s median frame may lie and still count as a hold candidate. Half the register window, so bleed near -20 dB in a rest does not widen the range.
LOWEST_MODEL_PITCH
The lowest pitch the model can give, A0.
MIN_NOTE_LENGTH
The shortest note the file holds. A shorter note is lengthened to it, and to at least one tick.
MODEL_RATE
The input rate of the model.
MODEL_SHA256
SHA-256 of the official nmp.onnx (the bundled MODEL_ONNX), as a lowercase hex string.
NO_KNEE_CUT
A note without a note-off knee ends this long before its end in the list.
OCTAVE_AGREEMENT
How far a note may lie from the f0 track’s median and still agree.
OCTAVE_FIX_CEILING
The f0 median, A2 (110 Hz), at or below which, within OCTAVE_TOLERANCE, a note an octave above it moves down. The ghosts are measured there; above it a gap of an octave only sets the flag.
OCTAVE_MIN_FRAMES
The fewest voiced frames, 17 ms of track, that check a note.
OCTAVE_TOLERANCE
How close to an octave a gap must lie to count as one.
PAD_FALL
A pad note ends where its level falls this far below its plateau.
QUIET_FRAME
The length of a guard frame: 25 ms, short enough to follow a note.
QUIET_GATE
The gate of the guard: a frame is active within this many decibels of the loudest frame. It is the project’s active-frame gate.
REFERENCE_PERCENTILE
The percentile of the voiced frames’ levels that serves as the reference level. A short loud transient does not move it.
REGISTER_MARGIN
How far the range reaches beyond the register on each side.
REGISTER_PERCENTILES
The low and high percentiles of the voiced f0 frames that bound the register.
REGISTER_WINDOW
The register reads only voiced frames within this many decibels of the reference level, so quiet bleed in a rest cannot widen it.
RISE_LATEST
How far after the onset a rise may start: the decoder starts a note up to 15 ms before its attack.
RISE_READ
How many rise limits past RISE_LATEST the rise test reads.
RISE_SLACK
How much longer than a step read through the envelope window a rise may take: about the attack of a gate.
RISE_SPAN
The share of the loudest envelope reading a rise starts below, and the share it ends above.
RISE_STEP
The step between envelope readings of the rise test.
RISE_WINDOW
The shortest envelope window of the rise test; it spans one period of the note when that is longer.
SPLIT_GAP
The widest gap a split may leave: two model frames.
SPLIT_LOWEST
The lowest key whose notes split_at_attacks splits: A1, 55 Hz.
SPLIT_ONSET
The onset activation below which a note that starts where a note of the same key ends joins it.
TICKS_PER_BEAT
The resolution of the file in ticks per quarter note.
TRACK_FMAX
The highest f0 the track looks for, just above C8 (4186 Hz), the top of the transcription model. A lower ceiling reads every tone above it as a subharmonic.
TRACK_FMIN
The lowest f0 the track looks for, below B0 (30.87 Hz).
TRACK_FRAME
Samples per analysis frame at the model rate.
TRACK_HOP
Samples between frames at the model rate.
TRANSCRIBER_VERSION
The version of the transcription crate, pinned in Cargo.toml.
VELOCITY_LAW_DB
The level law: a note d dB under the loudest gets velocity 127 * 10^(-d / 40).

Traits§

Backend
An engine able to run the Basic Pitch network on one window of audio.

Functions§

check_octaves
Checks every note against the median of the voiced f0 frames inside it, and returns the notes with their octave flag set.
clean_up
Cleans decoded notes in five steps, and counts the notes after each.
detect
Detects the register and voicing of a stem from its model run and its f0 track, and builds the settings for the final decode.
detect_with_window
detect with another level window for the f0 register, for the evaluation of the window.
drop_quiet
Drops every note whose span holds no active frame of the stem, and returns the kept notes with the count of dropped ones.
drop_quiet_with
Drops the notes as drop_quiet does, over levels already measured.
finish
Rewrites the note list with the layer report.
join_splits
Joins the pieces of a held note that the decoder split, on the onset rule alone: join_splits_with with a stem of silence, which never gives an attack.
join_splits_with
Joins the pieces of a held note that the decoder split.
merge_overlaps
Merges every pair of notes of one key that sound at the same time into one note from the earlier onset to the later offset.
midi_track_name
Returns the first track name of a Standard MIDI File, or None when the bytes do not parse or the file names no track.
min_note_frames
The minimum note length for a BPM, in model frames.
min_note_length
The minimum note length for a BPM: min_note_frames model frames, the length the decoder drops a note at.
out_of_mask_fraction
Returns the share of the signal’s power that lies outside every mask.
probe_settings
The settings of the probe decode: the whole model range, the minimum length from the BPM and the melodia pass.
read_midi
Reads the notes of a MIDI file at path, checking its tempo against bpm.
read_midi_bytes
Reads the notes of a MIDI file at path as read_midi does, and returns the file’s bytes with them, so a caller can hash the very bytes it read.
read_midi_near
Reads the notes of a MIDI file at path as read_midi does, and also accepts a file whose every tempo matches refined, the trusted tempo refined from the stem. A refined equal to bpm counts as none.
split_at_attacks
Splits each note where the stem has an attack of its own inside it.
transcribe_stem
Runs the notes step on a mono stem at any rate: one model run, one f0 track, detection, the decode with the detected settings or those of profile, and clean_up.
voicing_of_notes
The voicing of a note list by the rule detection applies to its probe notes.
write_midi
Encodes the notes as a format 0 file at a BPM.
write_named_midi
Encodes the notes as write_midi does, with a track name event at tick 0 before the tempo. notes names the stem this way, so a later run can tell a file of another stem; midi_track_name reads it back.

Type Aliases§

LevelReader
Reads the full-band level of the stem from one time to another, with the RMS window of a frequency’s period.
Tracker
The f0 tracker that the notes step runs beside the model: PitchTrack::of unless Transcriber::with_tracker names another.