Snippet: Load Scala .Scl Tuning File

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:
http://www.huygens-fokker.org/docs/scales.zip

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.
    Download:
    3874 Scala.lua

I like where this is going :w00t:

:yeah:

I thought you might :)

Mm, could this somehow generate new pitchbend values to fit alternative tuning (maybe even in realtime)? Apparently there’s a MIDI plugin which does this.

Like: MIDI data in -> pitchbend to fit notes to alternative tuning -> notes+controls+pitchbend to plugin?

Anyone using this in a next version of their tool?

I hope this is being looked at for the ‘plugin grabber’ / render plugin to instrument function :)

Hi

I’ve been waiting for something like this for a couple of years now:)

Downloaded your file… Now, what do I do with it?

Can I use this with instruments, samples and vsti? or what?

Sorry, but I have never used a .LUA file before and didn’t find anything useful by googeling it…

Thanks

I’m sorry to disappoint you, but in its current form this bit of code doesn’t really do very much. It’s not possible to just plug this into Renoise and then get microtuning capabilities for samples and VSTs. Its only purpose is to load a Scala tuning file and then generate a table of note frequencies that represents all 128 MIDI notes. I simply posted it here so that other developers could learn from it, in case they wanted to add this type of functionality to their own Renoise tools in the future.

I see. Any chance they can/will implement it into Renoise directly?
If not, is there a place where I could have it custom made?
If not, where can I learn to make a Tool myself? (Been waiting and hoping for far too long now.)

Hi, Im learning about tuning and scala. Do you know hot to change the base frequency in scala?
I go to freq, change the number and save. But when I reload it, the frequency is the same as before 261.6
I need to learn this! : )

Could you give a few more details about what you’re trying to do here? When you say “I go to freq, change the number and save.” what exactly are you referring to? Which file are you editing?

Anyway, the strange thing is that I’ve never actually used Scala to generate any tunings myself, so I’m not familiar at all with how the program works or how you would configure it. I just based my code above on the .scl file format and then used a few .scl files to test it.

Oh, I thought you were a scala user. In scala theres a option to change the “base frequency”, by default 261 hz. But this thing doesn’t change the file, when you close it, the original freq remains.
I want to change the base frequency.
Besides that, I have another problem. Im using scala files in tobybear microtuner for sending this info to the instruments (vsts), but testing it with a tuner, I saw that the freqs are bad (in scala you can see the intervals AND the freqs of all notes). I think this is a problem of the microtuner.

Yes there is. one of the reasons I want to be able to route a VSTs MIDI output around inside Renoise…

Thats what tobybear´s microtuner does, alternate tuning with pitch bends. For a lot of reasons is very useful to route midi outs (and ins)

Was hoping to see an load .scl/.tun file implementation this update, in the new instrument settings / sample tab, right underneath the sync and t button there still is room left :wink: . Have faith it will happen eventually.

I’ve been waiting for real microtuning options in Renoise literally for years now… The Finetune option in renoise is just sad…
I’m currently looking elsewhere for an other solution. Hopefully they implement it soon!!!

i guess it’s quite a bit of work to really do full blown support for microtonal tunings. must be some way to select a symbol to represent each newly defined note and a way to handle number of notes per octave etc.

would be awesome though if done properly! (=

I’m already happy if Dblue’s code is made useful in some scripts. Being able to automatically convert a multi sample instrument tuning according to a .scl/.tun file doesn’t need symbolic representation or other visual candy to be useful imo, just auto transform the transpose & fine-tuning values, somewhat like that little t button does now next to sync but for all samples respectively.

yes, not trying to take anything away from him here ofc! (=

i’m just excited at the prospect of renoise going microtonal! alphanumeric representation of notes is perfect for handling non-standard tunings in contrast with having a pianoroll type of representation.

Thats very true!
The problem is if we want to control it via MIDI, in that case we have 128 notes (nothing bad)

The only “universal” way to address notes I can really think of is by frequency, but since that’s completely impractical and unmusical, addressing notes by alphanumeric name works.

Somewhat less on-topic:

As my current soundtrack is partially microtonal, I’ve been thinking more and more about starting a centralized feature-request / brainstorm forum thread for making tuning easier in Renoise… Without requesting full-blown microtonality support in Renoise, here are two relatively small features which I think would help us out greatly:

  1. The ability to share a sample among an instrument’s sample slots. Right now I have to have 19 unique copies of the same sample in my instrument in order to achieve 19-TET.
  2. Express finetuning as cents from 1 to 100. None of this 1 to 128 crap. Nobody calculates tuning like that.

Not to diverge from your topic, dblue. I’ve thought about using your script in a tool to create a retuned instrument, but there are many barriers.

I don’t know if any of this makes sense or is in the right thread. I’m pretty spaced out right now.