chordseq
Search chord progressions in any key, count n-grams, and name chords by key. Pure Python, one dependency (chordsym).
>>> from chordseq import find, ngrams
>>> sequence = ["Dm", "Bb", "F", "C", "Dm", "Bb", "F", "C"]
>>> [(m.start, m.stop) for m in find("vi IV I V", sequence)] # Roman numerals: any key
[(0, 4), (4, 8)]
>>> [m.transposition for m in find("Am F C G", sequence)] # chord symbols: any key too
[5, 5]
pip install chordseq
One-command test on real data
pytest tests/test_smoke.py
It reads the first Chordonomicon progressions over the public datasets-server API (standard library only; skipped offline), searches them and counts their 4-grams. The same by hand:
from chordseq import find, ngrams
progressions = [row.split() for row in chordonomicon_rows] # "<verse_1> C G Amin F ..."
hits = [m for p in progressions for m in find("Amin F C G", p, dialect="chordonomicon")]
ngrams(progressions, n=4, dialect="chordonomicon").most_common(5)
The query
Whitespace-separated items, like a regular expression over chords:
| Item | Means |
|---|---|
Am, E7, F#m7b5 |
a chord symbol |
vi, V7, bVII, ii, viiø7 |
a Roman numeral (upper major, lower minor, ° ø + sus) |
. |
any one chord |
E|E7 |
either (no spaces) |
E7? |
optional |
* (alone, or after an item) |
any run of chords, as few as will do |
E(7) is refused with a hint: parentheses already mean alterations in chord symbols. Chord symbols and Roman numerals do not mix in a query.
Defaults
level="triads" (E matches E7; "root" and "tetrads" are the other mir_eval levels), transposition-invariant, inversions ignored, repeated chords collapsed. transposition_invariant=False matches the query's own key: chord symbols as written, Roman numerals against key=.
Sequences, payloads, matches
A sequence is an iterable of chord symbols, each optionally (symbol, payload) with any payload you like (a time, a bar, a page). find(query, sequence) returns Match objects: start/stop are indices into the sequence as you gave it (so collapsed repeats are covered), items, symbols, payloads, transposition. search(query, sequences) does many sequences lazily, with sequence_index. The engine knows nothing about audio, pages or songs; you map spans to times or pages through the payloads. Anything that is not a chord (N, <verse_1>) matches nothing, so no match runs across it: cut a song into sections and the matches stay inside them.
N-grams and Roman numerals
ngrams(sequences, n=(2, 3, 4)) # pooled Counter of tuples, in the key of each sequence
ngrams(
sequences, relative_to="first"
) # keyless: numerals from each n-gram's first chord
ngrams(sequences, relative_to=None, per_sequence=True)
to_roman_sequence(["G", "D", "Em", "C"]) # ['I', 'V', 'vi', 'IV']
Roman numerals use one chromatic scheme from the tonic, major or minor key alike (bIII, bVI, bVII in a minor key), so to_roman and the query read each other.
Seams
| Seam | Keyword | Default | Replacement that exists |
|---|---|---|---|
| Chord spelling of the input | dialect= |
"default" (chart spellings) |
chordsym.DIALECTS (chordonomicon, harte), chordsym.register_dialect |
| Detail of comparison | level= |
"triads" |
"root", "tetrads" (mir_eval names) |
| Key for Roman numerals | key= |
estimated by chordsym.estimate_key |
any chordsym.Key |
NOT seams (v1): the scan engine (one regex pass per transposition over a string of one-character tokens; the packed-byte numpy scan of the phase-1 prototypes, in misc/docs/research/prototypes/, is the replacement when a corpus-sized consumer needs it, and then it lands behind the same search signature); an index; ranking and popularity; a browser or Web Worker build; a CLI; audio, pages and songs (callers map spans through payloads); chord symbols beyond what chordsym parses.
Design and research
The phase-1 design, five research reports and prototypes are in misc/docs/research/.
Metadata
Release files for chordseq 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chordseq-0.0.3.tar.gz | 88.3 kB | Without provenance | Details for chordseq-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chordseq-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for chordseq-0.0.3-py3-none-any.whl |
Total release size: 103.5 kB
Release files / chordseq-0.0.3.tar.gz
| Download URL | chordseq-0.0.3.tar.gz |
|---|---|
| Size | 88.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b35f5822146a8fc4cebc51074c2817e5fde6ec6e5063035a8f238a47063e085d
|
|
BLAKE2b-256 checksum How to use checksums |
4864300c1dfd4266fe3a6c63ff25ab8bf95fda3d3203e8d4e15f8e9beb2bd4c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / chordseq-0.0.3-py3-none-any.whl
| Download URL | chordseq-0.0.3-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
831db1000962b385076e4434d8caee799b3b4ab081b83987922997f13aa4cf27
|
|
BLAKE2b-256 checksum How to use checksums |
308b40711cfb6d26bb9516a745945c70bcb1c56c90af715db2a32ca27fab106f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for chordseq 0.0.3
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.