# Path: mididings/units/base.py
# class _Filter(_Unit, _Selector):
#     """
#     Wrapper class for all filters.
#     """
#     def __init__(self, unit):
#         _Unit.__init__(self, unit)
# 
#     def __invert__(self):
#         """
#         Invert the filter (still act on the same event types, unary
#         operator ~).
#         """
#         return self.invert()
# 
#     def __neg__(self):
#         """
#         Negate the filter (ignoring event types, unary operator -)
#         """
#         return self.negate()
# 
#     def invert(self):
#         return _InvertedFilter(self, False)
# 
#     def negate(self):
#         return _InvertedFilter(self, True)
# 
#     def build(self):
#         return self
# 
#     def build_negated(self):
#         return self.negate()


import _mididings
import mididings.util as _util
import mididings.overload as _overload
import mididings.arguments as _arguments
import mididings.unitrepr as _unitrepr
import functools as _functools
from mididings.units.base import _Filter
def CtrlValueFilter(lower, upper):
    return _Filter(_mididings.CtrlValueFilter(lower, upper))


@_unitrepr.accept(_arguments.flatten(_util.program_number), add_varargs=True)
def ProgramFilter(programs):
    """
    ProgramFilter(programs, ...)

    Filter program change events by program number. The *programs* argument
    can be a single program number or a list of program numbers.
    All other events are discarded.
    """
    return _Filter(_mididings.ProgramFilter(map(_util.actual, programs)))


@_overload.mark(
    r"""
    SysExFilter(sysex)
    SysExFilter(manufacturer=...)

    Filter system exclusive events by the data they contain, specified as a
    string or as a sequence of integers.
    If *sysex* does not end with ``F7``, partial matches that start with the
    given data bytes are accepted.

    Alternatively, a sysex manufacturer id can be specified, which may be
    either a string or a sequence of integers, with a length of one or three
    bytes.


# Path: mididings/units/base.py
# class _Filter(_Unit, _Selector):
#     """
#     Wrapper class for all filters.
#     """
#     def __init__(self, unit):
#         _Unit.__init__(self, unit)
# 
#     def __invert__(self):
#         """
#         Invert the filter (still act on the same event types, unary
#         operator ~).
#         """
#         return self.invert()
# 
#     def __neg__(self):
#         """
#         Negate the filter (ignoring event types, unary operator -)
#         """
#         return self.negate()
# 
#     def invert(self):
#         return _InvertedFilter(self, False)
# 
#     def negate(self):
#         return _InvertedFilter(self, True)
# 
#     def build(self):
#         return self
# 
#     def build_negated(self):
#         return self.negate()


# Path: mididings/units/filters.py
import _mididings
import mididings.util as _util
import mididings.overload as _overload
import mididings.arguments as _arguments
import mididings.unitrepr as _unitrepr
import functools as _functools
from mididings.units.base import _Filter

def CtrlValueFilter(lower, upper):
    return _Filter(_mididings.CtrlValueFilter(lower, upper))


@_unitrepr.accept(_arguments.flatten(_util.program_number), add_varargs=True)
def ProgramFilter(programs):
    """
    ProgramFilter(programs, ...)

    Filter program change events by program number. The *programs* argument
    can be a single program number or a list of program numbers.
    All other events are discarded.
    """
    return _Filter(_mididings.ProgramFilter(map(_util.actual, programs)))


@_overload.mark(
    r"""
    SysExFilter(sysex)
    SysExFilter(manufacturer=...)

    Filter system exclusive events by the data they contain, specified as a
    string or as a sequence of integers.
    If *sysex* does not end with ``F7``, partial matches that start with the
    given data bytes are accepted.

    Alternatively, a sysex manufacturer id can be specified, which may be
    either a string or a sequence of integers, with a length of one or three
    bytes.


    All non-sysex events are discarded.