Reputation: 1547
When I'm trying to save score as a png,
sc = stream.Part()
...
sc.write('musicxml.png')
it sometimes get rendered as follows:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.0">
<movement-title />
<identification>
<creator type="composer" />
<encoding>
<encoding-date>2020-11-19</encoding-date>
<software>music21 v.6.1.0</software>
</encoding>
</identification>
<defaults>
<scaling>
<millimeters>7</millimeters>
<tenths>40</tenths>
</scaling>
</defaults>
<part-list>
<score-part id="P8729564f570fa991172c7cf3dc206c44">
<part-name />
</score-part>
</part-list>
<!--=========================== Part 1 ===========================-->
<part id="P8729564f570fa991172c7cf3dc206c44">
<!--========================= Measure 0 ==========================-->
<measure number="0">
<attributes>
<divisions>10080</divisions>
<time>
<beats>6</beats>
<beat-type>4</beat-type>
</time>
</attributes>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>10080</duration>
<type>quarter</type>
<notations>
<slur type="start" number="1" />
</notations>
</note>
<note>
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>10080</duration>
<type>quarter</type>
</note>
<note>
<pitch>
<step>B</step>
<alter>-1</alter>
<octave>4</octave>
</pitch>
<duration>10080</duration>
<type>quarter</type>
<accidental>flat</accidental>
</note>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>10080</duration>
<type>quarter</type>
</note>
<note>
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>10080</duration>
<type>quarter</type>
<notations>
<slur type="stop" number="1" />
</notations>
</note>
<note>
<rest />
<duration>10080</duration>
<type>quarter</type>
</note>
</measure>
<!--========================= Measure 0 ==========================-->
<measure number="0">
<attributes>
<time>
<beats>3</beats>
<beat-type>4</beat-type>
</time>
</attributes>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>20160</duration>
<type>half</type>
</note>
<note>
<chord />
<pitch>
<step>C</step>
<octave>4</octave>
</pitch>
<duration>20160</duration>
<type>half</type>
</note>
<note>
<chord />
<pitch>
<step>B</step>
<alter>-1</alter>
<octave>4</octave>
</pitch>
<duration>20160</duration>
<type>half</type>
<accidental>flat</accidental>
</note>
<note>
<chord />
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>20160</duration>
<type>half</type>
</note>
<note>
<chord />
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>20160</duration>
<type>half</type>
</note>
<note>
<rest />
<duration>10080</duration>
<type>quarter</type>
</note>
</measure>
</part>
</score-partwise>
I would like to compress it, so redundant spaces will be removed:
Is it somehow possible to force music21 toolkit to compress my score, so it wont take whole screen?
It looks like your post is mostly code; please add some more details.
Above warning is some kind of bullshit..
Upvotes: 3
Views: 212
Reputation: 3638
Look in the music21.layout
docs and module to see how to set SystemLayout and PageLayout objects to specify the width of the page and where to do line/system breaks to get the output you want.
Upvotes: 1