# xen-calc

xen-calc is my attempt at a general purpose calculator/converter for microtonal music, inspired by (and intended to combine the features of) untwelve's interval calculator, the Harmonic Space Calculator, misotanni's FJS Calculators, and the "Interval Information" info boxes on the Xenharmonic wiki.

Under the hood, all calculations are done using my microtonal-utils javascript library. You can also find the latest version of this page's source code on Github.

If you find any bugs or want to request a feature, make an issue on Github! If you have a question or just want to share an idea, try out Github discussions.

To get started, check out some examples or browse the list of features below. Everything wrapped in a tan box (e.g. P5) is a possible input to xen-calc, and can be clicked on.

### Features

This calculator can:

• Convert between cents (e.g. 400c), just ratios (e.g. 5/4), EDO steps (e.g. 4\12, meaning "four steps of 12-EDO"), monzos (e.g. [-2, 0, 1>), intervals in FJS notation (e.g. M3^5), intervals in Neutral FJS notation (e.g. n3^11), intervals in color notation (e.g. y3 or yo 3rd), and intervals in ups-and-downs notation (e.g. vM3\22 or downmajor 3rd \ 22).
• Multiply (*), divide (/), and exponentiate (^) just ratios (e.g. 64/63 * (9/8)^2) as well as intervals in EDO step, monzo, (N)FJS, color, and ups-and-downs notation (e.g. 3/2 * M3^5, m3\22 / m3^7, (M3^5)^2).
• Add (+), subtract (-), and scale (x) cents values (e.g. 27.3c + 2 x 100c) as well as intervals in EDO step, monzo, (N)FJS, color, and ups-and-downs notation (e.g. 700c + M3^5, m3\22 - m3^7, 2 x M3^5).
• Combine all of the above with notes:
• Convert between hertz (e.g. 370Hz), notes in FJS notation (e.g. F♯^5), notes in color notation (e.g. yF♯), and notes in ups-and-downs notation (e.g. vF♯\22).
• Multiply (*) a note in hertz, FJS, color, or ups-and-downs notation by a just interval or an interval in EDO step, monzo, (N)FJS, color, or ups-and-downs notation (e.g. C4 * 5/4, Ab\22 * M2^5).
• Add (+) a note in FJS, color, or ups-and-downs notation with a cents value or an interval in EDO step, monzo, (N)FJS, color, or ups-and-downs notation (e.g. C4 + 400c, Ab\22 + M2^5).
• Divide (/) two notes in hertz, FJS, color, or ups-and-downs notation to get an interval (e.g. E4^5 / C4) or subtract (-) two notes in FJS, color, or ups-and-downs notation to get an interval.
• Set a reference note and tuning (e.g. C4 where A = 432hz) or set a reference note with automatically chosen tuning (e.g. F♯\12 / D where D = D\12).
• List possible English names for an interval. These names are automaticlly generated based on the interval's Neutral FJS name or ups-and-downs notation, e.g. "undecimal neutral third" for n3^11 or "24-EDO neutral third" for ~3\24. Names are also automatically generated for harmonics, e.g. "15th harmonic" for 15/1, and there are special cases for the Pythagorean comma (d-2) and phi (phi). See english.js in microtonal-utils for the exact algorithm.
• Play intervals and notes (using the synth from Sevish's Scale Workshop).
• List best rational approximations of an interval, with options to set the prime limit and odd limit. The results can be sorted by Tenney height, no-2s Tenney height (where all factors of 2 are removed before computing the height), the denominator of the ratio, or by the ratio's cents difference. Tenney height and no-2s Tenney height can be thought of as measures of a ratio's harmonic complexity (or dissonance). The latter is selected by default, since I find it often gives the most familiar results. For example, the results for M3\12 and m3\12 are exactly the corresponding 5-limit and 3-limit thirds when sorting by no-2s Tenney height. I find both of these sorts give better results than sorting by denominator, though the latter is closest to the output of untwelve's interval calculator (untwelve's output also includes semi-convergents which are not best approximations).
• List best EDO approximations of an interval. The results can be sorted by EDO or by cents difference.
• Solve for intervals in isoharmonic or linear chords (e.g. 4 : 5 : ?, 1 : ? : sqrt(5)). Only two intervals are needed to define an isoharmonic/linear chord, the rest can be left as dashes (e.g. 1 : - : ? : 5/4). As alternate notation, there are the functions isoUp (e.g. isoUp(5/4), which is 1 : 5/4 : ?), isoDown (e.g. isoDown(5,6), which is ? : 5 : 6), and isoMid (e.g. isoMid(sqrt(5)), which is 1 : ? : sqrt(5)), each of which can take one or two arguments. There is also the function iso which generalizes all of them (e.g. iso(5/4,2)), iso(5,6,-1)), iso(sqrt(5),1/2))). The solution to 1 : ? : sqrt(5) is phi.
• Compute a number of useful functions:
• Get information about EDOs (e.g. 22-EDO) including interactive tables of prime mappings, intervals, and rational approximations. The rational approximations shown in the table of intervals are constrained by the value of the relative cutoff set in the prime mappings section. In particular, this value determines the highest prime power which can appear in an approximation. For example, in 22-EDO the prime 3 has a relative error of 13.1%. If we set our relative cutoff to 33.3%, a factor of 3 can appear, as can 32 (having a relative error of 26.2% < 33.3%), but 33 cannot (having a relative error of 39.3% > 33.3%). Thus, in this example 3/2 and 9/8 would appear in the interval table as rational approximations, but 32/27 would not. Rational approximations are loaded in the order of their no-2s Tenney height (see above), and listed in order of difference. Additionally, only intervals which are consistent in the chosen prime limit are shown.

### Tips

Here are a few useful tips:

1. For accidentals, you can either click the 𝄫/♭/♮/♯/𝄪 buttons below the main input field to insert the chosen symbol at your current cursor position, or use their non-unicode counterparts: bb, b, nat, #, X.
2. A4 is always interpreted as an augmented fourth interval, not the A note above middle C. To type the latter, use A♮4 or Anat4 (or in this case, just A works). The same goes for A3 vs. A♮3, etc.
3. There are two types of expressions that this calculator understands: multiplicative expressions, which are written using *, /, ^ and can contain just intervals, and additive expressions, which are written using +, -, x and can contain cents values. At the moment these two types of expressions cannot be mixed. By using the "cents" function on just ratios and replacing every "*" with a "+", every "/" with a "-", and every "^" with a "x", every multiplicative expression can also be written additively. For example, 3/2 / (M2)^2 * P1^7 and cents(3/2) - 2 x M2 + P1^7 represent the same interval. (The "^7" does not change in this example because it is an FJS accidental, not exponentiation.) By replacing cents values with fractional powers of two with denominator 1200, i.e. replacing 250c with 2^(250/1200), and reversing all the replacements above, every additive expression can also be written multiplicatively.
4. If all the parts of an additive expression are in the same EDO, you can avoid duplication by using parentheses, e.g. 2 x M3\22 + m2\22 - 2\22 and (2 x M3 + m2 - 2)\22 represent the same interval. You can also do the same for multiplicative expressions, so long as they do not contain any intervals in EDO step notation, e.g. (M3\22)^2 * m2\22 and ((M3)^2 * m2)\22 represent the same interval.
5. You can exponentiate (^) or scale (x) by fractional values to equally divide intervals, e.g. 2^(1/12), P8 x 1/12, and 1\12 all represent the same interval. For multiplicative expressions, you can also use nth root notation, e.g. root12(2), sqrt(3/2).
6. Certain intervals have FJS and Neutral FJS symbols which conflict. For example, M7^11,11 interpreted as an FJS symbol gives 264627/131072, but interpreted as a NFJS symbol gives 121/64. Such symbols are always interpreted as FJS symbols unless wrapped in "NFJS", as in NFJS(M7^11,11).

### Examples

Here are a few examples of ways you can use this tool:

1. Interval info: Entering 9/7 (the septimal major third) we get back that it its size is roughly 435 cents, we get that its FJS symbol is M3_7, we can confirm its English name, and we can listen to how it sounds. We get similar info for EDO step intervals (e.g. 2\5) and FJS symbols.

2. Checking interval arithmetic:

• We can confirm that a minor second plus a major third is a perfect fourth: m2 + M3.
• We can also confirm things specific to 12-EDO, like the fact that two major thirds is a minor sixth: (2 x M3)\12. Note that without the "\12", we get the equally correct answer of an augmented fifth.
3. Suppose we wanted to find just ratios for a neutral third. (The Wikipedia page for neutral third can tell us, but suppose we want to figure it out ourselves.) A neutral third is an interval roughly halfway between a major third and minor third, so I would start by typing in something like 1/2 x (M3 + m3)*. This will give us the interval "halfway between" M3 and m3 in the same way that 1/2 x (3 + 4) gives us the number halfway between 3 and 4.

After entering that expression, the "Best Rational Approximations" section gives us our answers. The first result, 5/4, is definitely not a neutral third and is off by 35 cents, but the rest are all known neutral thirds, at least according to the Xenharmonic wiki. The simplest two of these, 11/9 and 16/13, are listed on Wikipedia. By default, these intervals are sorted by Tenney height, which is a measure of their harmonic complexity, but they can also be sorted by their cents difference, giving us a more complete list.

* It is worth noting that we can also write this same expression multiplicatively as (M3 * m3)^(1/2), which is a hint for why the calculator says both expressions are equal to sqrt(3/2). Another thing to notice is that we also get the same expression if we replace the Pythagorean M3 and m3 with any pair of corresponding major and minor thirds, for example the septimal major third (9/7 or M3_7) and the septimal minor third (7/6 or m3^7), or the 12-EDO major third (M3\12) and the 12-EDO minor third (m3\12).

4. The following is a quote from the fantastic Youtube video Analyzing The Saxophone Solo From Dolphin Shoals (at 8:34).

Another example of stepping outside of the written harmony is at the climax of the solo, where Katsuta wails on this high G flat over the B flat sus and E flat major chords. It's actually not quite a G flat, it's kind of halfway between a G flat and a G natural. This kind of third that's halfway between a major third and a minor third is called a blue note after its extensive use in the blues genre.

The Wikipedia page for blue note, seems to suggest that this blue "lowered third" ought to be around 6/5, or possibly somewhere in the neutral third range when slurred with 5/4.

So what interval does Katsuta actually play? I used a spectrum analyzer (specifically Sonic Visualizer, but any will do) and found that this note starts at around 1500Hz, stays at 1513Hz for a good chunk of the middle, and ends at around 1520Hz. I also checked a couple of other notes and it seems like the piece is otherwise in standard tuning (A = 440Hz). To find what intervals these notes correspond to in the key of E flat, we need to take the ratio of these frequencies to an (equally-tempered) E flat. We can then either wrap the whole thing in "red()" to octave-reduce the interval, or just make sure to compare the note to an E flat in the right octave, in this case Eb6\12.

• At the start, Katsuta plays roughly the interval 1500Hz / Eb6\12, which is not too far from 6/5.
• By the end, and in certain peaks, he plays roughly the interval 1520Hz / Eb6\12, which is almost exactly 11/9, a neutral third.
• But for most of the note, he plays roughly the interval 1513Hz / Eb6\12. If you type this in yourself, it might seem like this interval is not close to any nice ratio. This is because, by default, all the best rational approximations shown are in the 13-limit, meaning no prime factors greater than 13 are allowed. If you increase this prime limit from 13-limit to to 17-limit (as I did for the link above) one finds that this interval is almost exactly 17/14. This ratio is notable for being the mediant of 6/5 and 11/9, which, in this case, means it is the simplest just ratio which lies between the two.

That being said, I have no idea if 17/14 is actually a simple enough interval to be played on a saxophone. Personally, I suspect its appearance here is a coincidence - perhaps just because it is quite close to sqrt(6/5 * 11/9), the halfway point between 6/5 and 11/9.

So, I conclude that Katsuta's blue note is a slur between 6/5 and 11/9 which lingers mostly halfway between the two. I suspect others will come up with different answers or interpretations - so try the whole experiment yourself!

### Privacy

This site keeps count of how many queries are made each day, how many queries of each type are made each day (e.g. queries which are monzos, queries which are in color notation, etc.), how many new page loads happen each day, and how many times each class of error is raised (e.g. "Parse Error", "Error", etc.). This is to get a sense of how much this tool is getting used and which parts of it are being used the most. At the moment, the different values of the javascript referrer property are also logged each day. This is to get a sense of where visitors are coming from.

Exact queries are never tracked or saved, nor will they ever be. No personal identifying information is tracked or saved, nor will any ever be. This site does not use cookies.

All the counts mentioned above can be viewed on the stats page.