To automate just intonation

• Dec 17, 2018 - 16:01

Fellow nerds,
Here is a script for tuning your files to five-limit just intonation. Probably a few of us wish that there was something like this built into the GUI, but the developers have been busy working on lots of awesome features like speeding up the app, unmetered music, higher quality samples, and sfz support. And they had the foresight to use XML, not some proprietary binary blob.
Caveats:
* Files must be uncompressed (mscx).
* I probably won't test and rework in Musescore 3 till it's available for production.
* This script only works for compositions with a root of A (e.g. A minor, A dorian, A harmonic minor). Let me know if you need a different root.
* Only run this on a copy that does not already have tuning information.

#!/bin/bash
sed -i 's|<tpc>29</tpc>|<tpc>29</tpc>\n\t\t\t<tuning>0</tuning>|g' $1
sed -i 's|<tpc>17</tpc>|<tpc>17</tpc>\n\t\t\t<tuning>0</tuning>|g' $1
sed -i 's|<tpc>5</tpc>|<tpc>5</tpc>\n\t\t\t<tuning>0</tuning>|g' $1
sed -i 's|<tpc>24</tpc>|<tpc>24</tpc>\n\t\t\t<tuning>11.73</tuning>|g' $1
sed -i 's|<tpc>12</tpc>|<tpc>12</tpc>\n\t\t\t<tuning>11.73</tuning>|g' $1
sed -i 's|<tpc>0</tpc>|<tpc>0</tpc>\n\t\t\t<tuning>11.73</tuning>|g' $1
sed -i 's|<tpc>31</tpc>|<tpc>31</tpc>\n\t\t\t<tuning>3.91</tuning>|g' $1
sed -i 's|<tpc>19</tpc>|<tpc>19</tpc>\n\t\t\t<tuning>3.91</tuning>|g' $1
sed -i 's|<tpc>7</tpc>|<tpc>7</tpc>\n\t\t\t<tuning>3.91</tuning>|g' $1
sed -i 's|<tpc>26</tpc>|<tpc>26</tpc>\n\t\t\t<tuning>15.64</tuning>|g' $1
sed -i 's|<tpc>14</tpc>|<tpc>14</tpc>\n\t\t\t<tuning>15.64</tuning>|g' $1
sed -i 's|<tpc>2</tpc>|<tpc>2</tpc>\n\t\t\t<tuning>15.64</tuning>|g' $1
sed -i 's|<tpc>33</tpc>|<tpc>33</tpc>\n\t\t\t<tuning>-13.69</tuning>|g' $1
sed -i 's|<tpc>21</tpc>|<tpc>21</tpc>\n\t\t\t<tuning>-13.69</tuning>|g' $1
sed -i 's|<tpc>9</tpc>|<tpc>9</tpc>\n\t\t\t<tuning>-13.69</tuning>|g' $1
sed -i 's|<tpc>28</tpc>|<tpc>28</tpc>\n\t\t\t<tuning>-1.96</tuning>|g' $1
sed -i 's|<tpc>16</tpc>|<tpc>16</tpc>\n\t\t\t<tuning>-1.96</tuning>|g' $1
sed -i 's|<tpc>4</tpc>|<tpc>4</tpc>\n\t\t\t<tuning>-1.96</tuning>|g' $1
sed -i 's|<tpc>23</tpc>|<tpc>23</tpc>\n\t\t\t<tuning>-17.49</tuning>|g' $1
sed -i 's|<tpc>11</tpc>|<tpc>11</tpc>\n\t\t\t<tuning>-17.49</tuning>|g' $1
sed -i 's|<tpc>-1</tpc>|<tpc>-1</tpc>\n\t\t\t<tuning>-17.49</tuning>|g' $1
sed -i 's|<tpc>30</tpc>|<tpc>30</tpc>\n\t\t\t<tuning>1.96</tuning>|g' $1
sed -i 's|<tpc>18</tpc>|<tpc>18</tpc>\n\t\t\t<tuning>1.96</tuning>|g' $1
sed -i 's|<tpc>6</tpc>|<tpc>6</tpc>\n\t\t\t<tuning>1.96</tuning>|g' $1
sed -i 's|<tpc>25</tpc>|<tpc>25</tpc>\n\t\t\t<tuning>13.69</tuning>|g' $1
sed -i 's|<tpc>13</tpc>|<tpc>13</tpc>\n\t\t\t<tuning>13.69</tuning>|g' $1
sed -i 's|<tpc>1</tpc>|<tpc>1</tpc>\n\t\t\t<tuning>13.69</tuning>|g' $1
sed -i 's|<tpc>32</tpc>|<tpc>32</tpc>\n\t\t\t<tuning>-15.64</tuning>|g' $1
sed -i 's|<tpc>20</tpc>|<tpc>20</tpc>\n\t\t\t<tuning>-15.64</tuning>|g' $1
sed -i 's|<tpc>8</tpc>|<tpc>8</tpc>\n\t\t\t<tuning>-15.64</tuning>|g' $1
sed -i 's|<tpc>27</tpc>|<tpc>27</tpc>\n\t\t\t<tuning>-3.91</tuning>|g' $1
sed -i 's|<tpc>15</tpc>|<tpc>15</tpc>\n\t\t\t<tuning>-3.91</tuning>|g' $1
sed -i 's|<tpc>3</tpc>|<tpc>3</tpc>\n\t\t\t<tuning>-3.91</tuning>|g' $1
sed -i 's|<tpc>22</tpc>|<tpc>22</tpc>\n\t\t\t<tuning>-11.73</tuning>|g' $1
sed -i 's|<tpc>10</tpc>|<tpc>10</tpc>\n\t\t\t<tuning>-11.73</tuning>|g' $1


Comments

In reply to by mike320

Thank you, Mike! It's wonderful that there's a solution for everybody. I used to use this plugin. It only tunes compositions with a root of C. To use the plugin with other roots, you need to transpose the whole composition to C and then back up or down. After doing that on dozens of scores, that was starting to feel like a lot of friction. With twelve shell scripts like the one above, I can tune a score in one step.

Then there's the transition to Musescore 3. I expect I'll be able to update my scripts with one or two shell commands after five minutes of looking at the new MSCX markup, whereas I looked at the guide to updating plugins and my eyes glazed over: https://musescore.org/en/handbook/plugins-30

I'm a musician, not a programmer. I like taking the path of least resistance and I'm grateful that you're all using a hackable plaintext format. But I appreciate your thought.

In reply to by andrewjosephpf…

Okay, if anyone's prowling the forums years after the fact as I do looking for a just intonation solution, I found this week by far the easiest just intonation solution (at least for me) is timidity: http://manpages.ubuntu.com/manpages/bionic/man1/timidity.1.html

Export a MIDI and run it through timidity with a -Zpure0m option (or change the number to whatever key you're using). Way easier than trying to wrangle tuning with scripts as it looks like I was doing a couple years ago.

Do you still have an unanswered question? Please log in first to post your question.