Get note number from note name

This is probably a very straight forward question but I don’t know how to do it… I simply need to get the number behind a note name. The only way I have found is the following.

live_loop :test do
  note = :a1
  puts note + 0
  sleep 1
end

But I am wondering if there is a method or similar I can call on note that will return the integer value behind :a1

Thanks

Hi @keys,

try this:

puts note(:a1)
1 Like

hi @keys

i don’t know if you know that you can do that directly

play :c + 12

it will play the note corresponding to 60 + 12 = 72 so the :c5. The :c is interpreted as the :c4 note.

1 Like

Try

num= note(:a1)
puts num
1 Like

Thanks for the advise! It worked perfectly.

Interesting that I chose the variable name note in my example, which was the name of the function I was looking for :wink: