# Path: mididings/setup.py
# _VALID_BACKENDS = _mididings.available_backends()
# _DEFAULT_CONFIG = {
#     'backend':          'alsa' if 'alsa' in _VALID_BACKENDS else 'jack',
#     'client_name':      'mididings',
#     'in_ports':         1,
#     'out_ports':        1,
#     'data_offset':      1,
#     'octave_offset':    2,
#     'initial_scene':    None,
#     'start_delay':      None,
#     'silent':           False,
# }
# def _default_portname(n, out):
# def _parse_portnames(ports, out):
# def _parse_port_connections(ports, out):
# def reset():
# def config(**kwargs):
# def _config_impl(override=False, **kwargs):
# def _config_updated():
# def get_config(var):
# def hook(*args):
# def get_hooks():
# 
# Path: mididings/engine.py
# def _start_backend():
#     def __init__(self):
#     def setup(self, scenes, control, pre, post):
#     def run(self):
#     def _start_delay(self):
#     def _parse_scene_number(self, number):
#     def scene_switch_callback(self, scene, subscene):
#     def _call_hooks(self, name, *args):
#     def switch_scene(self, scene, subscene=None):
#     def switch_subscene(self, subscene):
#     def current_scene(self):
#     def current_subscene(self):
#     def scenes(self):
#     def process_event(self, ev):
#     def output_event(self, ev):
#     def process(self, ev):
#     def restart(self):
#     def _restart():
#     def quit(self):
# def run(patch):
# def run(scenes, control=None, pre=None, post=None):
# def switch_scene(scene, subscene=None):
# def switch_subscene(subscene):
# def current_scene():
# def current_subscene():
# def scenes():
# def output_event(ev):
# def in_ports():
# def out_ports():
# def time():
# def active():
# def restart():
# def quit():
# def process_file(infile, outfile, patch):
# class Engine(_mididings.Engine):
# 
# Path: mididings/misc.py
# def flatten(arg):
# def issequence(seq, accept_string=False):
# def issequenceof(seq, t):
# def islambda(f):
# def getargspec(f):
#     def __init__(self, replacement=None):
#     def wrapper(self, f, *args, **kwargs):
#     def __call__(self, f):
#     def __new__(cls, value, name):
#     def __init__(self, value, name):
#     def __getnewargs__(self):
#     def __repr__(self):
#     def __str__(self):
#     def __or__(self, other):
#     def __invert__(self):
# def prune_globals(g):
# def sequence_to_hex(data):
#     def __init__(self, data):
#     def __repr__(self):
# def get_terminal_size():
# class deprecated(object):
# class NamedFlag(int):
# class NamedBitMask(NamedFlag):
# class bytestring(object):
# 
# Path: mididings/constants.py
# class _EventType(_NamedBitMask):
# class _EventAttribute(_NamedFlag):
# _EVENT_TYPES = {}


    import unittest2 as unittest
    import unittest
import random
import itertools
import sys
import copy
import mididings
import mididings.event
from mididings import *
from mididings import setup, engine, misc, constants
from mididings.event import *
            self.assertEqual(repr(w), rep)
            r[k] = w
        return r

    def make_event(self, *args, **kwargs):
        """
        Create a new MIDI event. Attributes can be specified in args or
        kwargs, unspecified attributes are filled with random values.
        """
        type, port, channel, data1, data2, sysex = \
            itertools.islice(itertools.chain(args, itertools.repeat(None)), 6)

        for k, v in kwargs.items():
            if k == 'type': type = v
            if k == 'port': port = v
            elif k == 'channel': channel = v
            elif k in ('data1', 'note', 'ctrl'): data1 = v
            elif k in ('data2', 'velocity', 'value'): data2 = v
            elif k == 'program': data2 = v - setup.get_config('data_offset')
            elif k == 'sysex': sysex = v

        if type is None:
            if channel is None:
                type = random.choice(list(set(constants._EVENT_TYPES.values())
                                        - set([DUMMY])))
            else:
                type = random.choice([NOTEON, NOTEOFF, CTRL, PITCHBEND,
                                      AFTERTOUCH, POLY_AFTERTOUCH, PROGRAM])
        elif type == NOTE:
            type = random.choice([NOTEON, NOTEOFF])

# Path: mididings/setup.py
# _VALID_BACKENDS = _mididings.available_backends()
# _DEFAULT_CONFIG = {
#     'backend':          'alsa' if 'alsa' in _VALID_BACKENDS else 'jack',
#     'client_name':      'mididings',
#     'in_ports':         1,
#     'out_ports':        1,
#     'data_offset':      1,
#     'octave_offset':    2,
#     'initial_scene':    None,
#     'start_delay':      None,
#     'silent':           False,
# }
# def _default_portname(n, out):
# def _parse_portnames(ports, out):
# def _parse_port_connections(ports, out):
# def reset():
# def config(**kwargs):
# def _config_impl(override=False, **kwargs):
# def _config_updated():
# def get_config(var):
# def hook(*args):
# def get_hooks():
# 
# Path: mididings/engine.py
# def _start_backend():
#     def __init__(self):
#     def setup(self, scenes, control, pre, post):
#     def run(self):
#     def _start_delay(self):
#     def _parse_scene_number(self, number):
#     def scene_switch_callback(self, scene, subscene):
#     def _call_hooks(self, name, *args):
#     def switch_scene(self, scene, subscene=None):
#     def switch_subscene(self, subscene):
#     def current_scene(self):
#     def current_subscene(self):
#     def scenes(self):
#     def process_event(self, ev):
#     def output_event(self, ev):
#     def process(self, ev):
#     def restart(self):
#     def _restart():
#     def quit(self):
# def run(patch):
# def run(scenes, control=None, pre=None, post=None):
# def switch_scene(scene, subscene=None):
# def switch_subscene(subscene):
# def current_scene():
# def current_subscene():
# def scenes():
# def output_event(ev):
# def in_ports():
# def out_ports():
# def time():
# def active():
# def restart():
# def quit():
# def process_file(infile, outfile, patch):
# class Engine(_mididings.Engine):
# 
# Path: mididings/misc.py
# def flatten(arg):
# def issequence(seq, accept_string=False):
# def issequenceof(seq, t):
# def islambda(f):
# def getargspec(f):
#     def __init__(self, replacement=None):
#     def wrapper(self, f, *args, **kwargs):
#     def __call__(self, f):
#     def __new__(cls, value, name):
#     def __init__(self, value, name):
#     def __getnewargs__(self):
#     def __repr__(self):
#     def __str__(self):
#     def __or__(self, other):
#     def __invert__(self):
# def prune_globals(g):
# def sequence_to_hex(data):
#     def __init__(self, data):
#     def __repr__(self):
# def get_terminal_size():
# class deprecated(object):
# class NamedFlag(int):
# class NamedBitMask(NamedFlag):
# class bytestring(object):
# 
# Path: mididings/constants.py
# class _EventType(_NamedBitMask):
# class _EventAttribute(_NamedFlag):
# _EVENT_TYPES = {}


# Path: tests/helpers.py
    import unittest2 as unittest
    import unittest
import random
import itertools
import sys
import copy
import mididings
import mididings.event
from mididings import *
from mididings import setup, engine, misc, constants
from mididings.event import *

            self.assertEqual(repr(w), rep)
            r[k] = w
        return r

    def make_event(self, *args, **kwargs):
        """
        Create a new MIDI event. Attributes can be specified in args or
        kwargs, unspecified attributes are filled with random values.
        """
        type, port, channel, data1, data2, sysex = \
            itertools.islice(itertools.chain(args, itertools.repeat(None)), 6)

        for k, v in kwargs.items():
            if k == 'type': type = v
            if k == 'port': port = v
            elif k == 'channel': channel = v
            elif k in ('data1', 'note', 'ctrl'): data1 = v
            elif k in ('data2', 'velocity', 'value'): data2 = v
            elif k == 'program': data2 = v - setup.get_config('data_offset')
            elif k == 'sysex': sysex = v

        if type is None:
            if channel is None:
                type = random.choice(list(set(constants._EVENT_TYPES.values())
                                        - set([DUMMY])))
            else:
                type = random.choice([NOTEON, NOTEOFF, CTRL, PITCHBEND,
                                      AFTERTOUCH, POLY_AFTERTOUCH, PROGRAM])
        elif type == NOTE:
            type = random.choice([NOTEON, NOTEOFF])

        elif misc.issequence(type):