Tuning.rb - Is it possible to modify? (Custom temperaments)

Hello everybody, first of all I’m really glad to join this community!
I have a small question to ask, is it possible to modify the C:\Program Files\Sonic Pi\app\server\ruby\lib\sonicpi\tuning.rb file in order to create custom temperaments?

I’ve tried but when saving the file and then opening Sonic PI, nothing changes.

PS: I have a decent background in programming but never write a line in Ruby. As a side note, despite i have posted a windows path, i actually made the test on a rasperry pi 400 with Raspi OS.

2 Likes

Hello @FainaruFantaji ! welcome to in_thread :slight_smile:
You’re almost there - that file tells Sonic Pi how to use the available tuning options.
In order to make any changes to these visible, it is also necessary to edit the code that provides the auto-completing list of tuning names for the editor. (See here, how I have done so just now with a new tuning called blabla.
image
The code for this is here:

Unfortunately, since the file that needs changing for this is part of the c++ code, once updated, it is necessary to recompile the GUI, according to the build instructions at the root of the Sonic Pi repository (sonic-pi/BUILD-LINUX.md at main · sonic-pi-net/sonic-pi · GitHub if you are testing on a RPi).

4 Likes

Thank you @ethancrawford , you’re great!
My custom tuning are there…but invisible!I should have guessed this possibility. :sweat_smile:

Tomorrow i’ll try to edit and recompile (and post my results).

For those interested, here is one of the microtonal scales that I want to implement; 12 notes selected from the 19edo (quite beginner firendly :slightly_smiling_face: )

  :19ish =>
    	[
    	  1.0,    #19edoish 12tet  -  every interval is sharper than the original
    	  1.076,
    	  1.157,
    	  1.200,
    	  1.291,
    	  1.339,
    	  1.440,
    	  1.549,
    	  1.607,
    	  1.728,
    	  1.793,
    	  1.928]
2 Likes

Done! Thanks again @ethancrawford.
Please don’t mind the cheesy program, it was used only for testing. :smiley:

For everyone interested in this operation, it took little more than an hour to download, edit, compile and build the files on a Raspberry pi 400; a little time consuming task!

2 Likes

I’d be interesting in your tuning experiments. Probably won’t do much of them myself but it’s always neat to find people with an interest in tuning systems, including xenharmonic ones.
Could be nice to have support for Scala/.tun files. And/or a system to automatically support the common EDO ones (which is what the Bitwig Studio DAW did, not too long ago).
I’ve been quite intrigued with 31EDO as it has several intervals which are quite close to JI.
In fact, I’ve been playing with something of a “noodling scale” (heptatonic) which could work well with several just intervals from 31EDO.

So, if you have examples of your tuning experiments, I’d be interested.

1 Like

That’s cool! This is something that I’ve played around with using a function, see below. I’m not 100% sure it’s correct, but can be built on.

define :micro_tune do |note, is_sample|
  # 12 out of 19-tET
  cents = [0,
           63.15,
           189.47,
           252.63,
           378.94,
           505.26,
           568.42,
           694.73,
           757.89,
           884.21,
           947.36,
           1073.68]
  
  tuned_notes = []
  idx = 0
  scale_length = 12
  
  if !note.kind_of?(Integer)
    note.each do |n|
      idx = n - (scale_length * (n / scale_length))
      tuned_notes.push(n + (cents[idx] - (idx * 100)) / 100)
    end
  else
    idx = note - (scale_length * (note / scale_length))
    tuned_notes.push(note + (cents[idx] - (idx * 100)) / 100)
  end
  
  if is_sample
    return (cents[idx] - (idx * 100)) / 100
  else
    return tuned_notes
  end
end

live_loop :test_notes do
  notes = scale(:c3, :chromatic)
  play micro_tune(notes.tick, false), amp: 1
  
  sleep 0.5
end
2 Likes

@enkerli @binarysweets I’m so sorry for the very late reply guys.

For personal reasons (Covid-related unfortunately), I have been away from the world of music and coding.
Hope you understand…

I’m quite happy to see that there are other people interested in mictrotuning and Sonic Pi.
Good luck for your experimentations! :slight_smile:

PS: 19 and 31-EDO are among my favourite alternate tunings! :wink:

2 Likes

Of course we understand! Hope the situation has improved for you.
Your favourite tunings are among mine as well. Especially 31, at this point. A bit unwieldy to map on a keyboard. Should work nicely in SPi.