orchetect / DAWFileKit

A Swift library for reading and writing common import/export file formats between popular DAW applications.
MIT License
26 stars 2 forks source link

MusicXML Support #19

Open orchetect opened 1 year ago

orchetect commented 1 year ago

Proposal

Add support for reading and authoring MusicXML.

Support for markers will be the main priority.

Considerations

A bit of testing is needed to determine if precise timing information can be derived.

Preliminary Observations

For example, a MusicXML xml file exported from Digital Performer 10 is summarized below.

<?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>
    <identification>
        <creator type="composer">Steffan Andrews</creator>
        <rights>© Steffan Andrews</rights>
        <encoding>
            <software>Digital Performer 10.13 86175</software>
            <encoding-date>2021-02-06</encoding-date>
            <supports attribute="new-system" element="print" type="no" value="yes"/>
            <supports attribute="new-page" element="print" type="no" value="yes"/>
            <supports element="accidental" type="yes"/>
            <supports element="beam" type="yes"/>
            <supports element="stem" type="no"/>
        </encoding>
    </identification>
    <part-list>
        <part-group number="2" type="start">
            <group-symbol>bracket</group-symbol>
            <group-barline>yes</group-barline>
        </part-group>
        <score-part id="P0">
            <part-name>MIDI-1</part-name>
            <part-abbreviation>MI.1</part-abbreviation>
        </score-part>
        <part-group number="2" type="stop"/>
    </part-list>
    <part id="P0">
        <measure number="1">
            <attributes>
                <divisions>480</divisions>
                <key>
                    <fifths>0</fifths>
                    <mode>major</mode>
                </key>
                <time>
                    <beats>4</beats>
                    <beat-type>4</beat-type>
                </time>
                <staves>1</staves>
                <clef number="1">
                    <sign>G</sign>
                    <line>2</line>
                </clef>
                <transpose>
                    <diatonic>0</diatonic>
                    <chromatic>0</chromatic>
                    <octave-change>0</octave-change>
                </transpose>
            </attributes>
            <note>
                <rest measure="yes"/>
                <duration>1920</duration>
                <voice>1</voice>
                <staff>1</staff>
            </note>
            <direction placement="above">
                <direction-type>
                    <metronome>
                        <beat-unit>quarter</beat-unit>
                        <per-minute>120.00</per-minute>
                    </metronome>
                </direction-type>
                <offset>-1920</offset>
                <voice>1</voice>
                <staff>1</staff>
                <sound tempo="120.00"/>
            </direction>
        </measure>
        <measure number="2">
            <note>
                <rest measure="yes"/>
                <duration>1920</duration>
                <voice>1</voice>
                <staff>1</staff>
            </note>
        </measure>

                <!-- ... (snipped: empty measures 3 through 1800 which are identical to measure 2) ... -->

        <measure number="1801">
            <note>
                <rest measure="yes"/>
                <duration>1920</duration>
                <voice>1</voice>
                <staff>1</staff>
            </note>
            <direction placement="above">
                <direction-type>
                    <words>Unlocked Marker 1_00_00_00</words>
                </direction-type>
                <offset>-1920</offset>
                <voice>1</voice>
                <staff>1</staff>
            </direction>
            <direction placement="above">
                <direction-type>
                    <words>Locked Marker 1_00_01_00</words>
                </direction-type>
                <offset>-960</offset>
                <voice>1</voice>
                <staff>1</staff>
            </direction>
        </measure>
        <measure number="1802">
            <note>
                <rest measure="yes"/>
                <duration>1920</duration>
                <voice>1</voice>
                <staff>1</staff>
            </note>
            <barline location="right">
                <bar-style>light-heavy</bar-style>
            </barline>
        </measure>
    </part>
</score-partwise>

References

https://github.com/w3c/musicxml/blob/799e2defb2ece0ae7bafe08dcbcac25b2c631d53/schema/direction.mod#L83-L97

https://github.com/w3c/musicxml/blob/799e2defb2ece0ae7bafe08dcbcac25b2c631d53/schema/direction.mod#L117-L127

orchetect commented 1 year ago

Update: Importing the above xml file into Cubase does not import any text or marker events.

So the theory is correct that there is no standard MusicXML event type for a marker.