top | item 44504676

Xenharmlib: A music theory library that supports non-western harmonic systems

208 points| retooth | 7 months ago |xenharmlib.readthedocs.io

19 comments

order

ksr|7 months ago

Fascinating. I'm working on many adjacent pieces myself - my name for this whole initiative is music-i18n because I see it as the equivalent of adding software layers to support world languages and locales - in this case musical ones.

I am especially interested to hear your plans / thoughts about the following:

- Supporting non-ET tunings

- Supporting tetrachords and other scale building blocks (like Arabic ajnas)

- Importing/exporting MusicXML

- Exporting to MIDI

Thanks!

retooth|7 months ago

Hi! I'll try to answer in order:

1. Just Intonation and non-linear temperaments are on the roadmap, but there are a couple of design problems I still have to figure out, mainly how to have a consistent definition of interval objects in regards to transposition if the distances between notes are uneven. It works nicely, if one uses multi-dimensional tunings, e.g. in a 5-Limit tuning with 3 dimensions every interval obtained from two notes can be applied to any other note as a measure of transposition distance, but once you reduce it to one dimension you can have two notes which form an interval that can not be applied to every note without reaching a note that is outside the temperament.

2. Tetrachords are already supported and can be easily defined using the scale object. There is no quartertone notation yet, but if you are happy with Up/Down Notation you can analyze arabic ajnas by using EDOTuning(24) as the base. Currently there is no pitch/note sequence object, so downward scale movement in maqams can not be properly defined, but if you are interested only in the harmonic qualities, scales should do.

3. MusicXML sadly does not have good support for non-12-EDO tunings. You can define quartertone accidentals by providing floats (like 0.5) as accidental values, but this gets increasingly difficult if you want to do anything other than 24-EDO. I looked into the MEI format as it supports at least turkish makam accidentals, but a more generalized semantic definition for arbitrary EDOs seems to be out of reach for the foreseeable future. One could however think of supporting MEI for a couple of tunings (like 24- or 53-EDO)

4. MIDI is also somewhat difficult. There is the MPE specification which allows individual note bending, however it is not supported by any python library as far as I can tell. One could try to hack something with channel pitch bends, but it would be limited to playing 16 notes at the same time.

I am still looking for contributors, so if you are interested in these things, feel free to contact me ;)

bntr|7 months ago

A bit tangential, but I recently made a xenharmonic-related library too - focused more on the visual/harmonic space side:

https://github.com/bntre/cs-rationals/blob/master/RationalsE...

Demo piece: https://www.youtube.com/watch?v=y_x4vtS_I7w

retooth|7 months ago

Oh, neat :) This looks really cool. In one of the upcoming versions of xenharmlib I am planning to add hooks for visualization plugins, so structures can be rendered in JupyterLab. Maybe you would be interested in contributing, however it will take some time before JI is supported.

bntr|7 months ago

My actual question: do you use xenharmlib for composing?

I assume this is your album: https://fabianvallon.bandcamp.com/album/a-different-path-for...

Was xenharmlib used in it, or some other software?

retooth|7 months ago

Yes, I do. For the actual score composition I used Ableton, but xenharmlib can export SCL files to define microtonal scales, which then can be imported in Ableton (a lot of other DAWs and VSTs support this format too).

For the most part however I use xenharmlib for theoretical aspects of music. I got interested in the "31 Equal Divisions per Octave" tuning a couple years ago, because of its psychoaccustic potentials, but thinking about chords, modes, notation in 31-EDO made my head hurt, so I built the library to help me think and answer my questions.

mkesper|7 months ago

Fantastic, my suggestion would be to rename to Xenharmoniclib, though. harmlib sounds...harmful? to me

userbinator|7 months ago

It would be a suitable name of a library for exploiting the Xen hypervisor.

retooth|7 months ago

Maybe I should double down and rename it "harmful" as in "full of harmonies" ;)

sim7c00|7 months ago

is there somethin similar in C++. this is really useful, but most VST etc. afaik get built in c++, i know for example JUCE framework to build em uses c++ so to me that seems a practical language for such a tool

(focussing on the last bit of the article mentioning it can be used in digital instruments / dsp. totally agree!)

retooth|7 months ago

Since xenharmlib is written in python it is not suitable for real-time audio because of the latency that an interpreted language introduces.

I think if someone was willing they could port the library to C or Rust rather easily, because apart from Exceptions the coding style is functional and stateless. AFAIK Rust has some libraries that provide a VST interface.

bhalahi|7 months ago

Does this include the socialist, communist, and banana republic dictatorial harmonic systems?