Jump to content


Photo

Snippet: Load Scala .Scl Tuning File


  • Please log in to reply
26 replies to this topic

#1 dblue

dblue

    Dodgy Geezer

  • Admins
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5551 posts
  • Gender:Male
  • Location:Berlin
  • Interests:Code. Music. Graphics.

Posted 26 January 2011 - 01:54

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-f...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:
Attached File  Scala.lua   5.41KB   370 downloads
  • hryx, maes, Cas and 1 other like this

#2 Djeroek

Djeroek

    Probably More God or Borg Than Human Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6660 posts
  • Gender:Male
  • Location:Borneo

Posted 26 January 2011 - 18:23

I like where this is going :w00t:

:yeah:

#3 dblue

dblue

    Dodgy Geezer

  • Admins
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5551 posts
  • Gender:Male
  • Location:Berlin
  • Interests:Code. Music. Graphics.

Posted 26 January 2011 - 21:17

I like where this is going :w00t:

I thought you might :)

#4 loimi

loimi

    Super Advanced Member

  • Normal Members
  • PipPipPipPip
  • 153 posts

Posted 27 January 2011 - 23:22

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?

#5 Djeroek

Djeroek

    Probably More God or Borg Than Human Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6660 posts
  • Gender:Male
  • Location:Borneo

Posted 17 February 2011 - 22:35

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 :)

#6 Delight

Delight

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male

Posted 13 March 2011 - 16:37

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

#7 dblue

dblue

    Dodgy Geezer

  • Admins
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5551 posts
  • Gender:Male
  • Location:Berlin
  • Interests:Code. Music. Graphics.

Posted 13 March 2011 - 16:51

Downloaded your file... Now, what do I do with it?
Can I use this with instruments, samples and vsti? or what?

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.

#8 Delight

Delight

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male

Posted 13 March 2011 - 17:08

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.)

#9 pirate utopia

pirate utopia

    Chief Above Chief Member

  • Normal Members
  • PipPipPipPipPipPip
  • 327 posts
  • Gender:Not Telling
  • Location:Patagonia, Argentina
  • Interests:Mountains, ocean, sand, stars

Posted 09 April 2011 - 08:49

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! : )

#10 dblue

dblue

    Dodgy Geezer

  • Admins
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 5551 posts
  • Gender:Male
  • Location:Berlin
  • Interests:Code. Music. Graphics.

Posted 09 April 2011 - 11:50

Hi, Im learning about tuning and scala. Do you know hot to change the base frequency in scala?

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.

#11 pirate utopia

pirate utopia

    Chief Above Chief Member

  • Normal Members
  • PipPipPipPipPipPip
  • 327 posts
  • Gender:Not Telling
  • Location:Patagonia, Argentina
  • Interests:Mountains, ocean, sand, stars

Posted 09 April 2011 - 18:27

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.

#12 radian

radian

    Chief Above Chief Member

  • Normal Members
  • PipPipPipPipPipPip
  • 258 posts
  • Gender:Male
  • Location:Brighton, UK

Posted 10 April 2011 - 03:03

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?

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

#13 pirate utopia

pirate utopia

    Chief Above Chief Member

  • Normal Members
  • PipPipPipPipPipPip
  • 327 posts
  • Gender:Not Telling
  • Location:Patagonia, Argentina
  • Interests:Mountains, ocean, sand, stars

Posted 10 April 2011 - 04:19

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)

#14 Djeroek

Djeroek

    Probably More God or Borg Than Human Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6660 posts
  • Gender:Male
  • Location:Borneo

Posted 10 April 2011 - 09:43

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 ;-) . Have faith it will happen eventually.
  • maes likes this

#15 Delight

Delight

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male

Posted 12 April 2011 - 16:05

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 ;-) . 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!!!

#16 maes

maes

    Guruh Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 952 posts
  • Gender:Male
  • Location:.se
  • Interests:musics

Posted 12 April 2011 - 16:31

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! (=

Edited by maes, 12 April 2011 - 16:31.


#17 Djeroek

Djeroek

    Probably More God or Borg Than Human Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6660 posts
  • Gender:Male
  • Location:Borneo

Posted 12 April 2011 - 18:35

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.

#18 maes

maes

    Guruh Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPip
  • 952 posts
  • Gender:Male
  • Location:.se
  • Interests:musics

Posted 13 April 2011 - 08:26

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.

#19 pirate utopia

pirate utopia

    Chief Above Chief Member

  • Normal Members
  • PipPipPipPipPipPip
  • 327 posts
  • Gender:Not Telling
  • Location:Patagonia, Argentina
  • Interests:Mountains, ocean, sand, stars

Posted 13 April 2011 - 18:48

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)

#20 hryx

hryx

    Super Advanced Member

  • Normal Members
  • PipPipPipPip
  • 172 posts
  • Gender:Male
  • Location:San Francisco

Posted 14 April 2011 - 00:53

alphanumeric representation of notes is perfect for handling non-standard tunings in contrast with having a pianoroll type of representation.

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.
  • engine likes this
Stevie / Hryx .... ホムページ | @Bandcamp | @Twitter

Topics of note ... The Official Tuning Proposal Thread

#21 Djeroek

Djeroek

    Probably More God or Borg Than Human Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6660 posts
  • Gender:Male
  • Location:Borneo

Posted 14 April 2011 - 01:45

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.


You can put slice markers on top of each other at the exact same spot in the sample editor, thought this would maybe enable triggering the same sample on different keys at different tunings, but that doesn't seem to work, or I;m doing something wrong?

2. Express finetuning as cents from 1 to 100. None of this 1 to 128 crap. Nobody calculates tuning like that.


makes sense +1

#22 hryx

hryx

    Super Advanced Member

  • Normal Members
  • PipPipPipPip
  • 172 posts
  • Gender:Male
  • Location:San Francisco

Posted 20 September 2011 - 17:43

(Old thread resuscitation)

You can put slice markers on top of each other at the exact same spot in the sample editor, thought this would maybe enable triggering the same sample on different keys at different tunings, but that doesn't seem to work, or I;m doing something wrong?


Huh, that's a clever idea, I hadn't thought of that. But yeah, looks like it won't work because when you try to put a slice on top of another slice, it just comes out blank.

By the way, I started a thread on tuning features for Renoise, complete with mockups. I want to get serious about a practical solution. If you have any ideas or are just curious you should drop by:
http://www.renoise.c...ature-proposal/

If any of the ideas there become reality, I'll probably be using dblue's Lua snippet for a retuning script. And then it will be Christmas every day.
Stevie / Hryx .... ホムページ | @Bandcamp | @Twitter

Topics of note ... The Official Tuning Proposal Thread

#23 kazakore

kazakore

    Probably More God or Borg Than Human Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6140 posts
  • Gender:Male

Posted 20 September 2011 - 17:55

Huh, that's a clever idea, I hadn't thought of that. But yeah, looks like it won't work because when you try to put a slice on top of another slice, it just comes out blank.


Does work, just make sure you enable it to play after the end of the slice rather than being limited to within the boundaries. Button just to the right of the percentage dropdown for the auto-slicer.

#24 vV

vV

    God's or Borg's Chief and Ruler of All Species

  • Moderator
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 16855 posts
  • Gender:Male
  • Location:Netherlands

Posted 17 April 2012 - 17:53

bump. Renoise features ready for expansion on this idea.
Vv....


cpu Intel Core i7-4820K @3.70GHz
chipset Intel X79 chipset
mem 32 Gb 2400Mhz
os Win 7 64-bit SP1, DirectX 11
audio ESI ESP1010e - > Driver rev:2.0.6.0
video nVidia Geforce GTX780 - > Driver rev:335.23


Renoise Official Manual

#25 pirate utopia

pirate utopia

    Chief Above Chief Member

  • Normal Members
  • PipPipPipPipPipPip
  • 327 posts
  • Gender:Not Telling
  • Location:Patagonia, Argentina
  • Interests:Mountains, ocean, sand, stars

Posted 17 April 2012 - 19:06

bump. Renoise features ready for expansion on this idea.

cool!!!