Skip to main content

Capo: A Python Library for Guitar Chord Transposition

Project description

Capo: A Python Library for Guitar Chord Transposition


built with Python3 GitHub repo size PyPI version

Overview

Capo is a lightweight Python library for guitarists and developers that provides precise chord transposition across capo positions. It allows users to easily convert chord progressions from one capo setting to another, supporting sharps, flats, complex chord types, and slash chords. Whether you’re building a songwriting assistant, a practice tool, or a music theory application, Capo delivers a clear, reliable foundation for working with chord mappings and capo calculations in Python.

PyPI Counter
Github Stars
Branch main dev
CI
Code Quality CodeFactor

Installation

Source Code

PyPI

Usage

Capo Map

Automatically converts chords between different capo positions while preserving harmonic relationships.

>>> from capo import capo_map
>>> capo_map(["A", "Em", "C", "G"], target_capo=2, current_capo=0)
['G', 'Dm', 'A#', 'F']
>>> capo_map(["A", "Em", "C", "G"], target_capo=2, current_capo=0, flat_mode=True)
['G', 'Dm', 'Bb', 'F']

Transpose

Shifts chords up or down by a specified number of semitones to change the song's key.

>>> from capo import transpose
>>> transpose(["A", "E", "Cm", "G", "Fmaj7"], semitones=3)
['C', 'G', 'D#m', 'A#', 'G#maj7']
>>> transpose(["A", "E", "Cm", "G", "Fmaj7"], semitones=3, flat_mode=True)
['C', 'G', 'Ebm', 'Bb', 'Abmaj7']

Key Scores

Returns all possible keys and their corresponding scores for a given list of chords using the Krumhansl-Schmuckler algorithm.

>>> from capo import key_scores
>>> key_scores(["Em", "Am", "G", "Bm", "Em", "C", "G", "Bm", "Em"])
{'A#m': 0.4871417233740239, 'G#': 0.4774543026320962, 'A#': 0.5520334829280494, 'D': 0.7477367635967468, 'Am': 0.6716505683174476, 'Gm': 0.6750401588831327, 'A': 0.6622255631674839, 'Dm': 0.6367313900369936, 'G': 0.8399547248439911, 'F#m': 0.6173531647275109, 'Fm': 0.530630809877153, 'C#m': 0.5987423938857308, 'D#': 0.5377480823857491, 'C': 0.7278176839673419, 'F#': 0.5572647563660749, 'F': 0.5820127037844264, 'Em': 0.8254612345527799, 'C#': 0.4563950736636346, 'E': 0.7179587455649095, 'B': 0.7088375508524547, 'G#m': 0.6478594798186766, 'D#m': 0.564206942839128, 'Cm': 0.6280335727363678, 'Bm': 0.8030131913724882}
>>> key_scores(["G#", "G#", "Fm", "C#", "D#", "G#", "Fm", "C#", "D#"], flat_mode=True)
{'Cbm': 0.5059430034954594, 'D': 0.47214060767880817, 'Fbm': 0.5663422985823668, 'Am': 0.626082212718544, 'Gm': 0.6473142793320639, 'Gb': 0.6249570609550481, 'Dm': 0.5984541508829389, 'G': 0.5502083795108782, 'Fm': 0.8274571550716174, 'Dbm': 0.6608315888220377, 'Bbm': 0.7017791458623973, 'Abm': 0.7402210552899815, 'Ab': 0.8839844066440953, 'Bb': 0.6867751194296899, 'Ebm': 0.6941303268339243, 'Db': 0.7655343684259058, 'F': 0.6847698356536668, 'Fb': 0.573580307659009, 'Gbm': 0.5507809081451287, 'Eb': 0.8043262373344897, 'Cb': 0.5963990540758232, 'C': 0.6631957481323153, 'Cm': 0.8049063265566369, 'A': 0.4962731607074994}

Detect Key

Automatically identifies the musical key from a sequence of chords using the Krumhansl-Schmuckler algorithm.

>>> from capo import detect_key
>>> detect_key(["Em", "Am", "G", "Bm", "Em", "C", "G", "Bm", "Em"])
'G'
>>> detect_key(["G#", "G#", "Fm", "C#", "D#", "G#", "Fm", "C#", "D#"], flat_mode=True)
'Ab'

Transpose to Key

Automatically transposes a list of chords from their current key to a target key.
If the current key is not provided, it will be detected automatically.

⚠️ Chords are shifted chromatically; chord qualities are not adjusted to the target key's scale.

>>> from capo import transpose_to_key
>>> transpose_to_key(["Am", "F", "C", "G"], target_key="C")
['Em', 'C', 'G', 'D']
>>> transpose_to_key(["Am", "F", "C", "G"], current_key="A", target_key="C")
['Cm', 'G#', 'D#', 'A#']
>>> transpose_to_key(["Am", "F", "C", "G"], current_key="A", target_key="C", flat_mode=True)
['Cm', 'Ab', 'Eb', 'Bb']

Issues & Bug Reports

Just fill an issue and describe it. We'll check it ASAP!

  • Please complete the issue template

References

1- Guitar chords capo calculator - GuitarPlayerBox
2- Enharmonic Equivalents - Music Theory Academy
3- Capo Calculator
4- Chord Transposer: Online Tool to Transpose Chords
5- Enharmonic Equivalent Chart with Enharmonic Note Names
6- Schmuckler, M.A., 1989. Expectation in music: Investigation of melodic and harmonic processes. Music Perception, 7(2), pp.109-149.
7- Chord Interval Chart: How Chords Are made (Notes and Interval Formulas)

Show Your Support

Star This Repo

Give a ⭐️ if this project helped you!

Donate to Our Project

Bitcoin

1KtNLEEeUbTEK9PdN6Ya3ZAKXaqoKUuxCy

Ethereum

0xcD4Db18B6664A9662123D4307B074aE968535388

Litecoin

Ldnz5gMcEeV8BAdsyf8FstWDC6uyYR6pgZ

Doge

DDUnKpFQbBqLpFVZ9DfuVysBdr249HxVDh

Tron

TCZxzPZLcJHr2qR3uPUB1tXB6L3FDSSAx7

Ripple

rN7ZuRG7HDGHR5nof8nu5LrsbmSB61V1qq

Binance Coin

bnb1zglwcf0ac3d0s2f6ck5kgwvcru4tlctt4p5qef

Tether

0xcD4Db18B6664A9662123D4307B074aE968535388

Dash

Xd3Yn2qZJ7VE8nbKw2fS98aLxR5M6WUU3s

Stellar

GALPOLPISRHIYHLQER2TLJRGUSZH52RYDK6C3HIU4PSMNAV65Q36EGNL

Zilliqa

zil1knmz8zj88cf0exr2ry7nav9elehxfcgqu3c5e5

Coffeete

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

0.6 - 2026-01-05

Added

  • key_scores function

Changed

  • detect_key function modified
  • README.md updated
  • Test system modified

0.5 - 2025-12-15

Added

  • transpose_to_key function

Changed

  • capo_map function modified
  • README.md updated
  • Test system modified

0.4 - 2025-12-05

Added

  • detect_key function

Changed

  • _validate_chords function modified
  • README.md updated
  • Test system modified

0.3 - 2025-11-26

Added

  • Double sharp notes
  • Double flat notes

Changed

  • Fb bug fixed
  • Cb bug fixed
  • E# bug fixed
  • B# bug fixed
  • README.md updated
  • Test system modified

0.2 - 2025-11-15

Added

  • transpose function
  • Logo

Changed

  • README.md updated
  • capo_map function modified
  • Test system modified

0.1 - 2025-11-05

Added

  • capo_map function
  • Flat notes
  • Sharp notes

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

capo-0.6.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

capo-0.6-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file capo-0.6.tar.gz.

File metadata

  • Download URL: capo-0.6.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for capo-0.6.tar.gz
Algorithm Hash digest
SHA256 20dc5bc09279455902e7264cb8ba9c889e23598dd318b76a96102b4b49e5fc57
MD5 c49ea24a87e92d19ddbbf902a798fc45
BLAKE2b-256 72e46aa7ca79916f549016aee15b39b6e75d0474d7b0a48339b84f164d2da6bb

See more details on using hashes here.

File details

Details for the file capo-0.6-py3-none-any.whl.

File metadata

  • Download URL: capo-0.6-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for capo-0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3914731157bb8f7b7b524d95012b8eb514eb797a2ad6d81c84964cbfa9f58c0c
MD5 3591f933160270f086ab83028862ef03
BLAKE2b-256 7e397ca00b06bffe08b20b3bbb6b1a2aac62fa6b29bc65f5470ba7aa24b23014

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page