pymusicxml package

A simple utility for exporting MusicXML files that represents musical objects more hierarchically.

While it is of course possible to create MusicXML files in Python directly via ElementTree, the format is awkwardly non-hierarchical. For instance, there are no separate objects for chords and tuplets; rather they exist only as special annotations to the note objects themselves. In pymusicxml, chords are represented similarly to notes but with multiple pitches, and tuplets are treated as containers for notes, chords, and rests.

At the moment, this library is intended as a tool for composition, making it easier to construct and export MusicXML scores in Python. In the future, the ability to parse existing MusicXML scores may be added.

Modules:

pymusicxml.directions

Module containing all non-spanner subclasses of the Direction type.

pymusicxml.enums

Module containing relevant Enums used throughout pymusicxml.

pymusicxml.notations

Module containing all non-spanner notations, such as glisses, bowings, fermatas, etc.

pymusicxml.score_components

Module containing all of the classes representing the hierarchy of a musical score.

pymusicxml.spanners

Module containing all spanners (i.e.

Public-Facing API (result of import *):

Enum(value)

Generic enumeration.

Degree(value, alter[, degree_type, print_object])

The <degree> element is used to add, alter, or subtract individual notes in the chord.

Dynamic(dynamic_text[, placement, voice, staff])

Class representing a dynamic that is attached to the staff

Harmony(root_letter, root_alter, kind[, ...])

Class representing harmonic notation.

MetronomeMark(beat_length, bpm[, placement, ...])

Class representing a tempo-specifying metronome mark

TextAnnotation(text[, font_size, italic, ...])

Class representing text that is attached to the staff

AccidentalType(value)

An enumeration.

ArpeggiationDirection(value)

An enumeration.

HairpinType(value)

An enumeration.

LineEnd(value)

An enumeration.

LineType(value)

An enumeration.

StaffPlacement(value)

An enumeration.

Arpeggiate([direction])

Chord arpeggiation notation.

DownBow()

Down-bow notation

Fermata([inverted])

Fermata notation.

Harmonic()

Harmonic notation.

Mordent([inverted, placement])

Mordent ornament.

NonArpeggiate()

Chord non-arpeggiate notation.

OpenString()

Open-string notation

Ornament()

Abstract class for all ornament notations

Schleifer([placement])

Schleifer mark.

SnapPizzicato()

Snap-pizzicato notation

StartGliss([number])

Notation to attach to a note that starts a glissando

StartMultiGliss([numbers])

Multi-gliss notation used for glissing multiple members of a chord

StopGliss([number])

Notation to attach to a note that ends a glissando

StopMultiGliss([numbers])

End of a multi-gliss notation used for glissing multiple members of a chord.

Stopped()

Stopped notation

Technical()

Abstract class for all technical notations

Tremolo([num_lines])

Tremolo lines on a note stem.

TrillMark([placement])

Trill mark on a single note (without wavy line).

Turn([inverted, delayed, placement])

Turn ornament.

UpBow()

Up-bow notation

BarRest(bar_length[, directions])

Class representing a bar rest.

BarRestDuration(length)

Special duration object used for bar rests.

BeamedGroup([contents])

Represents a group of notes/chords/rests joined under a single beam.

Chord(pitches, duration[, ties, notations, ...])

Class representing a chord.

Clef(sign, line[, octaves_transposition])

Class representing a musical clef

Direction([placement, voice, staff])

Abstract base class for musical directions, such as text and metronome marks.

Duration(note_type[, num_dots, tuplet_ratio])

Represents a length that can be written as a single note or rest.

GraceChord(pitches, duration[, ties, ...])

Subclass of Chord representing a durationless grace chord.

GraceNote(pitch, duration[, ties, ...])

Subclass of Note representing a durationless grace note.

Measure([contents, time_signature, key, ...])

Class representing a measure of music, perhaps with multiple voices.

Notation()

Abstract base class for MusicXML Notations (glissandi, slurs).

Note(pitch, duration[, ties, notations, ...])

Class representing a single, pitched note.

Notehead(notehead_name[, filled])

Class representing a notehead type.

Part(part_name[, measures, part_id, ...])

Represents a musical part/staff.

PartGroup([parts, has_bracket, ...])

Represents a part group (a group of related parts, possible connected by a bracket)

Pitch(step, octave[, alteration])

Class representing a notated musical pitch.

Rest(duration[, notations, directions])

Class representing a notated rest.

Score([contents, title, composer])

Class representing a full musical score

Transpose(chromatic[, diatonic, octave])

Class representing transposition.

Tuplet(contents, ratio)

Represents a tuplet; same as a BeamedGroup, but with a particular time ratio associated with it.

ChangePedal([label, sign, line, placement, ...])

Pedal change in the middle of a sustain pedal spanner.

StartBracket([label, line_type, line_end, ...])

Start of a bracket spanner.

StartDashes([label, dash_length, ...])

Start of a dashed spanner (e.g.

StartHairpin(hairpin_type[, label, spread, ...])

Notation to attach to a note that starts a hairpin

StartPedal([label, sign, line, placement, ...])

Start of a sustain pedal spanner.

StartSlur([label])

Notation to attach to a note that starts a slur

StartTrill([label, placement, accidental])

Starts a trill spanner with a wavy line.

StopBracket([label, line_end, end_length, ...])

StopDashes([label, text, placement, voice, ...])

End of a dashed spanner (e.g.

StopHairpin([label, spread, placement, ...])

Notation to attach to a note that ends a hairpin

StopPedal([label, sign, line, placement, ...])

Stops a sustain pedal spanner.

StopSlur([label])

Notation to attach to a note that ends a slur

StopTrill([label, placement])

Stops a trill spanner with a wavy line.