Blockers

Currently, our group has a few blocks that are preventing us from continuing on the JEM portion of our project. Mainly, the midi library has a function onNoteOn( *function* ) that is calls a function whenever a midi note is played. The problem is that this does not accept a midi file as input. I suspect that there is a simple solution for this (and will be working with Tanner on this later today). If a function that calls a function for each note in a midi file does not exist, there is a potential work around that would involve looping through each note of the note list, calling a function to make a graphic, the pausing the loop for the duration of the note. If a simpler option exists, it will likely run quicker than this loop.

In the mean time, I have written two pieces code pertaining to the graphics. The first determines what note is being read, and from that choses what shape the note will represent.


def shapeChoice(shapeVar):
shape = getNote(note)
def getNote(note):
shape = none
noteValue = none
pitch = note.getPitch()
if pitch in (0,12,24,36,48):
noteValue = c
if pitch in (1,13,25,37,49):
noteValue = db
if pitch in (2,14,26,38,50):
noteValue = d
if pitch in (3,15,27,39,51,63,75,87,99,111,123):
noteValue = eb
if pitch in (4,16,28,40,52,64,76,88,100,112,124):
noteValue = e
if pitch in (5,17,29,41,53,65,77,89,101,113,125):
noteValue = f
if pitch in (6,18,30,42,54,66,78,90,102,114,126):
noteValue = gb
if pitch in (7,19,31,43,55,67,79,91,103,115,127):
noteValue = g
if pitch in (8,20,32,44,56,68,80,92,104,116):
noteValue = ab
if pitch in (9,21,33,45,57,69,81,93,105,117):
noteValue = a
if pitch in (10,22,34,46,58,70,82,94,106,118):
noteValue = bb
if pitch in (11,23,35,47,59,71,83,95,107,119):
noteValue = b
if noteValue in (c,eb,gb,a):
shape = square
if noteValue in (db,e,g,bb):
shape = square
if noteValue in (d,f,ab,b):
shape = pentagon
return shape

view raw

Shape Choice

hosted with ❤ by GitHub

Additionally I found a method of making a gradient of colors and choosing a color based on the pitch of a note. The function works with any color combination but for this example we will say it goes from red to blue. This function will align the lowest note to red and the highest note to blue. Any notes in between will be assigned a color proportional to their distance from either end of the gradient.


colors = []
def getColor(note):
import colorsys
for i in range(101):
rgb = colorsys.hsv_to_rgb(i / 300., 1.0, 1.0)
colors.append(i, [round(255*x) for x in rgb])

view raw

Color Gradient

hosted with ❤ by GitHub

One goal I would like to achieve would be making the background an animated gradient. This background would smoothly shift between two colors when a note of certain parameters is played.

Leave a comment