示例#1
0
文件: io.py 项目: PaulBatchelor/pippi
    def gridHandler(self, tick, bpm, midiout=4):
        # TODO: send MIDI clock again, assign device via 
        # config file and/or console cmd. Also allow mapping 
        # MIDI control to grid tempo value without resetting
        os.nice(0)

        cdiv = 24

        beat = dsp.bpm2frames(bpm) / cdiv

        count = 0

        ts = time.time()

        while getattr(self.ns, 'grid', True):
            if count % cdiv == 0:
                tick.set()
                tick.clear()

            ts = time.time()

            dsp.delay(beat)
            count += 1

        ts = time.time()
示例#2
0
    def grid_handler(self, tick, bpm):
        os.nice(0)

        beat = dsp.bpm2frames(bpm)

        count = 0
        while getattr(self.ns, 'grid', True):
            tick.set()
            tick.clear()
            dsp.delay(beat)
            count += 1
示例#3
0
    def grid_handler(self, tick, bpm):
        os.nice(0)

        beat = dsp.bpm2frames(bpm)

        count = 0
        while getattr(self.ns, 'grid', True):
            tick.set()
            tick.clear()
            dsp.delay(beat)
            count += 1
示例#4
0
        def _sendMidi(note, velocity, length, device):
            velocity = int(round(velocity * 127))
            note = int(note)
            dsp.log(device)
            out = mido.open_output(device)
            msg = mido.Message('note_on', note=note, velocity=velocity)
            out.send(msg)

            dsp.delay(length)

            msg = mido.Message('note_off', note=note, velocity=0)
            out.send(msg)
示例#5
0
文件: io.py 项目: bensteinberg/pippi
        def _sendMidi(note, velocity, length, device):
            velocity = int(round(velocity * 127))
            note = int(note)
            dsp.log(device)
            out = mido.open_output(device)
            msg = mido.Message('note_on', note=note, velocity=velocity)
            out.send(msg)

            dsp.delay(length)

            msg = mido.Message('note_off', note=note, velocity=0)
            out.send(msg)
示例#6
0
    def loop(self):
        while self.run == True:
            dsp.delay(4410)

            if hasattr(self.ns, 'console_cmds'):
                cmds = self.ns.console_cmds
                del self.ns.console_cmds

                for cmd in cmds:
                    cmd = cmd.split(' ')
                    cmd_function = cmd.pop(0)
                    args = ' '.join(cmd)
                    if hasattr(console, 'do_%s' % cmd_function):
                        method = getattr(console, 'do_%s' % cmd_function)
                        method(args)
示例#7
0
    def gridHandler(self, divs, bpm, ctl=None):
        # TODO: send MIDI clock again, assign device via
        # config file and/or console cmd. Also allow mapping
        # MIDI control to grid tempo value without resetting
        os.nice(0)

        count = 0

        if self.params.get('clock', 'off') == 'on':
            out = mido.open_output(self.default_midi_device)
            start = mido.Message('start')
            stop = mido.Message('stop')
            clock = mido.Message('clock')
            out.send(start)

        while getattr(self.ns, 'grid', True):
            beat = dsp.bpm2frames(bpm) / 24

            if self.params.get('clock', 'off') == 'on':
                out.send(clock)

            if count % 24 == 0:
                divs[24].set()
                divs[24].clear()

            if count % 12 == 0:
                divs[12].set()
                divs[12].clear()

            if count % 8 == 0:
                divs[8].set()
                divs[8].clear()

            if count % 6 == 0:
                divs[6].set()
                divs[6].clear()

            if count % 3 == 0:
                divs[3].set()
                divs[3].clear()

            dsp.delay(beat)
            count += 1

        if self.params.get('clock', 'off') == 'on':
            out.send(stop)
示例#8
0
文件: io.py 项目: bensteinberg/pippi
    def gridHandler(self, divs, bpm, ctl=None):
        # TODO: send MIDI clock again, assign device via 
        # config file and/or console cmd. Also allow mapping 
        # MIDI control to grid tempo value without resetting
        os.nice(0)

        count = 0

        if self.params.get('clock', 'off') == 'on':
            out = mido.open_output(self.default_midi_device)
            start = mido.Message('start')
            stop = mido.Message('stop')
            clock = mido.Message('clock')
            out.send(start)

        while getattr(self.ns, 'grid', True):
            beat = dsp.bpm2frames(bpm) / 24

            if self.params.get('clock', 'off') == 'on':
                out.send(clock)

            if count % 24 == 0:
                divs[24].set()
                divs[24].clear()

            if count % 12 == 0:
                divs[12].set()
                divs[12].clear()

            if count % 8 == 0:
                divs[8].set()
                divs[8].clear()

            if count % 6 == 0:
                divs[6].set()
                divs[6].clear()

            if count % 3 == 0:
                divs[3].set()
                divs[3].clear()

            dsp.delay(beat)
            count += 1

        if self.params.get('clock', 'off') == 'on':
            out.send(stop)
示例#9
0
    def do_v(self, cmd):
        cmds = cmd.split(" ")

        channel = self.channels[int(cmds[0])]

        try:
            current = channel[0].get_volume()
            target = float(cmds[1])

            if target == current:
                return

            diff = target - current
            diff /= 100.0

            for i in range(100):
                current += diff
                channel[0].set_volume(current)
                dsp.delay(0.01)
        except AttributeError:
            pass

        self.do_i()