Skip to main content

A library to analyze chord progressions and convert them to Roman numeral analysis.

Project description

Chord Romanizer

PyPI version

Chord Romanizerは、コード進行の解析とディグリーネーム(ローマ数字)表記への変換を行うPythonライブラリです。 複雑なコードや転回形、ハイブリッドコード(分数コード)にも対応しており、文脈(前後のコード)を考慮した解析を行います。

特徴

  • 文脈考慮: キーと前後のコードから最適な度数表記を判定(例: 半音進行や解決先を考慮)。
  • 分数コード対応: 転回形 (C/E)、ハイブリッドコード (F/G)、UST (upper structure triad) などを識別し、適切に表記 (I/3, V9sus4, etc.)。
  • 柔軟な入力: 一般的なコードシンボル表記 (Cm7, F#aug, Bb/C など) をパース可能。

インストール

PyPIからインストールできます。

pip install chord-romanizer

クイックスタート

from chord_romanizer import Romanizer, ChordParser

# 1. インスタンス生成 (デフォルトキーを指定可能)
romanizer = Romanizer(default_tonic="C")

# 2. コード進行の準備 (文字列からParsedChordへ変換)
progression_str = ["Dm7", "G7", "Cmaj7", "A7(b9)", "Dm7"]
chords = [ChordParser.parse(c) for c in progression_str if c]

# 3. 解析 (annotate_progression)
# 結果は RomanizedChord オブジェクトのリスト
results = romanizer.annotate_progression(chords)

# 4. 結果の表示
for res in results:
    input_symbol = res.chord.symbol
    roman = res.roman
    key = romanizer.default_tonic
    print(f"{input_symbol} (Key: {key}) -> {roman}")

# 出力例:
# Dm7 (Key: C) -> IIm7
# G7 (Key: C) -> V7
# Cmaj7 (Key: C) -> IM7
# A7(b9) (Key: C) -> VI7(b9)
# Dm7 (Key: C) -> IIm7

主なクラスと機能

Romanizer

解析のメインクラスです。

  • annotate_progression(progression): コードのリストを受け取り、解析結果 (RomanizedChord) のリストを返します。リストの各要素は ParsedChord または (ParsedChord, Key) のタプルを受け付けます(転調に対応する場合)。

ChordParser

コードシンボル文字列を解析用オブジェクトに変換します。

  • parse(symbol_str): 文字列をパースして ParsedChord を返します。

RomanizedChord

解析結果を保持するデータクラスです。

  • roman: 最終的なローマ数字表記(例: IIm7, V7/VI)。
  • degree_root: ルートの度数(例: II, V)。
  • degree_bass: ベース音の度数(転回形の場合)。
  • is_hybrid: ハイブリッドコード(機能的な分数コード)として解釈されたかフラグ。
  • is_ii_v_start: ツーファイブ進行の起点(II)と判定されたか。
  • is_resolution_target: ドミナントモーションの解決先(I)と判定されたか。

ライセンス

MIT License

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

chord_romanizer-0.1.2.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

chord_romanizer-0.1.2-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file chord_romanizer-0.1.2.tar.gz.

File metadata

  • Download URL: chord_romanizer-0.1.2.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for chord_romanizer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6506e14d306120a86a29a1fa2f28443664d27f79cb6ce9e853466192159cf62b
MD5 3e01d00c3fed6b92dfbe76065f7820a5
BLAKE2b-256 b7a0f35b1f00b3b9484c8256c66d3decd0cd57455917cfc9afa3645c002a8594

See more details on using hashes here.

File details

Details for the file chord_romanizer-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for chord_romanizer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ab06bb48628088b4e09649cc3500840237eb4beae5f45eb74f254f82194384d2
MD5 887295d50f00250070f15381415865a7
BLAKE2b-256 d2383e6f36ca8ab97043322f60a2c31562dbb8c7911eab15a22cb296774db9ac

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