Shifting Octaves

Shifting Octaves

# OctaveShifting.rb
# 9 Nov 2017
define :getoct do |tone|
  a=note(tone)
  a=a/12 -1
  return a
end

a=:B4
b=:C5
puts a,note(a)
puts b,note(b)
puts a,note(a,octave: 3)
puts b,note(b,octave: 3)

puts a,getoct(a)
puts b,getoct(b)

puts a,note(a,octave: getoct(a)-1)
puts b,note(b,octave: getoct(b)-1)

The output

 ├─ :B4 71
 ├─ :C5 72
 ├─ :B4 59
 ├─ :C5 48
 ├─ :B4 4
 ├─ :C5 5
 ├─ :B4 59
 └─ :C5 60