musif.musicxml package¶
Submodules¶
musif.musicxml.common module¶
- musif.musicxml.common.fix_repeats(score: music21.stream.base.Score)[source]¶
Fix the repeat sign in the score by ensuring that all the parts have the same signs
- musif.musicxml.common.get_notes_and_measures(part: music21.stream.base.Part, with_positions: bool = False) Tuple[List[music21.note.Note], List[music21.note.Note], List[music21.stream.base.Measure], List[music21.stream.base.Measure]][source]¶
Obtains lists of notes, tied notes, measures, measures that containg notes, and notes and rests. Information that is useful in the subsequent process of extraction.
- Parameters:
part (Part) – Music21 part to extract the info from.
with_positions (bool) – When True, a sixth element is returned: for each note, a pair (0-based position of its measure in the part, in the order of the file whatever the printed numbers say; onset of the note in quarter notes from the start of that measure as written).
- musif.musicxml.common.is_voice(part: music21.stream.base.Part) bool[source]¶
Returns True if the part is a singer part, otherwise returns False
- Parameters:
part (Part) – Music21 part to check if it’s a singer part
- musif.musicxml.common.name_parts(score: music21.stream.base.Score)[source]¶
This function assign a name to each part in the score. If a name is already present, we keep it there, otherwise, we create a name of type missingName# where # is an incremental number,
- musif.musicxml.common.split_layers(score: music21.stream.base.Score, split_keywords: List[str])[source]¶
Function used to split possible layers. Those instruments that include to parts in the same staff will be separated in two diferent parts so they can be treated separately.
- Parameters:
score (Score) – Music21 score to scan and separate parts in it according to split_keywords list
split_keywords (List[str]) – List containing key words of instruments susceptible to be splitted. i.e. [oboe, viola]
- musif.musicxml.common.to_sounding_pitch(score: music21.stream.base.Score, file_path=None) None[source]¶
Transposes the score, in place, to sounding pitch: afterwards the notes, chords and key signatures of every transposing instrument (horns, trumpets, clarinets…) are the ones that sound. Only the transpositions the file states are applied, each from the measure that states it: a part that states none is left as it is, and so are the measures before the first one a part states.
- Parameters:
score (Score) – Music21 score to transpose
file_path (str, optional) – The MusicXML file the score was read from. The transpositions are taken from it, measure by measure. music21 alone cannot give them: it attaches to every instrument a default transposition (a horn is in F unless told otherwise) that cannot be told from one the file states, and would apply it to the measures in which the file states nothing. Without the file, or when it cannot be matched to the score part by part, music21’s reading of the instruments is used.
- musif.musicxml.common.unfold_score(score: music21.stream.base.Score, order: List[int]) music21.stream.base.Score[source]¶
The score with its measures in the order in which they are played: order gives, for each measure played, its 1-based position in every part (as ms3’s
mc). Repeated measures are copies; the score passed is taken apart and must not be used afterwards.Where the order jumps (a repeat, a da capo, a dal segno, a coda), the measure jumped to restates the time signature, key signature and clef in force at its place in the score, unless it states them itself: otherwise it would inherit those of the measure played before it (the end of the B section, often in another metre).
- Parameters:
score (Score) – Music21 score, as written (one pass through its measures)
order (List[int]) – Positions of the measures in the order in which they are played
musif.musicxml.constants module¶
- musif.musicxml.constants.FAMILY_TO_ABBREVIATION = {'brass': 'br', 'electric': 'elec', 'general': 'gen', 'keyboard': 'kb', 'percussion': 'perc', 'plucked': 'pluc', 'strings': 'str', 'voice': 'voice', 'wind': 'ww', 'woodwinds': 'ww'}¶
Dictionary containing abbreviation of each family
- musif.musicxml.constants.SCORING_FAMILY_ORDER = ['ww', 'br', 'perc', 'pluc', 'kb', 'voice', 'str', 'elec', 'gen']¶
Abbreviations of families in scoring order.
- musif.musicxml.constants.SCORING_ORDER = ['picc', 'fl', 'ob', 'eh', 'cl', 'sax', 'bn', 'hn', 'tpt', 'tbn', 'tba', 'timp', 'perc', 'mand', 'hp', 'pf', 'org', 'vv', 'cv', 'eq', 'fch', 'sop', 'alt', 'ten', 'bar', 'bbar', 'bass', 'vn', 'va', 'viol', 'vc', 'db', 'bs']¶
Abbreviations of sounds/instruments in scoring order. Abbreviations not listed here are appended at the end of Scoring/Instrumentation strings.
- musif.musicxml.constants.SOUND_TO_ABBREVIATION = {'a pistoni': 'crt', 'accordion': 'acc', 'alto': 'alt', 'alto flute': 'afl', 'archi': 'str', 'armonica a bocco': 'hca', 'armonium': 'harm', 'arpa': 'hp', 'arpeggione': 'arp', 'bagpipe': 'bag', 'banjo': 'bjo', 'baritone': 'bar', 'baritone oboe': 'bob', 'baritono': 'bryt', 'baryton': 'bryt', 'bass': 'bass', 'bass baritone': 'bbar', 'bass clarinet': 'bcl', 'bass flute': 'bfl', 'bass guitar': 'bgtr', 'bass oboe': 'bob', 'basset clarinet': 'bstcl', 'basset horn': 'bsthn', 'basso continuo': 'bs', 'bassoon': 'bn', 'bell': 'bell', 'bells': 'bell', 'bicchieri de vetro': 'ghca', 'bowl organ': 'ghca', 'brass instruments': 'br', 'bugle': 'bug', 'campanelli': 'gl', 'celesta': 'cel', 'cello': 'vc', 'cembalo': 'hpd', 'cetara': 'cit', 'cetra': 'cit', 'cetra da tavola': 'zith', 'chalumeau': 'cm', "child's voice": 'cv', "children's chorus": 'cch', 'chimes': 'bell', 'chitarra': 'gtr', 'chitarra elettrica': 'egtr', 'ciaramella': 'shw', 'cimbalom': 'cimb', 'cittern': 'cit', 'clarinet': 'cl', 'clarinetti': 'cl', 'clarinetto': 'cl', 'clarinetto contrabbasso': 'cbcl', 'clarinetto di bassetto': 'bstcl', 'clarino': 'tpt', 'clavicembalo': 'hpd', 'clavichord': 'clvd', 'clavicordo': 'clvd', 'concertina': 'conc', 'continuo': 'bs', 'continuous bass': 'bs', 'contrabass clarinet': 'cbcl', 'contrabasso': 'db', 'contrabassoon': 'cbn', 'contrafagotto': 'cbn', 'contralto': 'alt', 'cor anglais': 'eh', 'corna de segnale': 'bug', 'cornet': 'crt', 'cornett': 'crtt', 'cornetta': 'crt', 'cornetto': 'crtt', 'corno': 'hn', 'corno di bassetto': 'bsthn', 'corno inglese': 'eh', 'coro di fanciulli': 'cch', 'coro femminile': 'fch', 'coro maschile': 'mch', 'coro miste': 'ch', 'coro unisono': 'uch', 'cromorno': 'crh', 'crumhorn': 'crh', 'domra': 'dom', 'double bass': 'db', 'dulcian': 'dlcn', 'dulciana': 'dlcn', 'dulcimer': 'dulc', 'electric bass': 'bgtr', 'electric guitar': 'egtr', 'electric piano': 'epf', 'electronic instruments': 'elec', 'english horn': 'eh', 'equal voices': 'eq', 'erhu': 'erhu', 'eufonio': 'euph', 'euphonium': 'euph', 'fagoto': 'bn', 'female chorus': 'fch', 'fife': 'fife', 'fiffaro': 'fife', 'flageolet': 'flag', 'flagioletto': 'flag', 'flauto': 'fl', 'flauto a becco': 'rec', 'flauto di pan': 'pan', 'flauto dolce': 'rec', 'flauto piccolo': 'picc', 'flauto tenor': 'fda', 'flicorni': 'sxh', 'flicorno soprano': 'fgh', 'flugelhorn': 'fgh', 'flute': 'fl', "flute d'amore": 'fda', 'gamba': 'viol', 'ghironda': 'vie', 'glass harmonica': 'ghca', 'glassarmonica': 'ghca', 'glockenspiel': 'gl', 'guitar': 'gtr', 'harmonica': 'hca', 'harmonium': 'harm', 'harp': 'hp', 'harpsichord': 'hpd', 'heckelfono': 'heck', 'heckelphone': 'heck', 'horn': 'hn', 'hurdy-gurdy': 'vie', 'keyboard instrument': 'kbd', 'lira': 'lyre', 'liuto': 'lute', 'lute': 'lute', 'lyra tedesca': 'vie', 'lyre': 'lyre', 'male chorus': 'mch', 'mandolin': 'mand', 'mandolino': 'mand', 'marimba': 'mar', 'metallofono': 'gl', 'mezzo-soprano': 'mez', 'mezzosoprano': 'mez', 'mixed chorus': 'ch', 'mouth organ': 'hca', 'multiple soloists': 'vv', 'musette': 'mus', 'musette de cour': 'mus', 'narrator': 'nar', 'narratore': 'nar', 'oboe': 'ob', 'oboe baritono': 'bob', "oboe d'amore": 'oda', 'ocarina': 'oca', 'onde martenot': 'om', 'ondes martenot': 'om', 'ophicleide': 'oph', 'orchestra': 'orch', 'organ': 'org', 'organo': 'org', 'ottavino': 'picc', 'oud': 'oud', 'pan flute': 'pan', 'pan-pipes': 'pan', 'pedal piano': 'pfped', 'percussion': 'perc', 'piano': 'pf', 'piano 3 hands': 'pf3h', 'piano 4 hands': 'pf4h', 'piano 5 hands': 'pf5h', 'piano 6 hands': 'pf6h', 'piano di destra': 'pfrh', 'piano di sinistra': 'pflh', 'piano left hand': 'pflh', 'piano right hand': 'pfrh', 'pianoforte': 'pf', 'pianoforte 3 mani': 'pf3h', 'pianoforte 4 mani': 'pf4h', 'pianoforte 5 mani': 'pf5h', 'pianoforte 6 mani': 'pf6h', 'pianoforte elettrico': 'epf', 'pianoforte organistico': 'pfped', 'piccolo': 'picc', 'piccolo trumpet': 'ptpt', 'piffaro': 'shw', 'pipa': 'pipa', 'rebec': 'reb', 'rebeca': 'reb', 'reciter': 'nar', 'recorder': 'rec', 'ribeca': 'reb', 'sackbut': 'skbt', 'salmoè': 'cm', 'salterio': 'dulc', 'sarrusofono': 'sar', 'sarrusophone': 'sar', 'sassofono': 'sax', 'saxhorn': 'sxh', 'saxofono': 'sax', 'saxophone': 'sax', 'serpent': 'srp', 'serpentone': 'srp', 'shawm': 'shw', 'sheng': 'sheng', 'silofono': 'xyl', 'sintetizzatore': 'syn', 'siringa': 'pan', 'sitar': 'sit', 'slide trumpet': 'stpt', 'solo': 'v', 'soprano': 'sop', 'string instruments': 'str', 'strumento a fiato di legno': 'ww', 'strumento a fiato di ottone': 'br', 'strumento a percussione': 'perc', 'strumento a tastiera': 'kbd', 'strumento elettrica': 'elec', 'synthesizer': 'syn', 'tenor': 'ten', 'tenor flute': 'fda', 'tenore': 'ten', 'theremin': 'thrm', 'timpani': 'timp', 'tromba': 'tpt', 'tromba a tirarsi': 'stpt', 'trombino': 'ptpt', 'trombone': 'tbn', 'trumpet': 'tpt', 'tuba': 'tba', 'tuba di wagner': 'wag', 'ukelele': 'uke', 'ukulele': 'uke', 'unison chorus': 'uch', 'vibrafono': 'vib', 'vibraphone': 'vib', 'vielle': 'vie', 'viol': 'viol', 'viola': 'va', "viola d'amore": 'vda', 'viola da gamba': 'viol', 'viola pomposa': 'vap', 'violin': 'vn', 'violino': 'vn', 'violoncello': 'vc', 'violone': 'vlne', 'voce': 'v', 'voce di fanciullo': 'cv', 'voci': 'vv', 'voci pari': 'eq', 'voice': 'v', 'voices': 'vv', 'vuvuzela': 'vuv', 'wagner tuba': 'wag', 'woodwind instruments': 'ww', 'xiao': 'xiao', 'xilofono': 'xyl', 'xylophone': 'xyl', 'zink': 'crtt', 'zither': 'zith'}¶
Dictionary connecting each instrument name in a musicxml to an abbreviation
- musif.musicxml.constants.SOUND_TO_FAMILY = {'': 'keyboard', '5th voice': 'voice', '6th voice': 'voice', 'a high trumpet': 'brass', 'a ob': 'woodwinds', 'a pistoni': 'brass', 'a small trumpet or tenor trombone': 'brass', 'additions to any wind instrument to indicate a tuning other than standard tuning': 'general', 'also for unspecified bass instrument': 'brass', 'althorn': 'brass', 'alto': 'voice', 'alto saxophone': 'woodwinds', 'alto trombone': 'brass', 'alto viola': 'strings', 'an unspecified or unknown chorus part': 'voice', 'antique cymbals': 'percussion', 'archlute': 'plucked', 'armonium': 'keyboard', 'arpa': 'plucked', 'b ob': 'woodwinds', 'baritone': 'voice', 'baritone horn': 'brass', 'baritone saxophone': 'woodwinds', 'baritone trombone': 'brass', 'baritono': 'strings', 'barrel organ': 'keyboard', 'baryton': 'strings', 'bass': 'voice', 'bass clarinet': 'woodwinds', 'bass drum': 'percussion', 'bass electric guitar': 'plucked', 'bass horn': 'brass', 'bass trombone': 'brass', 'bass tuba': 'brass', 'bass viola da gamba': 'strings', "basse d'harmonie": 'brass', 'basset horn': 'woodwinds', 'basso continuo': 'strings', 'bassoon': 'woodwinds', 'bell': 'percussion', 'bell lyre': 'percussion', 'bells': 'percussion', 'bicchieri de vetro': 'percussion', 'birds singing': 'percussion', 'bombarde': 'woodwinds', 'bombardino': 'brass', 'bombardon': 'brass', 'bowl organ': 'percussion', "boys' choir": 'voice', 'brass instruments': 'general', 'bugle': 'brass', 'cantus': 'voice', 'carillon': 'percussion', 'castanets': 'percussion', 'celesta': 'keyboard', 'cello': 'strings', 'cembalo': 'keyboard', 'cetra da tavola': 'plucked', 'chalumeau': 'woodwinds', "children's choir": 'voice', 'chimes': 'percussion', 'chinese cymbal': 'percussion', 'chirimía': 'woodwinds', 'chitarra': 'plucked', 'chitarra elettrica': 'plucked', 'choir': 'voice', 'chorus': 'voice', 'ciaramella': 'woodwinds', 'cimbalom': 'percussion', 'cimbasso': 'brass', 'cl in a \t\t\tcor in e|b': 'general', 'clairon': 'brass', 'clarinet': 'woodwinds', 'clarinet in a': 'woodwinds', 'clarinet in c': 'woodwinds', 'clarinetti': 'woodwinds', 'clarinetto': 'woodwinds', 'clarino': 'brass', 'clarion': 'brass', 'clavecin': 'keyboard', 'claves': 'percussion', 'clavicembalo': 'keyboard', 'clavichord': 'keyboard', 'clavicordo': 'keyboard', 'conga drums': 'percussion', 'congas': 'percussion', 'continuo': 'strings', 'continuous bass': 'strings', 'continuous solo instrument in a work': 'general', 'contrabass': 'strings', 'contrabasso': 'strings', 'contrabassoon': 'woodwinds', 'contrafagotto': 'woodwinds', 'contralto': 'voice', 'cor anglais': 'woodwinds', 'corna de segnale': 'brass', 'cornet': 'brass', 'cornett': 'brass', 'cornetta': 'brass', 'cornettino': 'brass', 'cornetto': 'brass', 'corno': 'brass', 'corno da caccia': 'brass', 'corno di bassetto': 'woodwinds', 'corno inglese': 'woodwinds', 'cuckoo': 'percussion', 'cymbal': 'percussion', 'dessus': 'voice', 'discant': 'voice', 'discantus': 'voice', 'double bass': 'strings', 'double bassoon': 'woodwinds', 'drum': 'percussion', 'drum with snares off': 'percussion', 'drums': 'percussion', 'dugetto': 'brass', 'dulcimer': 'percussion', 'electric': 'electric', 'electric guitar': 'plucked', 'english': 'general', 'english horn': 'woodwinds', 'etc. four hands': 'keyboard', 'eufonio': 'brass', 'euphonium': 'brass', 'examples': 'general', 'e|b clarinet': 'woodwinds', 'e|b horn': 'brass', 'fagoto': 'woodwinds', 'fanfare trumpet': 'brass', 'fiddle': 'strings', 'fife': 'woodwinds', 'fiffaro': 'woodwinds', 'finger cymbals': 'percussion', 'flautino': 'woodwinds', 'flauto': 'woodwinds', 'flauto a becco': 'woodwinds', 'flauto dolce': 'woodwinds', 'flauto piccolo': 'woodwinds', 'flauto quarto': 'woodwinds', 'flicorni': 'brass', 'flicorno': 'brass', 'flicorno soprano': 'brass', 'flugelhorn': 'brass', 'flute': 'woodwinds', 'flute in e|b': 'woodwinds', "flûte d'amour": 'woodwinds', 'french horn': 'brass', 'gamba': 'strings', "girls' choir": 'voice', 'glass harmonica': 'percussion', 'glassarmonica': 'percussion', 'glock': 'percussion', 'gong': 'percussion', 'guitar': 'plucked', 'handbell': 'percussion', 'harmonium': 'keyboard', 'harp': 'plucked', 'harpsichord': 'keyboard', 'heckelfono': 'woodwinds', 'heckelphone': 'woodwinds', 'helicon': 'brass', 'highest voice': 'voice', 'horn': 'brass', 'keyed bugle': 'brass', 'keyed trumpet': 'brass', 'lira': 'plucked', 'lituus': 'brass', 'liuto': 'plucked', 'lute': 'plucked', 'lyre': 'plucked', 'mandolin': 'plucked', 'mandolino': 'plucked', 'maracas': 'percussion', 'marimba': 'percussion', 'mellophone': 'brass', "mens' choir": 'voice', 'mezzo soprano': 'voice', 'musical clock': 'percussion', 'musical glasses': 'percussion', 'nightingale': 'percussion', 'oboe': 'woodwinds', "oboe d'amore": 'woodwinds', 'oboe da caccia': 'woodwinds', 'oboe di silva': 'woodwinds', 'oboe grande': 'woodwinds', 'ocarina': 'woodwinds', 'ophicleide': 'brass', 'orchestra': 'general', 'organ': 'keyboard', 'organ four hands': 'keyboard', 'organo': 'keyboard', 'organo a rullo': 'keyboard', 'ottavino': 'woodwinds', 'parade drum': 'percussion', 'percussion': 'percussion', 'physharmonica': 'keyboard', 'piano': 'keyboard', 'piano four hands': 'keyboard', 'pianoforte': 'keyboard', 'piccolo': 'woodwinds', 'piccolo oboe': 'woodwinds', 'piffaro': 'woodwinds', 'piston': 'brass', 'plucked instrument': 'plucked', 'pommer': 'woodwinds', 'post horn': 'brass', 'principale': 'brass', 'psaltery': 'plucked', 'quinta vox': 'voice', 'ratchet': 'percussion', 'rattle': 'percussion', 'recorder': 'woodwinds', 'requinto': 'plucked', 'rotary valve cornet': 'brass', 'salmoè': 'woodwinds', 'salterio': 'percussion', 'sassofono': 'woodwinds', 'saxhorn': 'brass', 'saxofono': 'woodwinds', 'saxophone': 'woodwinds', 'serpent': 'brass', 'serpentone': 'brass', 'sexta vox': 'voice', 'shawm': 'woodwinds', 'silofono': 'percussion', 'sleigh bells': 'percussion', 'small bell': 'percussion', 'snare drum': 'percussion', 'solo': 'voice', 'solo violin part': 'strings', 'solo vocal part': 'voice', 'sopranino recorder': 'woodwinds', 'soprano': 'voice', 'soprano saxophone': 'woodwinds', 'spinet': 'keyboard', 'spoken voice': 'voice', 'spoons': 'percussion', 'string drum': 'percussion', 'strings': 'general', 'strumento a fiato di ottone': 'general', 'strumento a percussione': 'percussion', 'suspended cymbal': 'percussion', 'tabor': 'percussion', 'taille de hautbois': 'woodwinds', 'tam tam': 'percussion', 'tambourine': 'percussion', 'tenor': 'voice', 'tenor bassoon': 'woodwinds', 'tenor drum': 'percussion', 'tenor horn': 'brass', 'tenor oboe': 'woodwinds', 'tenor saxophone': 'woodwinds', 'tenor trombone': 'brass', 'tenor viola da gamba': 'strings', 'tenore': 'voice', 'tenoron': 'woodwinds', 'the alto part in a chorus': 'voice', 'the bass part in a chorus': 'voice', 'the soprano part in a chorus': 'voice', 'the tenor part in a chorus': 'voice', 'theorbo': 'plucked', 'thoroughbass': 'strings', 'timbales': 'percussion', 'timpani': 'percussion', 'tiple': 'voice', 'tom tom': 'percussion', 'transverse flute': 'woodwinds', 'treble viola da gamba': 'strings', 'triangle': 'percussion', 'tromba': 'brass', 'trombone': 'brass', 'trumpet': 'brass', 'tuba': 'brass', 'turkish drum': 'percussion', 'usually brass': 'brass', 'vagans': 'voice', 'valve horn': 'brass', 'valve trombone': 'brass', 'valve trumpet': 'brass', 'vibrafono': 'percussion', 'vibraphone': 'percussion', 'viol': 'strings', 'viola': 'strings', 'viola basso': 'strings', 'viola bastarda': 'strings', "viola d'amore": 'strings', 'viola da braccio': 'strings', 'viola da gamba': 'strings', 'viola pomposa': 'strings', 'violetta': 'strings', 'violetta marina': 'strings', 'violin': 'strings', 'violin concertino': 'strings', 'violin principale': 'strings', 'violin ripieno': 'strings', 'violino': 'strings', 'violoncello': 'strings', 'violone': 'strings', 'virginal': 'keyboard', 'voce': 'voice', 'voice': 'voice', 'vox humana': 'woodwinds', 'wind band': 'brass', 'winds': 'general', "womens' choir": 'voice', 'woodwinds': 'woodwinds', 'xilofono': 'percussion', 'xylophone': 'percussion', 'zink': 'brass', 'zither': 'plucked', 'zufoletto': 'woodwinds'}¶
Dictionary containing the family of each instrument (sound)
musif.musicxml.key module¶
- musif.musicxml.key.analyze_key(score: music21.stream.base.Score) music21.key.Key[source]¶
music21’s key analysis of the score (score.analyze(“key”)), run on a separate stream that holds the same pitches and durations.
The analysis walks the notes of a flattened copy of the score, and every note it walks takes that copy as its active site. Afterwards note.beat is computed from the note’s position in the whole score modulo the length of a bar, which is wrong after a pickup, a metre change or a short bar, and the dotted figures were read from those beats.
- musif.musicxml.key.get_key_and_mode(score: music21.stream.base.Score) Tuple[music21.key.Key, str, str][source]¶
Returns abbreviated designation of keys (uppercase for major mode; lowercase for minor mode)
Example
if key == ‘D- major’: return ‘Db’
- Parameters:
score
musif.musicxml.repeat module¶
musif.musicxml.scoring module¶
- musif.musicxml.scoring.extract_sound(part: music21.stream.base.Part, config: ExtractConfiguration) str[source]¶
Returns sound name for a specific part based on the sound name Part: VnI -> Sound name: Vn :param part: Part to get abbreviaton from :type part: str :param cfg: ExtractConfiguration object :type cfg: ExtractConfiguration
- musif.musicxml.scoring.to_abbreviation(part: music21.stream.base.Part, parts: List[music21.stream.base.Part], cfg: ExtractConfiguration) str[source]¶
Returns abbreviation name for a specific part based on the sound name
- Parameters:
part (str) – Part to get abbreviaton from
parts (List[part]) – List of parts in the score
cfg (ExtractConfiguration) – ExtractConfiguration object
musif.musicxml.tempo module¶
- class musif.musicxml.tempo.TempoGroup2(value)[source]¶
Bases:
EnumContains constants refering to grouped tempo on the second level that will be used by the tempo module.
- FAST = 'Fast'¶
- MODERATE = 'Moderate'¶
- NA = 'NA'¶
- SLOW = 'Slow'¶
- musif.musicxml.tempo.extract_numeric_tempo(file_path: str) int | None[source]¶
Finds the numeric tempo in a musixml file: the first tempo stated in the first measure of the first part (<sound tempo=”…”>, in a direction or directly in the measure). It is “NA” when that measure states none, and also when it states 120, the default of notation software.
- Parameters:
file_path (str)
from. (Path to xml file to get the tempo)
- musif.musicxml.tempo.extract_reprise_instruction(file_path: str)[source]¶
Whether a MusicXML file carries a “da capo” or “dal segno” instruction: 1 if it does, 0 if it does not, “NA” if the file cannot be read.
Such a score does not write its reprise out: the opening section is on the page once and is performed twice. Every proportion and mean computed from the page therefore weighs that section once, where a score with a written-out reprise weighs it twice.
- Parameters:
file_path (str)
into. (Path to xml file to look)
- musif.musicxml.tempo.get_number_of_beats(time_signature: str) int[source]¶
Returns the number of beats corresponding to a time signature.
By default, this returns the numerator, with the exceptions when the numerator is 6, 9, or 12 and when the time signature is C or 3/8. If it is empty, it returns 1. If it is “NA”, it returns pd.NA.
- Parameters:
time_signature (str) – Time signature in the form of string separated by ‘/’ to obtain the time signature type.
- musif.musicxml.tempo.get_quarter_length(time_signature: str) float[source]¶
Returns the length of a measure in quarter notes for a time signature: 4 for 4/4 and for 2/2, 1.5 for 3/8, 3 for 6/8. Unlike the number of beats, it does not depend on which note value the signature takes as the beat, so rates per quarter note are comparable between metres.
It follows get_number_of_beats for the special values: 4 for “C”, 1 for an empty signature, and pd.NA for “NA”.
- Parameters:
time_signature (str) – Time signature in the form of string separated by ‘/’.
- musif.musicxml.tempo.get_tempo_grouped_1(tempo: str) str[source]¶
Returns a 1st level of grouping for the tempo markings, removing secondary labels and diminutive endings.
- Parameters:
tempo (str)
from. (Tempo string in italian to be extract the group)