# Path: bl/debug.py
# def debug(message):
#     if DEBUG:
#         log.msg(message)
# 
# DEBUG = _Debug()
# 
# Path: bl/utils.py
# def getClock(clock=None):
#     if clock is None:
#         from bl.scheduler import BeatClock
#         return BeatClock.defaultClock
#     return clock
# 
# def exhaustCall(v):
#     """
#     Get an uncallable value at the end of a call chain or `v` itself
#     if `v` is not callable.
#     """
#     while callable(v):
#         v = v()
#     return v


import random
from itertools import cycle
from pprint import pformat
from zope.interface import Interface, Attribute, implements
from twisted.python import log
from bl.debug import debug, DEBUG
from bl.utils import getClock, exhaustCall
    def _resetRecording(self):
        whens = self._tape['whens']
        notes = self._tape['notes']
        velocities = self._tape['velocities']
        sustains = self._tape['sustains']
        indexes = self._tape['indexes']
        if DEBUG:
            log.msg('>tape===\n%s' % pformat(self._tape))
        self._eraseTape()
        if not whens and (self._last_tape and self._last_tape['dirty']):
            whens = self._last_tape['whens']
            notes = self._last_tape['notes']
            velocities = self._last_tape['velocities']
            sustains = self._last_tape['sustains']
            indexes = self._last_tape['indexes']
            self._last_tape['dirty'] = True
        if whens:
            sus = [None] * len(whens)
            for (ontick, onnote, sustain) in sustains:
                index = indexes.get((ontick, onnote))
                if index is not None:
                    sus[index] = sustain
                else:
                    log.err(ValueError(
                        'no index for tick=%s note=%s' % (ontick, onnote)))
            self.phrase = zip(whens, notes, velocities, sus)
            self.phrase = [
                (w, n, v, s or self.elapsed - w)
                for (w, n, v, s) in self.phrase
            ]

# Path: bl/debug.py
# def debug(message):
#     if DEBUG:
#         log.msg(message)
# 
# DEBUG = _Debug()
# 
# Path: bl/utils.py
# def getClock(clock=None):
#     if clock is None:
#         from bl.scheduler import BeatClock
#         return BeatClock.defaultClock
#     return clock
# 
# def exhaustCall(v):
#     """
#     Get an uncallable value at the end of a call chain or `v` itself
#     if `v` is not callable.
#     """
#     while callable(v):
#         v = v()
#     return v


# Path: bl/arp.py
import random
from itertools import cycle
from pprint import pformat
from zope.interface import Interface, Attribute, implements
from twisted.python import log
from bl.debug import debug, DEBUG
from bl.utils import getClock, exhaustCall

    def _resetRecording(self):
        whens = self._tape['whens']
        notes = self._tape['notes']
        velocities = self._tape['velocities']
        sustains = self._tape['sustains']
        indexes = self._tape['indexes']
        if DEBUG:
            log.msg('>tape===\n%s' % pformat(self._tape))
        self._eraseTape()
        if not whens and (self._last_tape and self._last_tape['dirty']):
            whens = self._last_tape['whens']
            notes = self._last_tape['notes']
            velocities = self._last_tape['velocities']
            sustains = self._last_tape['sustains']
            indexes = self._last_tape['indexes']
            self._last_tape['dirty'] = True
        if whens:
            sus = [None] * len(whens)
            for (ontick, onnote, sustain) in sustains:
                index = indexes.get((ontick, onnote))
                if index is not None:
                    sus[index] = sustain
                else:
                    log.err(ValueError(
                        'no index for tick=%s note=%s' % (ontick, onnote)))
            self.phrase = zip(whens, notes, velocities, sus)
            self.phrase = [
                (w, n, v, s or self.elapsed - w)
                for (w, n, v, s) in self.phrase
            ]

            if DEBUG: