Abjad (3.0.0)

GitHub | PyPI | Documentation | Mailing list | Issue Tracker | Travis-CI


Abjad helps composers build up complex pieces of music notation in an iterative and incremental way. Use Abjad to create symbolic representations of all the notes, rests, staves, tuplets, beams and slurs in any score. Because Abjad extends the Python programming language, you can use Abjad to make systematic changes to your music as you work. And because Abjad wraps the powerful LilyPond music notation package, you can use Abjad to control the typographic details of the symbols on the page.


1. Get Abjad and LilyPond

Get Abjad via pip:

~$ sudo pip install abjad

Get LilyPond from http://lilypond.org/development.html.

Consult our installation instructions for detailed help on getting Abjad, setting it up, and installing any dependencies like LilyPond:

2. Make notation

Start your Python interpreter and import Abjad:

>>> import abjad

Then use Abjad to create and show notation:

>>> duration = abjad.Duration(1, 4)
>>> notes = [abjad.Note(pitch, duration) for pitch in range(8)]
>>> staff = abjad.Staff(notes)
>>> abjad.show(staff)

Note that you can click on any music notation you find in Abjad’s documentation to see its LilyPond source code.

You might notice that the music notation throughout Abjad’s documentation doesn’t quite look like what LilyPond produces out-of-the-box. There are a number of small differences. For example, all of the notes, chords and rests are spaced proportionally. There are no bar numbers. The glissandi are a little bit thicker than normal. Tuplet brackets show the tuplet ratio rather than a single number.

How does this happen? Our notation examples are generated as part of Abjad’s doc-building process via a custom Sphinx extension housed in Abjad’s abjad.book subpackage. To get the look-and-feel we want for our examples, we include a default stylesheet in each generated file.

Not all examples are styled the same. When demonstrating LilyPond overrides or page layout options we may replace Abjad’s default documentation stylesheet with another stylesheet or disable documentation stylesheets entirely. If, while examining the LilyPond source files in Abjad’s documentation, you encounter \include "..." statements in those files, you can find the corresponding stylesheets in Abjad’s documentation source directory: abjad/docs/source/_stylesheets/.

Now, let’s split the notes you just made every 5/16 duration, transpose every other split group up by a major-seventh, then slur every split group and finally attach an accent to the first note of each split group:

>>> shards = abjad.mutate(staff[:]).split(
...     durations=[abjad.Duration(5, 16)],
...     cyclic=True,
...     tie_split_notes=False,
...     )
>>> for index, shard in enumerate(shards):
...     if index % 2:
...         abjad.mutate(shard).transpose('M7')
...     if 1 < len(shard):
...         abjad.attach(abjad.Slur(), shard)
...     abjad.attach(abjad.Articulation('accent'), shard[0])
>>> abjad.show(staff)

Now let’s create a second staff, copied from the first, invert all of the new staff’s pitches around middle-G and finally group both staves into a staff group:

>>> copied_staff = abjad.mutate(staff).copy()
>>> staff_group = abjad.StaffGroup([staff, copied_staff])
>>> for note in abjad.iterate(copied_staff).leaves(pitched=True):
...     note.written_pitch = note.written_pitch.invert(axis='G4')
>>> abjad.show(staff_group)

Explore Abjad’s documentation to find even more ways you can create and transform notation with Python, LilyPond and Abjad.

Texts on Abjad

A number of papers and dissertations discuss Abjad.


Abjad lets you:

  • Create musical notation in an object-oriented way.
  • Model compositional thinking computationally.
  • Generate and transform complex rhythms through rhythm-makers, meter-rewriting and quantization.
  • Construct powerful component selectors for locating musical objects in a score.
  • Parse LilyPond and RTM syntax into musical objects.
  • Control all of the typographic details of music notation.
  • Embed musical notation in IPython notebooks, LaTeX and Sphinx documents.

Explore the high-level overview of Abjad’s concepts or our tutorials and examples to see these features in action:


Abjad supports a collection of extension packages providing additional documentation, tooling and compositional support.

Abjad’s codebase in detail

Miscellaneous information