Reputation: 958
I've been trying to load a MusicXML file, edit it (removing several parts), and create a PDF sheet document + midi/mp3, all of this using Python.
I've first looked at music21
, that would load my MusicXML file right, but as far as I could find, would not output a proper file (all the details in the output files have disappeared, all that's left is the notes and the title)
Then I found abjad
which looked promising. It did output great quality ly/pdf files, but there was no musicxml imported.
Then, I discovered that Lilypond comes with a musicxml2ly
script. I was able to call it and get the result lilypond file in python using sh
(great lib !) but then the abjad
lilypond
parser would not parse it (the doc says it parses a "large subset" for lilypond, without more precisions).
Finally, I found that music21
had an exporter to abjad python objects but it seems not to be present in the codebase anymore and the source code for the exporter clearly just exported the notes.
I'm a little out of options, what could I do to achieve these goals ?
(additional point : I still don't know how I'm going to do the second part, going to midi/mp3 using soundfonts, but that may not be the hardest part. Any suggestion ?)
Upvotes: 6
Views: 5409
Reputation: 1
%run /mnt/data/add_libraries_py from ai_song_maker import song_maker
abc_notation_intro = """ M:4/4 L:1/4 Q:1/4=70 K:C V:1 clef=treble name="Piano" snm="Piano" | [C2E2G2]4 | [G2B2D2]4 | [A2C2E2]4 | [F2A2C2]4 | """
ordered_part_instrument_intro = {'Piano': 'Piano'}
musicxml_path_intro = '/mnt/data/song_intro_musicxml.xml' midi_path_intro = '/mnt/data/song_intro_midi.mid'
parts_data_intro, score_data_intro = song_maker.process_abc(abc_notation_intro, ordered_part_instrument_intro, musicxml_path_intro, midi_path_intro)
musicxml_path_intro, midi_path_intro
Upvotes: 0
Reputation: 3648
If you have MuseScore 2+, you can set it up in python
import music21
c = music21.converter.parse('path_to_musicxml.xml')
c.show('musicxml.pdf')
c.show('midi')
Upvotes: 4