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.

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, …)

Class representing a bar rest.

BarRestDuration(length)

Special duration object used for bar rests.

BeamedGroup(*args, **kwds)

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

Chord(pitches, str]], duration, str, float], …)

Class representing a chord.

Clef(sign, line, octaves_transposition)

Class representing a musical clef

Direction(placement, …)

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, str]], duration, str, …)

Subclass of Chord representing a durationless grace chord.

GraceNote(pitch, str], duration, str, …[, …])

Subclass of Note representing a durationless grace note.

Measure(*args, **kwds)

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

Notation()

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

Note(pitch, str], duration, str, float], ties)

Class representing a single, pitched note.

Notehead(notehead_name, filled)

Class representing a notehead type.

Part(*args, **kwds)

Represents a musical part/staff.

PartGroup(*args, **kwds)

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, str, float], notations, str, …)

Class representing a notated rest.

Score(*args, **kwds)

Class representing a full musical score

Tuplet(*args, **kwds)

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

ChangePedal(id, sign, line, placement, …)

Pedal change in the middle of a sustain pedal spanner.

StartBracket(id, line_type, …)

Start of a bracket spanner.

StartDashes(id, dash_length, space_length, …)

Start of a dashed spanner (e.g.

StartHairpin(hairpin_type, …)

Notation to attach to a note that starts a hairpin

StartPedal(id, sign, line, placement, …)

Start of a sustain pedal spanner.

StartSlur(id)

Notation to attach to a note that starts a slur

StartTrill(id, placement, str] =, …)

Starts a trill spanner with a wavy line.

StopBracket(id, line_end, …)

StopDashes(id, text, …)

End of a dashed spanner (e.g.

StopHairpin(id, spread, placement, …)

Notation to attach to a note that ends a hairpin

StopPedal(id, sign, line, placement, …)

Stops a sustain pedal spanner.

StopSlur(id)

Notation to attach to a note that ends a slur

StopTrill(id, placement, str] =)

Stops a trill spanner with a wavy line.