コード例 #1
0
ファイル: test_engine.py プロジェクト: wkoziej/mididings
    def test_out_ports(self):
        ports = ['foo', 'bar', 'baz']
        config(out_ports = ports)
        self.assertEqual(engine.out_ports(), ports)

        config(out_ports = 3)
        self.assertEqual(engine.out_ports(), ['out_0', 'out_1', 'out_2'])
コード例 #2
0
ファイル: printing.py プロジェクト: wkoziej/mididings
    def __call__(self, ev):
        # lazy import to avoid problems with circular imports
        from mididings import engine

        # get list of port names to be used (delayed 'til first use,
        # because the engine doesn't yet exist during __init__)
        if self.ports is None:
            if self.portnames == 'in':
                self.ports = engine.in_ports()
            elif self.portnames == 'out':
                self.ports = engine.out_ports()
            else:
                self.ports = []

        # find maximum port name length (delayed for the same reason as above)
        if _Print.portnames_used and _Print.max_portname_length == -1:
            all_ports = engine.in_ports() + engine.out_ports()
            _Print.max_portname_length = max(len(p) for p in all_ports)

        if self.name:
            namestr = '%-*s ' % (_Print.max_name_length + 1, self.name + ':')
        elif _Print.max_name_length != -1:
            # no name, but names used elsewhere, so indent appropriately
            namestr = ' ' * (_Print.max_name_length + 2)
        else:
            namestr = ''

        if ev.type == _constants.SYSEX:
            eventmax = _misc.get_terminal_size()[1] - len(namestr)
        else:
            eventmax = 0
        eventstr = ev.to_string(self.ports, _Print.max_portname_length,
                                eventmax)

        print('%s%s' % (namestr, eventstr))
コード例 #3
0
ファイル: printing.py プロジェクト: Darko8/mididings
    def __call__(self, ev):
        # lazy import to avoid problems with circular imports
        from mididings import engine

        # get list of port names to be used (delayed 'til first use,
        # because the engine doesn't yet exist during __init__)
        if self.ports is None:
            if self.portnames == 'in':
                self.ports = engine.in_ports()
            elif self.portnames == 'out':
                self.ports = engine.out_ports()
            else:
                self.ports = []

        # find maximum port name length (delayed for the same reason as above)
        if _Print.portnames_used and _Print.max_portname_length == -1:
            all_ports = engine.in_ports() + engine.out_ports()
            _Print.max_portname_length = max(len(p) for p in all_ports)

        if self.name:
            namestr = '%-*s ' % (_Print.max_name_length + 1, self.name + ':')
        elif _Print.max_name_length != -1:
            # no name, but names used elsewhere, so indent appropriately
            namestr = ' ' * (_Print.max_name_length + 2)
        else:
            namestr = ''

        if ev.type == _constants.SYSEX:
            eventmax = _misc.get_terminal_size()[1] - len(namestr)
        else:
            eventmax = 0
        eventstr = ev.to_string(self.ports, _Print.max_portname_length,
                                eventmax)

        print('%s%s' % (namestr, eventstr))
コード例 #4
0
def _panic_bypass():
    # send all notes off (CC #123) and sustain off (CC #64) to all output
    # ports and on all channels
    for p in _engine.out_ports():
        for c in range(16):
            _engine.output_event(_event.CtrlEvent(p, _util.offset(c), 123, 0))
            _engine.output_event(_event.CtrlEvent(p, _util.offset(c), 64, 0))
コード例 #5
0
ファイル: panic.py プロジェクト: Darko8/mididings
def _panic_bypass():
    # send all notes off (CC #123) and sustain off (CC #64) to all output
    # ports and on all channels
    for p in _engine.out_ports():
        for c in range(16):
            _engine.output_event(
                _event.CtrlEvent(p, _util.NoDataOffset(c), 123, 0))
            _engine.output_event(
                _event.CtrlEvent(p, _util.NoDataOffset(c), 64, 0))
コード例 #6
0
def Panic(bypass=True):
    """
    Generate all-notes-off (CC #123) and sustain off (CC #64) events on
    all channels.

    :param bypass:
        If true, events will be sent directly on all output ports, instead
        of originating from the :func:`Panic()` unit and being subject to
        further processing.
    """
    if bypass:
        return _m.Call(lambda ev: _panic_bypass())
    else:
        return _m.Fork([(_m.Ctrl(p, _util.offset(c), 123, 0) //
                         _m.Ctrl(p, _util.offset(c), 64, 0))
                        for p in _engine.out_ports() for c in range(16)])
コード例 #7
0
ファイル: panic.py プロジェクト: Darko8/mididings
def Panic(bypass=True):
    """
    Generate all-notes-off (CC #123) and sustain off (CC #64) events on
    all channels.

    :param bypass:
        If true, events will be sent directly on all output ports, instead
        of originating from the :func:`Panic()` unit and being subject to
        further processing.
    """
    if bypass:
        return _m.Call(lambda ev: _panic_bypass()) >> _m.Discard()
    else:
        return _m.Fork([
            (_m.Ctrl(p, _util.NoDataOffset(c), 123, 0) //
             _m.Ctrl(p, _util.NoDataOffset(c), 64, 0))
                for p in _engine.out_ports()
                for c in range(16)
        ])