jdxi_editor.midi.track.classification

Track classification utilities for MIDI files.

This module provides functions to classify MIDI tracks into categories: - Bass: Low-pitched, monophonic or low polyphony tracks - Keys/Guitars: Wide range, polyphonic tracks (piano, guitar, etc.) - Strings: Sustained, legato tracks with ensemble-like patterns

Attributes

BASS_RULES

KEYS_RULES

STRINGS_RULES

Classes

ScoreRule

Functions

name_contains(keywords)

percentage(part, whole)

bass_percentage_gt(p)

max_polyphony_le(n)

avg_duration_gt(ticks)

note_range_ge(n)

has_pitch_bend(s)

max_polyphony_ge(n)

note_count_gt(n)

note_count_between(lo, hi)

legato_score_gt(x)

velocity_range_gt(r)

mid_percentage_between(lo, hi)

velocity_std_lt(threshold)

name_contains_string(→ bool)

True when track name contains 'string' or 'strings' (case-insensitive).

analyze_track_for_classification(...)

score_rules(→ float)

calculate_scores(→ None)

explain_score(stats, rules)

_calculate_std_dev(→ float)

Calculate standard deviation of a list of values.

classify_tracks(→ dict)

Classify tracks in a MIDI file into Bass, Keys/Guitars, and Strings.

Module Contents

jdxi_editor.midi.track.classification.name_contains(keywords)[source]
jdxi_editor.midi.track.classification.percentage(part, whole)[source]
jdxi_editor.midi.track.classification.bass_percentage_gt(p)[source]
jdxi_editor.midi.track.classification.max_polyphony_le(n)[source]
jdxi_editor.midi.track.classification.avg_duration_gt(ticks)[source]
jdxi_editor.midi.track.classification.note_range_ge(n)[source]
jdxi_editor.midi.track.classification.has_pitch_bend(s: jdxi_editor.midi.track.stats.TrackStats)[source]
jdxi_editor.midi.track.classification.max_polyphony_ge(n)[source]
jdxi_editor.midi.track.classification.note_count_gt(n)[source]
jdxi_editor.midi.track.classification.note_count_between(lo, hi)[source]
jdxi_editor.midi.track.classification.legato_score_gt(x)[source]
jdxi_editor.midi.track.classification.velocity_range_gt(r)[source]
jdxi_editor.midi.track.classification.mid_percentage_between(lo, hi)[source]
jdxi_editor.midi.track.classification.velocity_std_lt(threshold)[source]
class jdxi_editor.midi.track.classification.ScoreRule[source]
name: str[source]
weight: float[source]
condition: Callable[[jdxi_editor.midi.track.stats.TrackStats], bool][source]
evaluate(stats: jdxi_editor.midi.track.stats.TrackStats) float[source]
jdxi_editor.midi.track.classification.BASS_RULES[source]
jdxi_editor.midi.track.classification.KEYS_RULES[source]
jdxi_editor.midi.track.classification.name_contains_string(stats: jdxi_editor.midi.track.stats.TrackStats) bool[source]

True when track name contains ‘string’ or ‘strings’ (case-insensitive).

jdxi_editor.midi.track.classification.STRINGS_RULES[source]
jdxi_editor.midi.track.classification.analyze_track_for_classification(track: mido.MidiTrack, track_index: int) jdxi_editor.midi.track.stats.TrackStats[source]
jdxi_editor.midi.track.classification.score_rules(stats: jdxi_editor.midi.track.stats.TrackStats, rules: list[ScoreRule]) float[source]
jdxi_editor.midi.track.classification.calculate_scores(stats: jdxi_editor.midi.track.stats.TrackStats) None[source]
jdxi_editor.midi.track.classification.explain_score(stats: jdxi_editor.midi.track.stats.TrackStats, rules: list[ScoreRule])[source]
jdxi_editor.midi.track.classification._calculate_std_dev(values: List[float]) float[source]

Calculate standard deviation of a list of values.

jdxi_editor.midi.track.classification.classify_tracks(midi_file: mido.MidiFile, exclude_drum_tracks: List[int] | None = None, min_score: float = 30.0) dict[source]

Classify tracks in a MIDI file into Bass, Keys/Guitars, and Strings.

Parameters:
  • midi_file – The MIDI file to analyze

  • exclude_drum_tracks – List of track indices to exclude from classification

  • min_score – Minimum score threshold for a track to be classified

Returns:

  • “bass”: List of (track_index, “TrackStats”) tuples

  • ”keys_guitars”: List of (track_index, TrackStats) tuples

  • ”strings”: List of (track_index, TrackStats) tuples

  • ”unclassified”: List of (track_index, TrackStats) tuples

Return type:

Dictionary with keys