Happy New Year to you too.
Let me know if you start to dabble with Ziffers and have some ideas how to make it better. There is the wiki and article to get you started ![:slight_smile: :slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)
Ziffers monkeypatches scale method in Sonic Pi, which means you have access to all of the 1490 scales in the 12 tone equal temperament using integers (See Ian Rings study of scales). In addition the patched scale method also has a Scala scale parser that support extended format as defined in Sevish scale workshop. Also see the tutorial for the workbench.
So for example with Ziffers installed you can do:
print scale(:major)
print scale(2741) # Also major
Last year I was mostly doing Topos but come back to Sonic Pi time to time. With Topos I have been playing around with the ideas from the Ian Rings site (See Proximity chapter in study of scales) to calculate distance between scales. So you could do a similar method for Sonic Pi like:
def distance(int1, int2)
# Apply XOR operation to sum changed bits between two scales
bits1 = int1.to_s(2).chars.map(&:to_i)
bits2 = int2.to_s(2).chars.map(&:to_i)
(0...bits1.length).map do |i|
if bits2[i] != bits1[i]
if bits1[i + 1] != bits2[i + 1] && bits1[i] != bits1[i + 1]
bits2[i + 1] = bits1[i + 1]
end
1
else
0
end
end.sum
end
This could be used to get the distances between scales:
print distance(2741,2737) # 1
print distance(2741,2999) # 2
print distance(2741,2653) # 3
In addition to the distances you could also get all the the scales that are one step away with the same idea using some binary magic:
def near_scales(scale_int)
(1..11).flat_map do |i|
near = scale_int
if (scale_int & (1 << i)) != 0
off = near ^ (1 << i)
result = [off, off | (1 << (i - 1))]
result << (off | (1 << (i + 1))) unless i == 11
result
else
[near |= (1 << i)]
end
end.uniq
end
print near_scales(2741) # [2743, 2737, ...]
This is the list of the same scales as listed in Ian Rings site for all the scales at the bottom of the scale pages, for example for 2741 for the major scale.