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

See examples in Tune sources.

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.

Eskin ABC Tools

Load data from the Eskin ABC Transcription Tools tunebook websites (https://michaeleskin.com/tunebooks.html).

Requires:

Functions:

eskin.load_meta(key, *[, redownload])

Load the tunebook data, no parsing.

eskin.load_url(url)

Load tune from an Eskin abctools (michaeleskin.com/abctools/) share URL.

eskin.abctools_url_to_abc(url, *[, remove_prefs])

Extract the ABC from an Eskin abctools (michaeleskin.com/abctools/) share URL.

eskin.abc_to_abctools_url(abc, *[, lzw])

Create an Eskin abctools (michaeleskin.com/abctools/) share URL for abc.

Bill Black

Bill Black’s Irish Traditional Tune Library

https://www.capeirish.com/ittl/

Requires:

Functions:

bill_black.load_meta(*[, redownload, debug])

Load all data, splitting into ABC tune blocks and removing lines that start with %.

Paul Hardy

Load data from Paul Hardy’s tunebooks (https://pghardy.net/tunebooks/).

Requires:

Functions:

hardy.load_meta(key, *[, redownload, ...])

Load ABC tune blocks from a Paul Hardy tunebook, no parsing.

abcjs tools

See examples in Widget.

Widget

abcjs widget for Jupyter and more.

See examples in Widget.

ABCJSWidget(**kwargs)

Display SVG sheet music rendered from ABC notation by abcjs.

interactive([abc])

Return a Jupyter widget for interactive use, using ipywidgets.

Headless rendering

Render ABC notation to SVG sheet music using abcjs in the background.

See examples in Widget.

svg(abc, *[, scale, staff_width])

Render ABC notation to sheet music using abcjs, returning SVG string.

svg_to(svg, fmt, **kwargs)

Convert an SVG string to another format, returning bytes.

build()

Download abcjs and build our interface.

HTML page generation

Generate an HTML page to render ABC with abcjs.

html(abc, *[, title, scale, staff_width])

Generate an HTML page to render ABC with abcjs, returning string.

open_html(*args, **kwargs)

Generate an HTML page to render ABC with abcjs and open it in a new tab with the default web browser.