You can play shepard tones on your keyboard with this.
# Shepard Tone Keyboard
# Coded by Loopiloop
#---settings---
#set number of octaves the shepard tone uses
n = 15
#volume control
v = 0.25
#device
d = "masterkey_61_0:1"
#---code---
#remove delay
use_real_time
#repeat forver
live_loop :shepard do
#wait for keyboard input and get its values
key, velocity = sync "/midi:" + d + "/note_on"
#reset octave counter
tick_reset :octave
#for the desired amount of octaves do
n.times do
#determine pitch
note = (range 0, 12)[key] + tick(:octave) * 12
#determine volume
amplitude = ((n*12)-2.0*note-1)/((n*12)-1.0)
if amplitude < 0
amplitude = amplitude * -1
end
amplitude = (1 - amplitude)
#play note
play note, amp: amplitude * (velocity/127.0) * v
end
end