How to set key when playing notes

If you’re playing notes from sheet music that is set in a different key than C major, is there a command in Sonic Pi to set the key or do you just have to change the affected notes by hand? Thanks.

Hi

What do you mean ?

If you are looking for transposing stuff Transposing a play pattern to a key
Cheers

Hi @klynn47,

If you’re entering note names directly, Sonic Pi lets you specify sharps or flats by adding “s” or “f” to the note name:

play :gs4
sleep 0.5
play :fs4
sleep 0.5
play :e4

If you’d rather specify a melody in terms of a key, then @nlb’s advice is correct: you can use a scale object and access it by index:

s = scale(:e4, :major)
play s[2]
sleep 0.5
play s[1]
sleep 0.5
play s[0]

You can then “change the key signature” by using a different scale.

Does this make sense? I hope it helps.