def __init__(self, fifo_length): # Must physically connect the MIDI device to this port. port = 1 # The FIFO allows multiple or no MIDI data in between each time the # server runs. The driver writes the FIFO and provides a method # for the server to read the FIFO. self.fifo = fifo.Fifo(fifo_length) self.midi_in, port_name = rtmu.open_midiinput(port) self.midi_in.set_callback(MidiCallback(port_name, self.fifo)) self.tell_me_everything(port_name)
def __init__(self, rate, chunk, downwsample_ratio, fifo_length): #self.last_time = time.time() #self.get_last_time = time.time() self.fifo = fifo.Fifo(fifo_length) self.width = 2 self.channels = 2 self.rate = rate self.chunk = chunk self.downsample_ratio = downwsample_ratio print("Initialized the PyAudio class.")
def __init__(self, fifo_length): port = 1 # Change this to select associated MIDI device. self.fifo = fifo.Fifo(fifo_length) self.midi_in, port_name = rtmu.open_midiinput(port) self.midi_in.set_callback(MidiCallback(port_name, self.fifo)) self.tell_me_everything(port_name)
import numpy as np import random import tvgen import fifo #------------------------------------------------------------------------------- TV_FILE_NAME = "./out/tv.txt" NB_TVECS = 1000 NB_SEQ = 1 FIFO_SIZE = 5 #------------------------------------------------------------------------------- TV_FILE = open(TV_FILE_NAME, "w") #------------------------------------------------------------------------------- buf = fifo.Fifo(FIFO_SIZE) #------------------------------------------------------------------------------- op_id = [0, 1, 2] # 0: push, 1:pop, 2:push&pop op_repeat = np.arange(1, FIFO_SIZE) # nb of consequtive op input_arr = [op_id, op_repeat] tv = tvgen.TestVector(input_arr, 1, NB_TVECS) #------------------------------------------------------------------------------- for op in tv.testvecs: print("op = %d " % op[0], "repeat = %d" % op[1]) for rpt_idx in np.arange(op[1]): pop_data = -1 push_data = random.randrange(255) print("push data = ", push_data) if op[0] == 0: # 0: push print("Pushing data", push_data) buf.push(push_data) elif op[0] == 1: # 1: pop pop_data = buf.pop() print("Pop data = ", pop_data)
def __init__(self, fifosize=1024): self.fifo = fifo.Fifo(fifosize, only_bytes=True)