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

Uploaded Python 3

File details

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

File metadata

  • Download URL: chord_romanizer-0.1.3.tar.gz
  • Upload date:
  • Size: 17.2 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.3.tar.gz
Algorithm Hash digest
SHA256 9572ef1a9bf5288d81724dd432934902c0d9e7f9dd112cd6416fa225973ab8c1
MD5 bdda97ed235158a4dbabf80a64badba8
BLAKE2b-256 fb4e16afad77fb109d45746c97003f3e9f075a19f04861ea57372b3704ab1182

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chord_romanizer-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5f840a58fb685f63758980dbad695576352a44d25ac061b5e022cc06e5418922
MD5 3f4e7e0f0992c6eec8be2890f93e9fcd
BLAKE2b-256 e098551700c2b0e2cc4213a1bf59202ca98dc1a26c573bcca6dddbb948911858

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