Beispiel #1
0
def stop():
    "Stop playing of events."
    global playing, incoming
    playing = False
    alsaseq.stop()
    if incoming:
        incoming.insert(0, pgmchangevoz1)
        if voz2:
            incoming.insert(0, pgmchangevoz2)
        seq.tracks.append(incoming)
        incoming = []
    print("stopped")
    print(len(seq.tracks), "tracks")
Beispiel #2
0
def stop():
    'Stop playing of events.'
    global playing, incoming
    playing = False
    alsaseq.stop()
    if incoming:
        incoming.insert(0, pgmchangevoz1)
        if voz2:
            incoming.insert(0, pgmchangevoz2)
        seq.tracks.append(incoming)
        incoming = []
    print('stopped')
    print(len(seq.tracks), 'tracks')
Beispiel #3
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")
Beispiel #4
0
    def run(self):
        import select

        alsaseq.client(appinfo.name, self.num_inports, self.num_outports, True)
        self.start_time = datetime.now()
        alsaseq.start()
        log.debug("ALSA sequencer started")

        alsafd = alsaseq.fd()
        while not self.join_req:
            fds_ready = select.select([alsafd], [], [], 0.1)
            if alsaseq.inputpending():
                raw_event = alsaseq.input()
                new_event = self.create_event(raw_event)
                self.dispatch_event(new_event)
        alsaseq.stop()
        alsaseq.close()
Beispiel #5
0
    def clickThreadRun(self):
        def noteOff(time):
            time_split = math.modf(time)
            time_i = int(time_split[1])
            time_f = int(time_split[0] * 1e9)
            # print (time_i, time_f)
            return (7, 1, 0, 0, (time_i, time_f), (130, 0), (131, 0), (9, 75, 0, 0, 0))

        def noteOn(time, v, instrument):
            time_split = math.modf(time)
            time_i = int(time_split[1])
            time_f = int(time_split[0] * 1e9)
            # print (time_i, time_f)
            return (6, 1, 0, 0, (time_i, time_f), (130, 0), (131, 0), (9, instrument, v, 0, 0))

        clicks = self.songStructure.getAllClicksSecs()
        clicks.sort()
        lookAheadTime = 10  # seconds
        self.clickStartTime = time.time()
        alsaseq.start()

        """
        print "-=---------------------------"
        print self.songStructure.totalNumMeasures()
        print self.songStructure.totalSecsLength()
        print len(clicks)
        print "-=---------------------------"
        """
        totalSongLenSecs = self.songStructure.totalSecsLength()

        for c in clicks:
            alsaseq.output(noteOn(c[0], 127, c[1]))
            if self.stopClick:
                break
            while c[0] > (time.time() - self.clickStartTime) + lookAheadTime:
                time.sleep(0.5)

        while (time.time() - self.clickStartTime) < totalSongLenSecs:
            time.sleep(0.5)
        print "done with song!"
        alsaseq.stop()
        self.clickStartTime = 0
        self.stopClick = True