User:Ganaram inukshuk/Code: Difference between revisions

Ganaram inukshuk (talk | contribs)
Added the moscalc program I made some time back
Ganaram inukshuk (talk | contribs)
Added code link for JIRAF (short for JI ratio finder)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page is for xen-related programming projects that I've made but don't have an exact place on the wiki (yet).
This page is for xen-related programming projects that I've made but don't have an exact place on the wiki (yet).


== Mosfinder Program (C++) ==
== Mosfinder (C++) ==
I wrote a crude C++ program for finding all of the mosses for a given edo.
I wrote a crude C++ program for finding all of the mosses for a given edo.


Line 582: Line 582:
</syntaxhighlight>
</syntaxhighlight>


== Mosfinder Macro for Microsoft Excel (Visual Basic for Applications) ==
== Mosfinder (VBA) ==
Based on the C++ mosfinder and further experiments with copy-pasting tables from Excel and into the wiki editor, I ended up writing an Excel macro that's basically a port of the C++ mosfinder, with basic formatting for a table. The latest version has two versions of the same macro where one skips step visualization and lists the steps as a list of numbers. This version was created due to concerns of larger edos' step visualizations being harder to copy and paste.
Based on the C++ mosfinder and further experiments with copy-pasting tables from Excel and into the wiki editor, I ended up writing an Excel macro that's basically a port of the C++ mosfinder, with basic formatting for a table. The latest version has two versions of the same macro where one skips step visualization and lists the steps as a list of numbers. This version was created due to concerns of larger edos' step visualizations being harder to copy and paste.


Line 2,042: Line 2,042:
|}
|}


== Moscalc program ==
== Moscalc ==
This is a program that finds a string representing a mos xL ys in its brightest mode, given only x and y.
This is a program that finds a string representing a mos xL ys in its brightest mode, given only x and y.


Line 2,142: Line 2,142:
  LLLLLLsLLLLLs - 11L 2s
  LLLLLLsLLLLLs - 11L 2s
  LLLLLLLLLLLLs - 12L 1s
  LLLLLLLLLLLLs - 12L 1s
== Moscalc and modecalc (Python) ==
This is a Python port of the aforementioned Moscalc program written in C++. This is accompanied by a Modecalc program that finds a scale's modes, the intervals for those modes, and the scale degrees for those modes.
Source code: https://gist.github.com/GanaramInukshuk/3b09f806573ecd90745d1d7fad11abdc
Example output for 3L 4s:
Scale modes sorted by modal brightness:
----------  ---  ------  ------  ------  ------  ------  ------  ------  ------
Modestring  UDP  0-step  1-step  2-step  3-step  4-step  5-step  6-step  7-step
LsLsLss    0|6  0      L      L+s    2L+s    2L+2s  3L+2s  3L+3s  3L+4s
LsLssLs    1|5  0      L      L+s    2L+s    2L+2s  2L+3s  3L+3s  3L+4s
LssLsLs    2|4  0      L      L+s    L+2s    2L+2s  2L+3s  3L+3s  3L+4s
sLsLsLs    3|3  0      s      L+s    L+2s    2L+2s  2L+3s  3L+3s  3L+4s
sLsLssL    4|2  0      s      L+s    L+2s    2L+2s  2L+3s  2L+4s  3L+4s
sLssLsL    5|1  0      s      L+s    L+2s    L+3s    2L+3s  2L+4s  3L+4s
ssLsLsL    6|0  0      s      2s      L+2s    L+3s    2L+3s  2L+4s  3L+4s
----------  ---  ------  ------  ------  ------  ------  ------  ------  ------
Scale modes sorted by cyclic permutational order (starting at brightest mode):
----------  ---  ------  ------  ------  ------  ------  ------  ------  ------
Modestring  CPO  0-step  1-step  2-step  3-step  4-step  5-step  6-step  7-step
LsLsLss    0    0      L      L+s    2L+s    2L+2s  3L+2s  3L+3s  3L+4s
sLsLssL    1    0      s      L+s    L+2s    2L+2s  2L+3s  2L+4s  3L+4s
LsLssLs    2    0      L      L+s    2L+s    2L+2s  2L+3s  3L+3s  3L+4s
sLssLsL    3    0      s      L+s    L+2s    L+3s    2L+3s  2L+4s  3L+4s
LssLsLs    4    0      L      L+s    L+2s    2L+2s  2L+3s  3L+3s  3L+4s
ssLsLsL    5    0      s      2s      L+2s    L+3s    2L+3s  2L+4s  3L+4s
sLsLsLs    6    0      s      L+s    L+2s    2L+2s  2L+3s  3L+3s  3L+4s
----------  ---  ------  ------  ------  ------  ------  ------  ------  ------
Scale degrees for each mode (modes sorted by modal brightness):
----------  ---  -----  -----  -----  -----  -----  -----  -----  -----
Modestring  UDP  0-deg  1-deg  2-deg  3-deg  4-deg  5-deg  6-deg  7-deg
LsLsLss    0|6  0      1      1      1      1      1      1      0
LsLssLs    1|5  0      1      1      1      1      0      1      0
LssLsLs    2|4  0      1      1      0      1      0      1      0
sLsLsLs    3|3  0      0      1      0      1      0      1      0
sLsLssL    4|2  0      0      1      0      1      0      0      0
sLssLsL    5|1  0      0      1      0      0      0      0      0
ssLsLsL    6|0  0      0      0      0      0      0      0      0
----------  ---  -----  -----  -----  -----  -----  -----  -----  -----
Scale degrees for each mode (modes sorted by cyclic permutational order):
----------  ---  -----  -----  -----  -----  -----  -----  -----  -----
Modestring  CPO  0-deg  1-deg  2-deg  3-deg  4-deg  5-deg  6-deg  7-deg
LsLsLss    0    0      1      1      1      1      1      1      0
sLsLssL    1    0      0      1      0      1      0      0      0
LsLssLs    2    0      1      1      1      1      0      1      0
sLssLsL    3    0      0      1      0      0      0      0      0
LssLsLs    4    0      1      1      0      1      0      1      0
ssLsLsL    5    0      0      0      0      0      0      0      0
sLsLsLs    6    0      0      1      0      1      0      1      0
----------  ---  -----  -----  -----  -----  -----  -----  -----  -----
Instructions for how to read the output:
* A scale's modes are rotations of a scale, represented as a string. These are sorted in two different ways: modal brightness and cyclic permutational order.
* A scale's intervals are a substring of a mode's scalestring. Since the order of steps doesn't matter in an interval, the sum of steps is shown in the table instead.
* Scale degrees are generally described with terms such as major, minor, augmented, diminished, and perfect. Here, they're enumerated in decreasing order based on size, where larger enumerations denote larger intervals (and therefore larger scale degrees). Perfect intervals, such as the unison and octave, always appear as one size each, and so their scale degrees are always perfect. The other scale degrees that are described as perfect come from the generating intervals (such as the perfect 5th and perfect 4th); these usually apply for moment-of-symmetry scales. A perfect 5th is described as perfect because it appears as that size in all but one mode (the locrian mode, where it's a diminished 5th instead), and a perfect 4th is described as perfect because it appears as that size in all but one mode (then lydian mode, where it's an augmented 4th instead).
* Intervals and scale degrees are enumerated starting at 0 rather than 1.
=== Update (Nov 2022) ===
There is now an option to output a mos table as one consolidated table using the MosModecalcOnetable() function. Note that MosModecalc() can output this as two separate tables (one for mossteps and one for mosdegrees). Example output below (may be too wide on some screens).<syntaxhighlight>
Mode    UDP    Mode name      Rotational order  smiunison (0-smidegree)    1-smistep (1-smidegree)    2-smistep (2-smidegree)    3-smistep (3-smidegree)    4-smistep (4-smidegree)    5-smistep (5-smidegree)    6-smistep (6-smidegree)    smioctave (7-smidegree)
-------  -----  -----------  ------------------  -------------------------  -------------------------  -------------------------  -------------------------  -------------------------  -------------------------  -------------------------  -------------------------
LLsLsLs  6|0    Mode 1                        0  0 (perfect)                L (major)                  2L (augmented)            2L+s (major)              3L+s (major)              3L+2s (perfect)            4L+2s (major)              4L+3s (perfect)
LsLLsLs  5|1    Mode 2                        5  0 (perfect)                L (major)                  L+s (perfect)              2L+s (major)              3L+s (major)              3L+2s (perfect)            4L+2s (major)              4L+3s (perfect)
LsLsLLs  4|2    Mode 3                        3  0 (perfect)                L (major)                  L+s (perfect)              2L+s (major)              2L+2s (minor)              3L+2s (perfect)            4L+2s (major)              4L+3s (perfect)
LsLsLsL  3|3    Mode 4                        1  0 (perfect)                L (major)                  L+s (perfect)              2L+s (major)              2L+2s (minor)              3L+2s (perfect)            3L+3s (minor)              4L+3s (perfect)
sLLsLsL  2|4    Mode 5                        6  0 (perfect)                s (minor)                  L+s (perfect)              2L+s (major)              2L+2s (minor)              3L+2s (perfect)            3L+3s (minor)              4L+3s (perfect)
sLsLLsL  1|5    Mode 6                        4  0 (perfect)                s (minor)                  L+s (perfect)              L+2s (minor)              2L+2s (minor)              3L+2s (perfect)            3L+3s (minor)              4L+3s (perfect)
sLsLsLL  0|6    Mode 7                        2  0 (perfect)                s (minor)                  L+s (perfect)              L+2s (minor)              2L+2s (minor)              2L+3s (diminished)        3L+3s (minor)              4L+3s (perfect)
</syntaxhighlight>The same output can be formatted as a wikitable. Other table features (such as sorting) may require additional edits.
{| class="wikitable sortable" style="text-align: left;"
|+Modes of 4L 3s (smitonic)
|-
! Mode    !! UDP                  !! Mode name  !! align="right"|  Rotational order !! smiunison (0-smidegree)  !! 1-smistep (1-smidegree)  !! 2-smistep (2-smidegree)  !! 3-smistep (3-smidegree)  !! 4-smistep (4-smidegree)  !! 5-smistep (5-smidegree)  !! 6-smistep (6-smidegree)  !! smioctave (7-smidegree)
|-
| LLsLsLs || 6<nowiki>|</nowiki>0 || nerevarine  || align="right"|                  0 || 0 (perfect)              || L (major)                || 2L (augmented)            || 2L+s (major)              || 3L+s (major)              || 3L+2s (perfect)          || 4L+2s (major)            || 4L+3s (perfect)
|-
| LsLLsLs || 5<nowiki>|</nowiki>1 || vivecan    || align="right"|                  5 || 0 (perfect)              || L (major)                || L+s (perfect)            || 2L+s (major)              || 3L+s (major)              || 3L+2s (perfect)          || 4L+2s (major)            || 4L+3s (perfect)
|-
| LsLsLLs || 4<nowiki>|</nowiki>2 || lorkhanic  || align="right"|                  3 || 0 (perfect)              || L (major)                || L+s (perfect)            || 2L+s (major)              || 2L+2s (minor)            || 3L+2s (perfect)          || 4L+2s (major)            || 4L+3s (perfect)
|-
| LsLsLsL || 3<nowiki>|</nowiki>3 || sothic      || align="right"|                  1 || 0 (perfect)              || L (major)                || L+s (perfect)            || 2L+s (major)              || 2L+2s (minor)            || 3L+2s (perfect)          || 3L+3s (minor)            || 4L+3s (perfect)
|-
| sLLsLsL || 2<nowiki>|</nowiki>4 || kagrenacan  || align="right"|                  6 || 0 (perfect)              || s (minor)                || L+s (perfect)            || 2L+s (major)              || 2L+2s (minor)            || 3L+2s (perfect)          || 3L+3s (minor)            || 4L+3s (perfect)
|-
| sLsLLsL || 1<nowiki>|</nowiki>5 || almalexian  || align="right"|                  4 || 0 (perfect)              || s (minor)                || L+s (perfect)            || L+2s (minor)              || 2L+2s (minor)            || 3L+2s (perfect)          || 3L+3s (minor)            || 4L+3s (perfect)
|-
| sLsLsLL || 0<nowiki>|</nowiki>6 || dagothic    || align="right"|                  2 || 0 (perfect)              || s (minor)                || L+s (perfect)            || L+2s (minor)              || 2L+2s (minor)            || 2L+3s (diminished)        || 3L+3s (minor)            || 4L+3s (perfect)
|}
== JIRAF (C++) ==
JI ratio finder, possibly reverse-engineered from other already-existing algorithms.
Source code: https://gist.github.com/GanaramInukshuk/b010ff8c29cd03c13b84f1b504efce62<syntaxhighlight line="1">
Approximated ratios for 1\16 (75c):
19/18 = 93.6031
20/19 = 88.8008
Approximated ratios for 2\16 (150c):
11/10 = 165.004
12/11 = 150.637
13/12 = 138.573
Approximated ratios for 3\16 (225c):
8/7 = 231.174
17/15 = 216.687
Approximated ratios for 4\16 (300c):
6/5 = 315.641
13/11 = 289.21
19/16 = 297.513
20/17 = 281.358
Approximated ratios for 5\16 (375c):
5/4 = 386.314
16/13 = 359.472
Approximated ratios for 6\16 (450c):
9/7 = 435.084
13/10 = 454.214
17/13 = 464.428
Approximated ratios for 7\16 (525c):
15/11 = 536.951
19/14 = 528.687
Approximated ratios for 8\16 (600c):
7/5 = 582.512
10/7 = 617.488
17/12 = 603
Approximated ratios for 9\16 (675c):
19/13 = 656.985
Approximated ratios for 10\16 (750c):
14/9 = 764.916
17/11 = 753.637
20/13 = 745.786
Approximated ratios for 11\16 (825c):
8/5 = 813.686
13/8 = 840.528
Approximated ratios for 12\16 (900c):
5/3 = 884.359
17/10 = 918.642
Approximated ratios for 13\16 (975c):
7/4 = 968.826
Approximated ratios for 14\16 (1050c):
11/6 = 1049.36
20/11 = 1035
Approximated ratios for 15\16 (1125c):
19/10 = 1111.2
End of program reached.
</syntaxhighlight>