Relative MIDI pitch to frequency ratio

pitch_to_ratio  pitch (midi_number)

Convert a midi note to a ratio which when applied to a frequency will scale the frequency by the number of semitones. Useful for changing the pitch of a sample by using it as a way of generating the rate.

Introduced in v2.5

Examples

# Example 1

pitch_to_ratio 12



#=> 2.0



# Example 2

pitch_to_ratio 1



#=> 1.05946



# Example 3

pitch_to_ratio -12



#=> 0.5



# Example 4

sample :ambi_choir, rate: pitch_to_ratio(3)



# Plays :ambi_choir 3 semitones above default.



# Example 5


(range 0, 16).each do |n|                 
  sample :ambi_choir, rate: pitch_to_ratio(n)
  sleep 0.5                               
end



# Play a chromatic scale of semitones
# For each note in the range 0->16
# play :ambi_choir at the relative pitch
# and wait between notes