Skip to main content

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

Project description

Chord Romanizer

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

特徴

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

インストール

現在のところ、PyPIには公開されていません。リポジトリをクローンしてプロジェクトに含めてください。

git clone https://github.com/your-username/chord-romanizer.git

クイックスタート

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.1.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.1-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chord_romanizer-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 51ced36796e3acb95c7f41815af4cf874349ed55002c5adcb590f90a4b486903
MD5 522f5149d134f73c53ad0487200ccdda
BLAKE2b-256 29ca324b2de3e2df18804011ee0f4b40db5d9f89d69d34ae681600c87da01f06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chord_romanizer-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7d01844cd8aff0693b7c27a4ec4c8c1ea5c2fd526d2fa2c5c4576916bf9864c1
MD5 f04f22730e0e643205e3f4bf4dcdaea1
BLAKE2b-256 949f5fe1e56f877e92e188eb906eca479ddff9eb5592d0d21efc066fcb3b5b47

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