Skip to main content
PitchClock Logo

PitchClock Logo

PitchClock

PitchClock is a Python library for generating tone clock visualizations. Tone clocks were originally developed as a tool for atonal composition, but can also be quite useful for visualizing tonal structures in classical and Just Intonation theory as well.

License

PitchClock is distributed under the permissive MIT license.

Installation

The latest stable distribution of PitchClock can be installed with pip:

pip install pitchclock

Or, if you prefer the current development version:

pip install git+https://github.com/hosford42/pitchclock.git

Example Usage

As an example, let’s compare the equal temperament major scale, versus the just intonation scale it approximates, known as the syntonic diatonic scale. Tone clocks are used for visualizing the relationships, i.e. the intervals, between the pitches, rather than the absolute pitches themselves. Thus the typical approach is to label the pitches with the intervals from the tonic that produce them, and to place the tonic at the 12 o’clock position. The equal temperament intervals are represented as the number of half-tones in the interval, enclosed within square brackets. The just intervals are represented as whole number frequency ratios. For this graph, we will mark the equal temperament intervals with filled circles, the just intervals with outlined circles, and the tonic with an angle mark. Here’s the code to produce the graph:

from fractions import Fraction
from pitchclock import ETInterval, ToneClock

# The equal temperament scale, expressed as equal temperament
# intervals from the tonic.
et_major_scale = [ETInterval(s) for s in [0, 2, 4, 5, 7, 9, 11]]

# The just intonation scale, expressed as frequency ratios from
# the tonic.
ji_major_scale = [
    Fraction(*pair)
    for pair in [(1, 1), (9, 8), (5, 4), (4, 3), (3, 2), (5, 3), (15, 8)]
]

# Here we create the clock, indicating which pitches to represent
# with each type of marking in the graph.
clock = ToneClock(
    filled_dots=et_major_scale,
    empty_dots=ji_major_scale,
    angles=[et_major_scale[0], ji_major_scale[0]],
    labels={p: p for p in et_major_scale + ji_major_scale}
)

# We make the radius a little bigger because there's a lot going
# on in this graph. A bigger radius means more space for details.
clock.style.radius *= 1.5

# Everything is quantized to quarter tones by default, but we are
# building this graph specifically to compare slight differences
# in pitch, so we turn it off. However, we leave it on for labels,
# because otherwise they will overlap for pitches that are very
# close neighbors. With quantization of labels left on, labels
# falling within the same quantum will be grouped together with
# commas to separate them.
clock.style.quantize_non_labels = False

# Save the clock as a PNG file. Currently, this is the only
# supported format.
clock.save('images/major_comparison.png')

And here’s the image it produces:

Major Scale Comparison

Major Scale Comparison

From this graph, it becomes immediately apparent that the intervals in the syntonic scale that are most poorly approximated by the equal temperament major scale are 5/4, 5/3, and 15/8, each of which is slightly flatter than the equal temperament pitch used to approximate it.

Metadata

Release files for pitchclock 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pitchclock 0.0.4
File Size Uploaded Provenance
pitchclock-0.0.4.tar.gz 9.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pitchclock 0.0.4
File Interpreter ABI Platform
pitchclock-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 20.7 kB

Release files / pitchclock-0.0.4.tar.gz

Download URL pitchclock-0.0.4.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1a3f6017b13a2b3f0ecfadc2e3a18922b592aa41c8c6d841759b441631414456
BLAKE2b-256 checksum
How to use checksums
f2b5ab17b19025e45af261977205a378857b8d367f455d57597000e2ba301234
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pitchclock-0.0.4-py3-none-any.whl

Download URL pitchclock-0.0.4-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4934ed0f1a277be4e859420371c374a579dd8a40e2fe37006b7969815af55650
BLAKE2b-256 checksum
How to use checksums
4220862c96656b29a55b61a37415c8dd65f42be1bfb0c007b1b0b7bc4e977b01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pitchclock 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page