Musicxml import parses only first `<score-instrument>` for a part
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start by reproducing with the attached BasicRockBeat.musicxml, using the script in the issue to print each note's getInstrument().instrumentId, which currently returns None. The MusicXML import code is the entry point, and the work is to read every score-instrument in a score-part and match each note to its instrument id. Done means each drum note reports its own instrument ID (such as P1-I36) and name, and chords get the right instrument per note. The maintainer notes say the issue is unlikely to be addressed soon, so confirm scope before starting.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
music21 version
9.1.0
Problem summary
When importing MusicXML files which contain parts with Drumsets (which use multiple instruments), it's impossible to tell what instrument which note belongs to.
music21 seems to only read the first <score-instrument> section of a <score-part>, and it doesn't seem to read the <instrument id="..."/> section of each <note>. This behaviour loses most of the drum note information, i.e. which actual drum to hit (.displayName is quite insufficient as many different drums can be notated on the same staff position, and each score can use different drum-to-staff mappings).
Steps to reproduce
I'm attaching a very basic MusicXML file which contains a basic drum rock beat. This file was produced by MuseScore 4.2.1.
The file contains a single drumset part with a single measure with:
- a quarter-note chord of closed hi-hat together with the bass drum,
- a quarter-note of closed hi-hat
- a quarter-note chord of closed hi-hat together with the snare,
- a quarter-note of closed hi-hat again.
First, ungzip the file in shell:
gzip -d BasicRockBeat.musicxml.gz
Then, in Python:
import music21
brb = music21.converter.parse('BasicRockBeat.musicxml')
# try to print note instruments
for note in brb.flatten().notes:
instr = note.getInstrument()
instr_id = instr.instrumentId
print(f'ID {instr_id}: {instr}')
# first "note" is actually a chord. Maybe there's an instrument hidden somewhere in the notes?
first_chord_first_note = brb.flatten().notes[0].notes[0]
instr = first_chord_first_note.getInstrument()
instr_id = instr.instrumentId
print(f'ID {instr_id}: {instr}')
Observe the following output:
ID None: P1: Drumset: Acoustic Bass Drum
ID None: P1: Drumset: Acoustic Bass Drum
ID None: P1: Drumset: Acoustic Bass Drum
ID None: P1: Drumset: Acoustic Bass Drum
ID None:
Expected vs. actual behavior
I'd expect each note to be assigned to the correct instrument.
At the very least I'd expect .getInstrument().instrumentId to point to the correct instrument ID (i.e. "P1-I36", "P1-I43" and so on).
Additionally, I'd expect there to be an easy way to get the instrument name as well, i.e. not just "Acoustic Bass Drum" for everything (which is actually a substring together with Drumset), but also "Closed Hi-hat", "Acoustic Snare", etc. I'd also like to be able to access the MIDI note number (currently .midiProgram is empty for that instrument, and .midiChannel is sometimes correctly 9, but only if the note is not in a chord.).
More information
My suggestion would be to fully parse the <score-instrument> sections of a <score-part>. Parsing <midi-instrument>s would be nice too, so that the user of the library could get at the <midi-channel>, <midi-program> and <midi-unpitched> values. Once that's done, the instruments could be properly assigned to <note>s using IDs, as per the MusicXML standard.
- Lingua principale
- Python
- Stelle
- 2.6k
- Fork
- 459
- Merge medio
- 1g 7h
- PR unite (30g)
- 40
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di cuthbertLab/music21
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
cuthbertLab/music21#2084 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
cuthbertLab/music21#2082 ·
I maintainer di solito rispondono entro 1 giorno
-
`TypeError` in `ChordReducer.run()` on multi-part `stream.Score` without instrument `partId`sAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
cuthbertLab/music21#2074 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
cuthbertLab/music21#2055 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Slur bezier-x/y from start element gets overwritten by stop element's valuesForse di nuovo libera @bingliscodes l’ha presa 8 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
cuthbertLab/music21#2019 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di cuthbertLab/music21
Issue simili
-
`burr` fails to start when the Python path has a space in itForse già presa @enekoreto l’ha presa oggi. Apertastatus/needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 5 giorni
-
gemini 出现了新的域名需要加入Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 72/100
debpalash/VoiceStudio#2903 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
dagster-io/community-integrations#367 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
aws-samples/sample-per-model-bedrock#243 ·
I maintainer di solito rispondono entro 1 giorno