Hi,
I am trying to draw a pianoroll (similar to piano notes) with the following python class:
class EtGrid(Gclass):
""" Equal Tempered Grid, useful in revealing pitch values
Optionally show the midi note number of each section
"""
def __init__(self, low = 48, high = 72):
self.low = low
self.high = high
self.nNotes = high - low
self.semiSize = 1. / self.nNotes
self.blackNotes = [1, 3, 6, 8, 10]
self.lineNotes = [0, 5]
def draw(self):
n = 0
while n < self.nNotes:
if (n%12) in self.lineNotes:
glColor(0,0,0)
glBegin(GL_LINE_STRIP)
glVertex2f(0, n*self.semiSize)
glVertex2f(1, n*self.semiSize)
glEnd()
if (n%12) in self.blackNotes:
glColor4f(0,0,0,.5)
else:
glColor4f(1,1,1,.5)
glBegin(GL_QUADS)
glVertex2f(0, n*self.semiSize)
glVertex2f(0, (n+1)*self.semiSize)
glVertex2f(1, (n+1)*self.semiSize)
glVertex2f(1, n*self.semiSize)
glEnd()
n += 1
# end class EtGrid
The resulting display can be seen here: http://mtg.upf.edu/files/personal/pianogrid.png
The problem is that I do not have a separator line at note 5 and 12, which I don’t know why. Does anyone else?
Thanks for the help,
Rich