Some utilities when working with non tempered scales

Today I stumbled upon the fact that many non western scales, for example :ferahfeza, contain decimal midi values, which means that they are not tempered scales. I explored the topic and wrote some routines. Maybe someone else will find them useful.

The first script gives back all Sonic Pi scales that have decimal midi values:

my_scale_arr = []
scale_names.each do |par_scale|
  scale(:C4, par_scale).each do |par_note|
    if par_note != par_note.to_i
      my_scale_arr.append(par_scale)
      break
    end
  end
end
print my_scale_arr

With the following code you get all midi values, approximated midi names and the frequencies in hertz for a certain scale. I rounded them to 4 decimals, because this is more readable:

print (scale :C4,:ferahfeza).to_a.map{
  |note| [note.round(4),
          note_info(note).midi_string,
          midi_to_hz(note).round(4)]
}

If you want to play chords with such scales, you can either use the exact decimal midi values or you can work with chord_degree. Here is the version with chord_degree:

use_synth :piano
play chord_degree(:iv, :c3, :ferahfeza, 3, invert: 1), decay: 1
sleep 2
1 Like