Here is a LUA function that loads a Scala .scl tuning file and returns a table of all 128 MIDI note frequencies in Hz. This functionality could easily be incorporated into tools or projects that want to explore alternate (ie. non-Western) tunings.
Speaking about my own projects, this would be a perfect candidate for the Native Synth and Tuned RingMod examples that I posted earlier. Sadly, it’s not yet possible to directly access to the LFO envelope points via scripting, so I cannot yet make a tool which generates the RingMod/LFO envelope automatically. I can still generate some XML that can be manually copied/pasted into the LFO Device, which is a bit cumbersome but at least it’s a start. I will post some code for that a little bit later.
If you’re looking for .scl files to test it with, there’s a huge archive (over 3900) on the Scala website:
Usage is pretty simple:
local base_note = 48 local base_frequency = 261.625565300598623000 local scl_filename = 'some_tuning.scl' local frequencies = scl_to_frequency_table(base_note, base_frequency, scl_filename)
The frequencies table would then contain 128 frequencies in Hz (indexed from 0 to 127 by default), ready to be used for whatever you have in mind.
- The first parameter sets the base note. In this example 48 refers to C-4.
- The second parameter sets the frequency that the base note should be tuned to. All other generated frequencies are based around this, so it’s very important to set it as precisely as possible, otherwise it could introduce tuning errors later. In this example C-4 would be tuned to Middle C.
- The third parameter sets the Scala .scl file that should be used. If the file cannot be opened for any reason, then the function will default to generating tunings for the standard ‘Western’ 12 tone equal temperament, so that you at least get something useful back.