Skip to content

Repository files navigation

AHM-EmoChoard — Affective Harmony Machine

A dataset, training pipeline, and native Csound opcode for emotion-driven chord progression generation using machine learning.

emoChord is a Csound plugin opcode that takes an emotion string at i-rate, runs a Random Forest classifier via the ONNX Runtime C API inside the Csound process, and schedules chord events into any synthesis instrument — no Python, no external process at runtime.


Dataset

Source Progressions Rows Coverage
Jazz 25 1,200 12 keys × 4 voicings
Pop 83 996 12 keys
Combined 108 2,196 —
  • 6 emotion classes: Joyful, Vital, Epic, Uneasiness, Depressive, Despair
  • 7 scale/mode categories: Ionian, Aeolian, Dorian, Phrygian, Lydian, Mixolydian, Harmonic minor

Dataset files:

  • jazz_harmony_ml_dataset.csv — jazz progressions with 4 voicing styles per key
  • pop_harmony_dataset.csv — pop progressions across 12 keys
  • emotion_tags.csv — master emotion/scale annotation reference

How to train

pip install scikit-learn optuna skl2onnx onnxruntime pandas numpy
python train_model.py

Outputs to Csound/opcode/:

  • gen_model.onnx — Random Forest classifier (input: [emotion_id, scale_id], output: probabilities [1, 108])
  • gen_data.tsv — chord name lookup table (1,296 rows)

Csound opcode

See Csound/opcode/README.md for build instructions and full opcode reference.

Minimal usage:

<CsInstruments>
emoChord_init "/path/to/gen_model.onnx", "/path/to/gen_data.tsv"

instr 1  ; p4 = emotion string
  Sem strget p4
  emoChord Sem, 2, p2, p3, 0.7
endin
</CsInstruments>
<CsScore>
i1   0   4  "joyful"
i1   6   4  "depressive"
i1  12   4  "uneasiness"
e
</CsScore>

Requirements

  • macOS (arm64 native or x86_64 via Rosetta)
  • Csound 6.x
  • Python 3.10+ (training only)

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages