# Path: mididings/units/base.py
# class _Unit(object):
#     """
#     Wrapper class for all units.
#     """
#     def __init__(self, unit):
#         self.unit = unit
# 
#     def __rshift__(self, other):
#         """
#         Connect units in series (operator >>).
#         """
#         if not isinstance(other, _UNIT_TYPES):
#             return NotImplemented
#         return _join_units(_Chain, self, other)
# 
#     def __rrshift__(self, other):
#         """
#         Connect units in series (operator >>).
#         """
#         if not isinstance(other, _UNIT_TYPES):
#             return NotImplemented
#         return _join_units(_Chain, other, self)
# 
#     def __floordiv__(self, other):
#         """
#         Connect units in parallel (operator //).
#         """
#         if not isinstance(other, _UNIT_TYPES):
#             return NotImplemented
#         return _join_units(_Fork, self, other)
# 
#     def __rfloordiv__(self, other):
#         """
#         Connect units in parallel (operator //).
#         """
#         if not isinstance(other, _UNIT_TYPES):
#             return NotImplemented
#         return _join_units(_Fork, other, self)
# 
#     def __pos__(self):
#         """
#         Apply to duplicate (unary operator +)
#         """
#         return self.add()
# 
#     def add(self):
#         return Fork([ Pass(), self ])
# 
#     def __repr__(self):
#         return _unitrepr.unit_to_string(self)


import _mididings
import mididings.constants as _constants
import mididings.util as _util
import mididings.overload as _overload
import mididings.unitrepr as _unitrepr
from mididings.units.base import _Unit
@_overload.partial((_constants.EVENT_PORT, _constants.EVENT_CHANNEL))
@_unitrepr.accept(_util.port_number_ref, _util.channel_number_ref,
                  _util.program_number_ref)
def Program(port, channel, program):
    """
    Program(program)
    Program(port, channel, program)

    Create a program change event, replacing the incoming event.
    """
    return _Unit(_mididings.Generator(
        _constants.PROGRAM,
        _util.actual_ref(port),
        _util.actual_ref(channel),
        0,
        _util.actual_ref(program)
    ))


@_overload.partial((_constants.EVENT_PORT,))
@_unitrepr.accept(_util.port_number_ref, _util.sysex_data)
def SysEx(port, sysex):
    """
    SysEx(sysex)
    SysEx(port, sysex)

    Create a system exclusive event, replacing the incoming event.
    *sysex* can be a string (binary or ASCII) or a sequence of integers,
    and must include the leading ``F0`` and trailing ``F7`` bytes.
    """

# Path: mididings/units/base.py
# class _Unit(object):
#     """
#     Wrapper class for all units.
#     """
#     def __init__(self, unit):
#         self.unit = unit
# 
#     def __rshift__(self, other):
#         """
#         Connect units in series (operator >>).
#         """
#         if not isinstance(other, _UNIT_TYPES):
#             return NotImplemented
#         return _join_units(_Chain, self, other)
# 
#     def __rrshift__(self, other):
#         """
#         Connect units in series (operator >>).
#         """
#         if not isinstance(other, _UNIT_TYPES):
#             return NotImplemented
#         return _join_units(_Chain, other, self)
# 
#     def __floordiv__(self, other):
#         """
#         Connect units in parallel (operator //).
#         """
#         if not isinstance(other, _UNIT_TYPES):
#             return NotImplemented
#         return _join_units(_Fork, self, other)
# 
#     def __rfloordiv__(self, other):
#         """
#         Connect units in parallel (operator //).
#         """
#         if not isinstance(other, _UNIT_TYPES):
#             return NotImplemented
#         return _join_units(_Fork, other, self)
# 
#     def __pos__(self):
#         """
#         Apply to duplicate (unary operator +)
#         """
#         return self.add()
# 
#     def add(self):
#         return Fork([ Pass(), self ])
# 
#     def __repr__(self):
#         return _unitrepr.unit_to_string(self)


# Path: mididings/units/generators.py
import _mididings
import mididings.constants as _constants
import mididings.util as _util
import mididings.overload as _overload
import mididings.unitrepr as _unitrepr
from mididings.units.base import _Unit

@_overload.partial((_constants.EVENT_PORT, _constants.EVENT_CHANNEL))
@_unitrepr.accept(_util.port_number_ref, _util.channel_number_ref,
                  _util.program_number_ref)
def Program(port, channel, program):
    """
    Program(program)
    Program(port, channel, program)

    Create a program change event, replacing the incoming event.
    """
    return _Unit(_mididings.Generator(
        _constants.PROGRAM,
        _util.actual_ref(port),
        _util.actual_ref(channel),
        0,
        _util.actual_ref(program)
    ))


@_overload.partial((_constants.EVENT_PORT,))
@_unitrepr.accept(_util.port_number_ref, _util.sysex_data)
def SysEx(port, sysex):
    """
    SysEx(sysex)
    SysEx(port, sysex)

    Create a system exclusive event, replacing the incoming event.
    *sysex* can be a string (binary or ASCII) or a sequence of integers,
    and must include the leading ``F0`` and trailing ``F7`` bytes.
    """

    return _Unit(_mididings.SysExGenerator(