Пример #1
0
def supplyoutput():
    'Supply events to the sequencer.'
    global outgoing
    event_tmpl = 'events: {:3} in the ALSA sequencer queue, {:3} outgoing, {:3} may be sent, {:3} sent'
    enfila_old = 0
    while vivo:
        enfila = alsaseq.status()[2]
        if enfila < 250 and outgoing:
            nenviar = 500 - enfila - nlibres
            if len(outgoing) > nlibres:
                for evento in outgoing[:nlibres]:
                    alsaseq.output(evento)
                print(
                    event_tmpl.format(enfila, len(outgoing), 500 - enfila,
                                      nlibres))
                outgoing = outgoing[nlibres:]
            else:
                print(
                    event_tmpl.format(enfila, len(outgoing), 500 - enfila,
                                      len(outgoing)))
                for evento in outgoing:
                    alsaseq.output(evento)
                    outgoing = []
        elif enfila != enfila_old:
            print(event_tmpl.format(enfila, len(outgoing), 500 - enfila, 0))
        enfila_old = enfila
        time.sleep(0.5)
    print('Ending supplyoutput()')
Пример #2
0
def drums(ritmo, tempo, compases):
    "Output one measure to queue."
    global incoming
    tiempoms = alsamidi.tuple2time(alsaseq.status()[1]) * 1000
    t = pista.construye(ritmo, tempo, compases, tiempoms)
    final = alsamidi.time2tuple(pista.duracion(ritmo, tempo, compases, tiempoms) / 1000.0)
    t.append((alsaseq.SND_SEQ_EVENT_ECHO, 1, 0, 0, final, (0, 0), (alsaseq.id(), 0), (1, 2, 3, 4, 5)))

    for evento in t:
        alsaseq.output(evento)
        incoming.append(evento)  # record it
Пример #3
0
def drums(ritmo, tempo, compases):
    'Output one measure to queue.'
    global incoming
    tiempoms = alsamidi.tuple2time(alsaseq.status()[1]) * 1000
    t = pista.construye(ritmo, tempo, compases, tiempoms)
    final = alsamidi.time2tuple(
        pista.duracion(ritmo, tempo, compases, tiempoms) / 1000.)
    t.append((alsaseq.SND_SEQ_EVENT_ECHO, 1, 0, 0, final, (0, 0),
              (alsaseq.id(), 0), (1, 2, 3, 4, 5)))

    for evento in t:
        alsaseq.output(evento)
        incoming.append(evento)  # record it
Пример #4
0
 def run(self):
     logging.info("Starting MIDI clock queue")
     self.enqueue_events()
     alsaseq.start()
     while self.keep_running:
         # not using alsaseq.syncoutput() here, as we would not be fast enough to enqueue more events after
         # the queue has flushed, thus sleep for half the approximate time the queue will need to drain
         time.sleep(self.enqueue_at_once / 2 * self.delay)
         status, time_t, events = alsaseq.status()
         if events >= self.enqueue_at_once:
             #logging.info("more than 24*4 events queued, skipping enqueue")
             continue
         self.enqueue_events()
     alsaseq.stop()
     logging.info("MIDI clock queue stopped")
Пример #5
0
def supplyoutput():
    "Supply events to the sequencer."
    global outgoing
    event_tmpl = "events: {:3} in the ALSA sequencer queue, {:3} outgoing, {:3} may be sent, {:3} sent"
    enfila_old = 0
    while vivo:
        enfila = alsaseq.status()[2]
        if enfila < 250 and outgoing:
            nenviar = 500 - enfila - nlibres
            if len(outgoing) > nlibres:
                for evento in outgoing[:nlibres]:
                    alsaseq.output(evento)
                print(event_tmpl.format(enfila, len(outgoing), 500 - enfila, nlibres))
                outgoing = outgoing[nlibres:]
            else:
                print(event_tmpl.format(enfila, len(outgoing), 500 - enfila, len(outgoing)))
                for evento in outgoing:
                    alsaseq.output(evento)
                    outgoing = []
        elif enfila != enfila_old:
            print(event_tmpl.format(enfila, len(outgoing), 500 - enfila, 0))
        enfila_old = enfila
        time.sleep(0.5)
    print("Ending supplyoutput()")
Пример #6
0
		if (status[0]*1000 + status[1]/1000000) > self.target:
			self.position = self.target + self.period
			self.output_pulses() 

	def output_pulses(self):
		for i in range(self.position, 
					   self.position + self.period,
					   self.pulse_period):
			alsaseq.output((alsaseq.SND_SEQ_EVENT_CLOCK, 1, 0, 1,
						   (i // 1000, (i%1000) * 1000000),
						   (0, 0), (0, 0), (0, 0, 0, 0, 0)))
		self.target = self.position
		


alsaseq.client('Midi Clock', 0, 1, True)
alsaseq.start()

midiclock = MidiClock(period)	
			
while True:
	status = alsaseq.status()
	midiclock.check_target(status[1])