def joystick(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup pixels = lib.Pixels(nStrips, lStrip, 0) theoAll = np.zeros([lStrip * nStrips, 3]) inputNames = mido.get_input_names() inport = mido.open_input(inputNames[0]) board = lib.Board() # loop while True: for msg in inport.iter_pending(): board.update(msg) for n in range(nStrips): theoAll[n * lStrip, :] = 0 theoAll = np.roll(theoAll, -1, axis=0) currentStrip = np.floor( (board.pitchwheel + 8192) // (8192 * 2 // nStrips)) for n in range(nStrips): if n == currentStrip: theoAll[(n * lStrip) + lStrip - 1] = [200, 100, 250] pixels.update(theoAll, 1.0, 0.4) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) time.sleep(2.e-2)
def drums_midi(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup pixels = lib.Pixels(nStrips, lStrip, 0) theoAll = np.zeros([lStrip * nStrips, 3]) inputNames = mido.get_input_names() inport = mido.open_input(inputNames[1]) board = lib.Board() speedCut = 100 frameNum = 0 nColorWheel = nStrips colorWheel = lib.getColorWheel(nColorWheel) stripColors = np.zeros([nStrips, 3]) n = 0 while n < nStrips: stripColors[n] = colorWheel[n] * 255 n += 1 midiNotes = [] while len(midiNotes) < nStrips: for msg in inport.iter_pending(): if msg.type == 'note_on': midiNotes.append(msg.note) print(midiNotes) justTurnedOn = np.zeros(nStrips) # loop while True: for msg in inport.iter_pending(): board.update(msg) #overallFactor = float(board.knobs[51]+1)/(128.0) #if np.mod(frameNum, speedCut) == 0: for n in range(nStrips): theoAll[n * lStrip, :] = 0 theoAll = np.roll(theoAll, -1, axis=0) for n in range(nStrips): if board.notes[midiNotes[n]] == 1: theoAll[(n * lStrip) + lStrip - 1] = stripColors[n] pixels.update(theoAll, 1.0, 0.4) client.putPixels(0, brightnessFactor * pixels.getArrayForDisplay()) time.sleep(2.e-2) frameNum += 1
def rain1_midi(brightnessFactor): # always here global nStrips, lStrip client = fastopc.FastOPC('localhost:7890') # setup pixels = lib.Pixels(nStrips, lStrip, 0) theoAll = np.zeros([lStrip * nStrips, 3]) inputNames = mido.get_input_names() inport = mido.open_input(inputNames[0]) board = lib.Board() speedCut = 100 frameNum = 0 midiNotes = [] while len(midiNotes) < nStrips: for msg in inport.iter_pending(): if msg.type == 'note_on': midiNotes.append(msg.note) print(midiNotes) # loop while True: for msg in inport.iter_pending(): board.update(msg) color = 2 * board.knobs[48:51] overallFactor = float(board.knobs[51] + 1) / (128.0) if np.mod(frameNum, speedCut) == 0: for n in range(nStrips): theoAll[n * lStrip, :] = 0 theoAll = np.roll(theoAll, -1, axis=0) for n in range(nStrips): midiNoteNum = midiNotes[n] if board.notes[midiNoteNum] == 1: theoAll[(n * lStrip) + lStrip - 1] = color * (board.velocities[midiNoteNum] / 128.0) #theoAll[(n*lStrip)+lStrip-1] = stripColors[n] pixels.update(theoAll, 1.0, 0.4) client.putPixels( 0, overallFactor * brightnessFactor * pixels.getArrayForDisplay()) time.sleep(2.e-4) frameNum += 1
def loopTest(brightnessFactor): # always here global nStrips, lStrip #client = fastopc.FastOPC('localhost:7890') # setup pixels = lib.Pixels(nStrips, lStrip, 0) theoAll = np.zeros([lStrip * nStrips, 3]) inputNames = mido.get_input_names() inport = mido.open_input(inputNames[0]) board = lib.Board() mseqList = [] n1 = 0 # loop while True: n = 0 mseqList.append(lib.midiSequence()) while n < 10000: n += 1 for msg in inport.iter_pending(): mseq.update(msg) pixels.update(theoAll, 1.0, 0.4) #client.putPixels(0, brightnessFactor*pixels.getArrayForDisplay()) time.sleep(2.e-4) n1 += 1