# Path: bl/utils.py
# def getClock(clock=None):
#     if clock is None:
#         from bl.scheduler import BeatClock
#         return BeatClock.defaultClock
#     return clock
# 
# Path: bl/debug.py
# def debug(message):
#     if DEBUG:
#         log.msg(message)


import pypm
from bl.utils import getClock
from bl.debug import debug
    def __init__(self, callback, sustain=False):
        """
        callback: handler to receive chords
        sustain: if True, only call our callback with noteon events
        """
        self.callback = callback
        self.sustain = sustain
        self._chord = []

    def noteon(self, channel, note, velocity, timestamp):
        """
        Add note to chord and call our callback with updated chord.

        Note that channel, velocity and timestamp arguments are ignored.
        """
        debug('noteon channel=%s note=%s velocity=%s t=%s' % (
                        channel, note, velocity, timestamp))
        if note not in self._chord:
            self._chord.append(note)
            debug('calling %s' % self.callback)
            self.callback(list(self._chord))

    def noteoff(self, channel, note, velocity, timestamp):
        """
        Remove note from chord.
        If the attribute `sustain` is `True` then we do not
        call callback with the updated chord.

        Note that channel, velocity and timestamp arguments are ignored.
        """

# Path: bl/utils.py
# def getClock(clock=None):
#     if clock is None:
#         from bl.scheduler import BeatClock
#         return BeatClock.defaultClock
#     return clock
# 
# Path: bl/debug.py
# def debug(message):
#     if DEBUG:
#         log.msg(message)


# Path: bl/midi.py
import pypm
from bl.utils import getClock
from bl.debug import debug

    def __init__(self, callback, sustain=False):
        """
        callback: handler to receive chords
        sustain: if True, only call our callback with noteon events
        """
        self.callback = callback
        self.sustain = sustain
        self._chord = []

    def noteon(self, channel, note, velocity, timestamp):
        """
        Add note to chord and call our callback with updated chord.

        Note that channel, velocity and timestamp arguments are ignored.
        """
        debug('noteon channel=%s note=%s velocity=%s t=%s' % (
                        channel, note, velocity, timestamp))
        if note not in self._chord:
            self._chord.append(note)
            debug('calling %s' % self.callback)
            self.callback(list(self._chord))

    def noteoff(self, channel, note, velocity, timestamp):
        """
        Remove note from chord.
        If the attribute `sustain` is `True` then we do not
        call callback with the updated chord.

        Note that channel, velocity and timestamp arguments are ignored.
        """

        debug('noteoff channel=%s note=%s velocity=%s t=%s' % (