I am working on a sheet music app and now I need to create a list (or whatever will let me do this) that will store all of this info (see below) as one item and then print it out or better yet insert it into my code to be manipulated by a bunch of functions...
print('Note' + '(' + str(wnote) + ', ' + repr(staff) + ', ' + str(measure) + ', ' + repr(note) + ', ' + repr(notetype) + ')' + '.ExNote()')
All that prints out something like this...
Note(8, '4R', 4, 'c', 'Ethnote').ExNote()
Which when hardcoded into my code goes through these class functions and print out an Eighth note onto my sheet music....
class Note:
def __init__(self, Num, staff, measure, note, notetype):
self.staff = staff
self.measure = measure
self.note = note
self.notetype = notetype
self.Num = Num
def Wmeasure(self):
return (self.measure-1)*153
def Wnotetype(self):
if self.notetype == 'Ethnote':
X= {'1':x+5, '2':x+22, '3':x+39, '4':x+56, '5':x+73, '6':x+90, '7':x+107, '8':x+124}
elif self.notetype == 'Fourthnote':
X={'1':x+19, '2':x+50, '3':x+81, '4':x+112}
elif self.notetype == 'Halfnote':
X={'1':x+39, '2':x+90}
elif self.notetype == 'note1':
X={'1':x+64, '2': x+64}
return X[str(self.Num)]
def Wnote(self):
YL={'b': y+76, 'a': y+80, 'g':y+84, 'f':y+88, 'e':y+92, 'd':y+96, 'c':y+100, 'b2':y+104, 'a2':y+108, 'a3': y+112}
YR= {'c': 62, 'd': 58, 'e': 54, 'f': 50, 'g':46, 'a':42, 'b':38,
'c2':34, 'd2':28 , 'e2':24, 'f2':20, 'g2':16, 'a2':12, 'b2':8, 'c3':4, 'd3':0}
if self.staff in ['1L', '2L', '3L', '4L']:
#self.staff == '1L': # or '2L' or '3L' or '4L':
return YL[self.note] #+ self.Wstaff()
else: #if self.staff == '1R' or '2R' or '3R' or '4R':
return YR[self.note] #+ self.Wstaff()
def Wstaff(self):
if self.staff in ['1L', '1R']:
j = 0
elif self.staff in ['2L', '2R']:
j = 160
elif self.staff in ['3L', '3R']:
j = 320
elif self.staff in ['4L', '4R']:
j = 480
return j
def getcoord(self):
return (self.Wmeasure() + self.Wnotetype()), (self.Wstaff() + self.Wnote())
def ExNote(self):
if self.notetype == 'Ethnote':
screen.blit(EthnoteIMG, self.getcoord())
elif self.notetype == 'Fourthnote':
screen.blit(FourthnoteIMG, self.getcoord())
elif self.notetype == 'Halfnote':
screen.blit(HalfnoteIMG, self.getcoord())
elif self.notetype == 'note1':
screen.blit(note1IMG, self.getcoord())
So my next step is to make a list or something that stores this...
('Note' + '(' + str(wnote) + ', ' + repr(staff) + ', ' + str(measure) + ', ' + repr(note) + ', ' + repr(notetype) + ')' + '.ExNote()')
... as one item and then I have to make a function that takes all the items in that list and somehow inserts them into my code seeing as just printing them out won't do anything.
Ok so I tried this which doesn't solve the whole problem but would definitely get me a lot closer BUT it doesn't work and I don't know why. I tested it all out in a separate file because that's easier and there are no errors or anything