Esempio n. 1
0
def Process(function, *args, **kwargs):
    """
    Process(function, *args, **kwargs)

    Process the incoming MIDI event using a Python function, then continue
    executing the mididings patch with the events returned from that
    function.

    :param function:
        a function, or any other callable object, that will be called with
        a :class:`~.MidiEvent` object as its first argument.

        The function's return value can be:
          - a single :class:`~.MidiEvent` object.
          - a list of :class:`~.MidiEvent` objects.
          - ``None`` (or an empty list).

        Instead of ``return``\ ing :class:`~.MidiEvent` objects, *function*
        may also be a generator that ``yield``\ s :class:`~.MidiEvent`
        objects.

    :param \*args:
        optional positional arguments that will be passed to *function*.

    :param \*\*kwargs:
        optional keyword arguments that will be passed to *function*.


    Any other MIDI processing will be stalled until *function* returns,
    so this should only be used with functions that don't block.
    Use :func:`Call()` for tasks that may take longer and/or don't require
    returning any MIDI events.
    """
    if _get_config('backend') == 'jack-rt' and not _get_config('silent'):
        print("WARNING: using Process() with the 'jack-rt' backend"
              " is probably a bad idea")
    return _CallBase(_call_partial(function, args, kwargs, True), False, False)
Esempio n. 2
0
def Process(function, *args, **kwargs):
    """
    Process(function, *args, **kwargs)

    Process the incoming MIDI event using a Python function, then continue
    executing the mididings patch with the events returned from that
    function.

    :param function:
        a function, or any other callable object, that will be called with
        a :class:`~.MidiEvent` object as its first argument.

        The function's return value can be:
          - a single :class:`~.MidiEvent` object.
          - a list of :class:`~.MidiEvent` objects.
          - ``None`` (or an empty list).

        Instead of ``return``\ ing :class:`~.MidiEvent` objects, *function*
        may also be a generator that ``yield``\ s :class:`~.MidiEvent`
        objects.

    :param \*args:
        optional positional arguments that will be passed to *function*.

    :param \*\*kwargs:
        optional keyword arguments that will be passed to *function*.


    Any other MIDI processing will be stalled until *function* returns,
    so this should only be used with functions that don't block.
    Use :func:`Call()` for tasks that may take longer and/or don't require
    returning any MIDI events.
    """
    if _get_config('backend') == 'jack-rt' and not _get_config('silent'):
        print("WARNING: using Process() with the 'jack-rt' backend"
              " is probably a bad idea")
    return _CallBase(_call_partial(function, args, kwargs, True), False, False)