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

Uploaded Python 3

File details

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

File metadata

  • Download URL: chord_romanizer-0.1.7.tar.gz
  • Upload date:
  • Size: 18.9 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.7.tar.gz
Algorithm Hash digest
SHA256 8a01bbfb927b78d2f3e510c0b043da49338a3fcf6adedab2a93fe46ae0cf099b
MD5 c17c1b8caee126f683052f91c4d84a28
BLAKE2b-256 c92cb3bcc7ae226ff280598c3a8fc32251a56edfd2c239d48f2ce68312ce7749

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chord_romanizer-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e65a1ff3f39e5d1b0bfbda98f1af878a84a93ec4a94881a50836ac752dfcf3f7
MD5 ba48b5e86c6ff8183ff61b6179f23ea5
BLAKE2b-256 ba8423091332e3417dd1d28cfda087361a3fbf4acb1c866f2b4684e2944f629f

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