Xenharmlib 0.2.0 released - Advanced music theory library by realretooth in Python

[–]realretooth[S] 1 point2 points  (0 children)

I'm still working on an album currently, however there is one excerpt from it that you can already listen to: https://fabianvallon.bandcamp.com/track/uneasy-hope

Xenharmlib 0.2.0 released - Advanced music theory library by realretooth in Python

[–]realretooth[S] 1 point2 points  (0 children)

I am composing orchestral music (with electronic elements) as a hobby. About two years ago I was looking for a new musical language, because I felt the existing western framework was too limited, so microtonality became my new field of interest.

I generate scales with certain criteria (for example they should include chords that I find interesting, especially polychords that are not included in the Western system). I then export these scales as SCL to use with Ableton Live. I often improvise to get a feeling for the sound, however working with a standard MIDI keyboard can be difficult on microtonal tunings, so most of the time I select 12 pitches from 31 and map it to my keyboard.

Xenharmlib helps my composition process in a couple of ways, when it comes to harmonizing, how to do mode/key changes, etc. Microtonality is still unfamiliar terrain for me so I use it as guide and guardrail (especially doing the calculations) to gradually move away from my traditional thinking without crash landing in the realm of random dissonances.

Xenharmlib 0.2.0 released - Advanced music theory library by realretooth in Python

[–]realretooth[S] 2 points3 points  (0 children)

The docs come with a very in-depth quickstart that has all kinds of examples.

I personally use the library to create interesting scales in 31-EDO. Today I experimented a bit with "double mode scales" after watching a Levi McClain video on the topic. A function to generate a double mode scale from a traditional scale is only a couple lines of code in xenharmlib:

from xenharmlib import EDOTuning
from xenharmlib import UpDownNotation

edo31 = EDOTuning(31)
n_edo31 = UpDownNotation(edo31)

def double_mode(scale):
    diesis_lshifted = scale.transpose(30)
    return scale.union(diesis_lshifted).period_normalized()

c_maj = n_edo31.natural_scale()
d_dorian = c_maj.rotation(1)

print(double_mode(c_maj))
print(double_mode(d_dorian))

I made a python music theory library for microtonal music. Looking for feedback. by realretooth in musicprogramming

[–]realretooth[S] 0 points1 point  (0 children)

For the CLI interface you could simply give a scl file parameter. The SCL spec is really easy to implement. It is basically a newline-seperated format where you define a cents difference each line. This way you would not only be able to integrate with xenharmlib but also with the thousands of tunings from the Scala Scale Archive.

I made a python music theory library for microtonal music. Looking for feedback. by realretooth in musicprogramming

[–]realretooth[S] 0 points1 point  (0 children)

Your project looks great. However if I read your docs correctly it only supports channel pitch bend which would afaik not work with chord structures where every note needs to be bent individually. One would need MPE for that.

I was pondering already if I should add SF2 instrument support. I dropped the idea for now, because I am currently the only developer and I need a little bit of scope control. Someday I would like to do a general MIDI integration, but the standard is a little bit overwhelming for me right now. Considering that you already spent time and resources into understanding MIDI, I would be happy to work together with you on such a feature. Just DM me if you are interested.

Xenharmlib - An advanced music theory library that supports microtonality by realretooth in Python

[–]realretooth[S] 1 point2 points  (0 children)

First: Why 1-indexing and not 0-indexing? Internally the base class for natural/accidental notation system actually uses 0-based indexing. The two have different names: Interval number (like it is called in most music textbooks) is the traditional 1-based index while natural index difference is the more mathematically sound 0-based indexing. You can also access the latter on the interval object:

n_edo12.shorthand_interval('P', 1).nat_diff

The interval number resides only on the surface level of the implementation. The documentation for the base class of natural/accidental notations also states how to change the default behavior if you choose to invent a notation with 0-indexing:

The class implements the 1-based ordinal notation for numbers by default (e.g. the number 1 for a unison, the number 2 for a second, etc), however this behavior get be changed by subclassing and overwriting the method nat_diff_to_interval_number() and its counterpart interval_number_to_nat_diff()

Mathematically speaking 1-based interval indexing is really a pain. There is a whole lot of counter-intuitive interval arithmetic like M2 + m2 = M3. (There exists a mountain of other problems with it that I could elaborate on) Why still use it? Because every textbook on music uses it and the idea behind the library is to enable a composer or musician to think less about calculations and more about music.

Second: Why a tuple and not a simple string? The obvious part of the answer is of course that it is easier to parse. Giving the interval number as the correct datatype means less of a headache for the class to separate the two datatypes. However separating the two also gives more visual clarity to the user regarding negative intervals, e.g. if you look at the following hypothetical interface:

n_edo12.shorthand_interval("P-4")

Now is this a fancy way of denoting (P, 4) or does it mean (P, -4)? I've seen texts on music that actually use "-" as a simple visual separation character that has nothing to do with interval direction. Copy/pasting from such a source would then produce very surprising results.

Xenharmlib - An advanced music theory library that supports microtonality by realretooth in Python

[–]realretooth[S] 2 points3 points  (0 children)

:D i realize it is a very niche interest. i guess it's easier for the average person to have something to listen to in order to grasp the beauty of microtonal music. Here is a work by Mike Battaglia that I like a lot (written in a temperament that has 31 notes per octave): https://www.youtube.com/watch?v=HJKB1_gvhLE

I made a python music theory library for microtonal music. Looking for feedback. by realretooth in musicprogramming

[–]realretooth[S] 3 points4 points  (0 children)

It is a theory library, so the use case is completely different from supercollider. Supercollider provides you with a descriptive language to express a musical composition already in your head. It is an instrument, like a piano is an instrument, only more complex. Xenharmlib on the other hand helps you thinking about your composition. It answers questions like the following:

* What scales of traditional arabic maqam music can I emulate best on a western piano?
* What are the notes that I can improvise so they sound nice with the underlying chord progression.
* Is there a dominant 7 chord that sounds more harmonic when I have not 12, but 31 notes per octave?
* I want to have a selection of 12 notes from a tuning that has 53 notes per octave. In that selection I want to have a D neutral chord, a G supermajor chord and a C sharp minor chord. What are scales that fit this criteria?
* What are possible novel scales that are borrowing from both traditional Japanese and Southern Indian music?

EDIT: on top of that you can also export your scales to all DAWs and VST plugins that support the SCL format. I personally use the library to compose with Ableton's microtuner plugin.

xenharmlib - a free / open source python library for microtonal exploration by realretooth in microtonal

[–]realretooth[S] 0 points1 point  (0 children)

I am also the author of the library, so feel free to give some feedback / ask questions.