# 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
    Note that that noteon callback should take two arguments
    (note, velocity) and noteoff callback should take one argument (note).
    """

    def __init__(self, noteonCallback, noteoffCallback):
        self.noteonCallback = noteonCallback
        self.noteoffCallback = noteoffCallback

    def noteon(self, channel, note, velocity, timestamp):
        """
        Call noteonCallback with the note and velocity.
        """
        # TODO - maybe do something smarter with the timestamp
        # ... like normalize to ticks
        self.noteonCallback(note, velocity)

    def noteoff(self, channel, note, velocity, timestamp):
        """
        Call noteoffCallback with the note.
        """
        self.noteoffCallback(note)


class ClockSender(object):
    """
    A simple midi beat clock sender which can be used to synchronize external
    MIDI devices.
    """

    def __init__(self, midiOut, clock=None):

# 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

    Note that that noteon callback should take two arguments
    (note, velocity) and noteoff callback should take one argument (note).
    """

    def __init__(self, noteonCallback, noteoffCallback):
        self.noteonCallback = noteonCallback
        self.noteoffCallback = noteoffCallback

    def noteon(self, channel, note, velocity, timestamp):
        """
        Call noteonCallback with the note and velocity.
        """
        # TODO - maybe do something smarter with the timestamp
        # ... like normalize to ticks
        self.noteonCallback(note, velocity)

    def noteoff(self, channel, note, velocity, timestamp):
        """
        Call noteoffCallback with the note.
        """
        self.noteoffCallback(note)


class ClockSender(object):
    """
    A simple midi beat clock sender which can be used to synchronize external
    MIDI devices.
    """

    def __init__(self, midiOut, clock=None):

        self.clock = getClock(clock)