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§
- Cleanup
Steps - 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.
- Contour
Point - One point of an f0 contour.
- Decode
Settings - 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.
- Drop
Span - A pitch drop of the pitch layer.
- Final
Note - One note of the final list, in ticks.
- Final
Notes - The final note list.
- Finish
Input - What
finishreads. - Frame
Mask - The masks of one frame: for each bin the note that claims it and whether a second note claims it too.
- Glide
Span - A glide of the pitch layer.
- Mask
Params - Settings of the harmonic masks.
- Masker
- Builds the masks of a note list on the bins of an STFT layout.
- Midi
Error - A MIDI file that cannot give a note list.
- Model
Run - The posteriorgrams of one model run over a stem.
- Note
- One note: onset, offset, pitch, and the fields later steps fill.
- Note
Facts - What the layer report says of one note of the list.
- Note
List - The notes of a stem, sorted by onset.
- Octave
Check - What the octave check did.
- Pitch
Range - A range of whole MIDI pitches the decoder may create, both ends kept, within the model’s range A0 to C8.
- Pitch
Track - The f0 track of a stem.
- Stem
Levels - The stem’s level in
QUIET_FRAMEframes at its own rate, with a quarter-frame hop, framemcentred atmhops. The quiet-note guard, the attack split and the split join read the same frames. - Track
Frame - 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.
- Transcription
Record - The transcriber’s model and settings, as the
transcriptiongroup oflayers.jsonrecords them. - Velocity
- A MIDI velocity from 1 to 127. Velocity 0 means a note-off in MIDI, so it is not a velocity.
- Vibrato
Span - A vibrato of the pitch layer.
Enums§
- EndRule
- Which rule set the end of a final note.
- Midi
Write Error - A note list that cannot become a MIDI file.
- Note
Error - A note or contour that breaks a rule.
- Notes
Error - A notes step that failed.
- Profile
- A fixed set of decode settings for one kind of stem.
- Range
Error - A pitch range that the decoder cannot use.
- Register
Source - Where the register came from.
- Track
Error - An f0 track that could not be built.
- Transcribe
Error - 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
renderreads 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
notescommand passes toVelocities::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_levelsums. - 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_SPANbefore 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 bundledMODEL_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_LATESTthe 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_attackssplits: 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
ddB under the loudest gets velocity127 * 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 detectwith 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_quietdoes, 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_withwith 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
Nonewhen 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_framesmodel 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 againstbpm. - read_
midi_ bytes - Reads the notes of a MIDI file at
pathasread_mididoes, 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
pathasread_mididoes, and also accepts a file whose every tempo matchesrefined, the trusted tempo refined from the stem. Arefinedequal tobpmcounts 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, andclean_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_mididoes, with a track name event at tick 0 before the tempo.notesnames the stem this way, so a later run can tell a file of another stem;midi_track_namereads it back.
Type Aliases§
- Level
Reader - 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::ofunlessTranscriber::with_trackernames another.