Return the current octave multiplied by twelve and add notes.note_to_int to it. This means a C-0 returns 0, C-1 returns 12, etc. This method allows you to use int() on Notes.
(self)
| 300 | return self.set_note(name, octave, {}) |
| 301 | |
| 302 | def __int__(self): |
| 303 | """Return the current octave multiplied by twelve and add |
| 304 | notes.note_to_int to it. |
| 305 | |
| 306 | This means a C-0 returns 0, C-1 returns 12, etc. This method allows |
| 307 | you to use int() on Notes. |
| 308 | """ |
| 309 | res = self.octave * 12 + notes.note_to_int(self.name[0]) |
| 310 | for n in self.name[1:]: |
| 311 | if n == "#": |
| 312 | res += 1 |
| 313 | elif n == "b": |
| 314 | res -= 1 |
| 315 | return res |
| 316 | |
| 317 | def __lt__(self, other): |
| 318 | """Enable the comparing operators on Notes (>, <, \ ==, !=, >= and <=). |