# Path: mididings/extra/per_channel.py
# class PerChannel(object):
#     """
#     Utility class, usable with Process() and Call(), that delegates events
#     to different instances of the same class, using one instance per
#     channel/port combination.
#     New instances are created as needed, using the given factory function,
#     when the first event with a new channel/port arrives.
#     """
#     def __init__(self, factory):
#         self.channel_proc = {}
#         self.factory = factory
# 
#     def __call__(self, ev):
#         k = (ev.port, ev.channel)
#         if k not in self.channel_proc:
#             self.channel_proc[k] = self.factory()
#         return self.channel_proc[k](ev)


import mididings as _m
import mididings.event as _event
import mididings.engine as _engine
from mididings.extra.per_channel import PerChannel as _PerChannel
                yield _event.NoteOnEvent(
                            ev.port, ev.channel, n, self.notes[n][0])
                self.current_note = n
                self.diverted = d


def VoiceFilter(voice='highest', time=0.1, retrigger=False):
    """
     Filter individual voices from a chord.

    :param voice:
        The voice to be filtered.

        This can be ``'highest'``, ``'lowest'``, or an integer index
        (positive or negative, the same way Python lists are indexed,
        with 0 being the lowest voice and -1 the highest).

    :param time:
        The period in seconds for which a newly played note may still be
        unassigned from the selected voice, when additional notes are played.

    :param retrigger:
        If true, a new note-on event will be sent when a note is reassigned
        to the selected voice as a result of another note being released.
    """
    if voice == 'highest':
        voice = -1
    elif voice == 'lowest':
        voice = 0


# Path: mididings/extra/per_channel.py
# class PerChannel(object):
#     """
#     Utility class, usable with Process() and Call(), that delegates events
#     to different instances of the same class, using one instance per
#     channel/port combination.
#     New instances are created as needed, using the given factory function,
#     when the first event with a new channel/port arrives.
#     """
#     def __init__(self, factory):
#         self.channel_proc = {}
#         self.factory = factory
# 
#     def __call__(self, ev):
#         k = (ev.port, ev.channel)
#         if k not in self.channel_proc:
#             self.channel_proc[k] = self.factory()
#         return self.channel_proc[k](ev)


# Path: mididings/extra/voices.py
import mididings as _m
import mididings.event as _event
import mididings.engine as _engine
from mididings.extra.per_channel import PerChannel as _PerChannel

                yield _event.NoteOnEvent(
                            ev.port, ev.channel, n, self.notes[n][0])
                self.current_note = n
                self.diverted = d


def VoiceFilter(voice='highest', time=0.1, retrigger=False):
    """
     Filter individual voices from a chord.

    :param voice:
        The voice to be filtered.

        This can be ``'highest'``, ``'lowest'``, or an integer index
        (positive or negative, the same way Python lists are indexed,
        with 0 being the lowest voice and -1 the highest).

    :param time:
        The period in seconds for which a newly played note may still be
        unassigned from the selected voice, when additional notes are played.

    :param retrigger:
        If true, a new note-on event will be sent when a note is reassigned
        to the selected voice as a result of another note being released.
    """
    if voice == 'highest':
        voice = -1
    elif voice == 'lowest':
        voice = 0


    return _m.Filter(_m.NOTE) % _m.Process(_PerChannel(