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.4.tar.gz (18.0 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.4-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chord_romanizer-0.1.4.tar.gz
  • Upload date:
  • Size: 18.0 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.4.tar.gz
Algorithm Hash digest
SHA256 ad6424096cd0910b18906fc2793647957389cf2766ef57f4ba573a17db42efb1
MD5 8d3798159fd2e41e2cb947b20fd62e4f
BLAKE2b-256 e43e462b1c8a8059b7e464480e50fb631fab521a14234bbbbd5eaca4166e1d2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chord_romanizer-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 076ea34c4e5242a96f81d9557fed017833a543c2687fce60774e70f7cbeed5ea
MD5 da26b3b08ad7d8b5751c6813868b5f9c
BLAKE2b-256 b98d07dc04f7d257a2a1cc57bd3634ccdce38afe811b4ccf436dc6b796a7d65c

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