API

Note types

PitchClass(value)

Pitch without octave.

Pitch(value)

A pitch with value relative to C0.

Note(value[, duration])

A note has a pitch and a duration.

Alternative initializers:

PitchClass.from_name(name)

From pitch class name (e.g., C, F#).

PitchClass.from_pitch(p)

From pitch instance.

Pitch.from_name(name)

From scientific pitch notation (SPN).

Pitch.from_class_name(class_name, octave)

From pitch class name and octave.

Pitch.from_class_value(value, octave)

From pitch class chromatic value and octave.

Pitch.from_etf(f)

From frequency, rounding to the nearest piano key.

Pitch.from_helmholtz(helmholtz_name)

From Helmholtz pitch notation.

Pitch.from_pitch_class(pc, octave)

From pitch class instance.

Note.from_abc(abc, *[, key, octave_base, ...])

Parse ABC string to note.

Note.from_pitch(p, *[, duration])

From pitch instance.

Key type

Key([name, tonic, mode])

Key, including mode.

Key.parse_key(key)

Parse a key spec string (e.g., D, Amin) and return the tonic and mode (3-char abbreviation).

Key.relative(mode, *[, match_acc])

Compute a relative key by specifying the target mode.

Tune type

Tune(abc)

Tune.

Some tune attributes derived from parsing the ABC header are available as instance attributes:

Tune.title

Tune primary title (first in the ABC).

Tune.titles

All tune titles.

Tune.type

Tune type/rhythm, e.g. 'jig'.

Tune.key

Key object corresponding to the tune's key.

Tune.url

Revelant URL for this particular tune/setting.

Other metadata from the ABC can be found in the Tune.header dict, and the original ABC is present at Tune.abc.

Tune.header

Information contained in the tune header.

Tune.abc

Original ABC string.

These methods/properties result from tune body parsing and repeat/ending expansion:

Tune.measures

Notes from "playing" the tune.

Tune.iter_notes()

Iterator (generator) for Notes of the tune.

Tune.print_measures([n, note_format])

Print measures to check parsing.

Tune sources

The pyabc2.sources namespace contains a few general tools.

load_example_abc([title])

Load an example ABC string, random if title not provided.

load_example([title])

Load an example tune, random if title not provided.

load_url(url)

Load tune from ABC found at the specified webpage.

Others are found in source-specific submodules. For example:

from pyabc2.sources import norbeck

Norbeck

Load Henrik Norbeck’s ABC Tunes (https://www.norbeck.nu/abc/).

Requires:

Functions:

norbeck.load([which, ascii_only, debug])

Load a list of tunes, by type(s) or all of them.

norbeck.load_url(url)

Load tune from a specified norbeck.nu/abc/ URL.

The Session

Load data from The Session (https://thesession.org).

Requires (to load tunes with load() or load_url()):

To load additional archive datasets with load_meta(), requires:

Functions:

the_session.load(*[, n, redownload, debug, ...])

Load tunes from The Session archive (https://github.com/adactio/TheSession-data).

the_session.load_meta(which, *[, ...])

Load data from The Session archive (https://github.com/adactio/TheSession-data) as a dataframe (requires pandas).

the_session.load_url(url)

Load tune from a specified thesession.org URL.