Abjad (2.16)

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

Introduction

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.

Quickstart

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:

>>> from abjad import *

First make eight 1/4 notes, rising by half-step from C to G:

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

Hint

Click on any music notation you find in Abjad’s documentation to see its LilyPond source code.

Note

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 abjadbooktools 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 = mutate(staff[:]).split(
...     durations=[Duration(5, 16)],
...     cyclic=True,
...     tie_split_notes=False,
...     )
>>> for index, shard in enumerate(shards):
...     if index % 2:
...         mutate(shard).transpose('M7')
...     attach(Slur(), shard)
...     attach(Articulation('accent'), shard[0])
... 
>>> show(staff)

That looks a little more intriguing, doesn’t it?

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 = mutate(staff).copy()
>>> staff_group = StaffGroup([staff, copied_staff])
>>> for note in iterate(copied_staff).by_class(Note):
...     note.written_pitch = note.written_pitch.invert(axis='G4')
... 
>>> 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.

Features

Abjad lets you:

  • Create musical notation in an object-oriented way.
  • Model compositional thinking computationally.
  • Generate and transform complex rhythmic 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: