Sorting Notes and Graphics

 

 

Since we’ve gotten midi files to load into JEM and have been able to pull note information out of those midi files, I’ve started trying to make some functions that will put different graphics on the screen based on what note is playing. I started off doing this by making dictionaries of notes. When you get the pitch of a note from a midi file with JEM it spits back out a number that corresponds to a certain note. I grouped all of these numbers into note values (A, B, C, etc.) so that we would be able to group the graphics more simply.


#dictonaries of notes
a = [9,21,33,45,57,69,81,93,105,117]
aS = [10,22,34,46,58,70,82,94,106,118]
aF = [8,20,32,44,56,68,80,92,104,116]
b = [11,23,35,47,59,71,83,95,107,119]
bS =[12,24,36,48,72,84,96,108,120]
c = [0,12,24,36,48,72,84,96,108,120]
cS = [1,13,25,37,49,61,73,85,97,109,121]
d = [26,38,50,62,74,86,98,110,122]
dS = [3,15,27,39,51,63,75,87,99,111,123]
e = [4,16,28,40,52,64,76,88,100,112,124]
eF = [3,15,27,39,51,63,75,87,99,111,123]
f = [5,17,29,41,53,65,77,89,101,113,125]
fS = [6,18,30,42,54,66,78,90,102,114,126]
fF = [4,16,28,40,52,64,76,88,100,112,124]
g = [7,19,31,43,55,67,79,91,103,115,127]
gS = [8,20,32,44,56,68,80,92,104,116]
gF = [6,18,30,42,54,66,78,90,102,114,126]

I then used the getNotes function that my team worked on in lab to get the pitch values of notes and then wrote another function which takes in a note as input and then uses if statements to see which note dictionary each pitch is in, and displays a corresponding graphic on the screen.


# Loops through the score, part, and phrase to make a list of all the notes
def getNotes():
global parts, notes, phrases, score
parts = score.getPartList()
for part in parts:
for phrase in part.getPhraseList():
phrases.append(phrase)
for note in phrase.getNoteList():
notes.append(note)
d = note.getDuration()
# Prints all the notes and their attributes
return notes
def noteImage(note):
global notes
for note in notes:
note.getPitch()
if note in a:
#put in this graphic and draw to screen
elif note in aS:
#put in this graphic and draw to screen
elif note in aF:
#etc..
elif note in b:
elif note in bS:
elif note in c:
elif note in cS:
elif note in d:
elif note in dS:
elif note in e:
elif note in eF:
elif note in f:
elif note in fS:
elif note in fF:
elif note in g:
elif note in gS:
else:

As you can see, the code is not fully fleshed out. We are still deciding as a group if we want to generate the graphics randomly with the GUI library, or if we want to do the graphics in Illustrator and then just put it on the screen depending on what the note is. I’m going to work on that next, and once we decide how we want to do the graphics I’m going to work on filling out and debugging this code.

 

 

Leave a comment