Note intervals -1 and 12?

Just wondering if this is a bug or not:

print (note_info :Bs).interval  # 12
print (note_info :Cb).interval  # -1

Should it be Bs=0 and Cb=11 instead?


what is the role of .interval ?

I can understand the output to some extend. All note intervals are measured between the note and the corresponding C below, belonging to the same octave. So the 12 for Bs is ok for me. The -1 for Cb is a bit strange, but if you consider the Cb as still being a member of the octave with base C, the Cb with -1 is plausible as well.
EDIT: interval is the number of steps to get there, not the index of the note

1 Like

Ah, yes, 12 represents the perfect octave, but -1 is just strange. It also apprears to be in the same octave, which is also kind of odd:

print (note_info :C).octave # 4
print (note_info :Cb).octave # 4

I was hoping to use these for transforming any existing melody to chromatic scale 0…11 to represent it in a Markov matrix somehow.

Well, it has to be in the same octave, otherwise -1 makes no sense at all…

What about n%12 for each note? -1%12 is 11 …

Thanks. That would do it … but if i want to take the right octave in account then i have to substract one from the octave in case its -1. Otherwise it would be that -1 and 11 are the same note in the same octave.

Would this do what you want?

[:bs, :c, :cb].each do |n|
  o = (n+0) / 12 - 1
  i = (n+0) % 12
  puts "note:", n, n + 0, "octave:", o, "interval:", i
{run: 20, time: 0.0}
 β”œβ”€ "note:" :bs 72 "octave:" 5 "interval:" 0
 β”œβ”€ "note:" :c 60 "octave:" 4 "interval:" 0
 └─ "note:" :cb 59 "octave:" 3 "interval:" 11
1 Like

Yes! Thanks. Good to know that note symbol + 0 thing.

1 Like

I think (:c+0) forces the ruby interpreter to do a type cast, like :c.to_i would

Sort of. It was a hack we put in (simple addition/subtraction with numbers and note name symbols) to make simple note transpositions a bit easier without having to purely use MIDI numbers :slight_smile:

1 Like