# 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


from itertools import cycle
from twisted.python import log
from twisted.python.failure import Failure
from bl.utils import getClock, exhaustCall
        """
        Immediately start playing our schedule. (Generally you should not use
        this method but resumePlaying() instead).
        """
        self.paused = False
        event = self._paused_event
        self._paused_event = None
        self._advance(self.last, self.schedule, event=event)

    def pause(self):
        """
        Immediately pause playing our schedule. (Generally you should not use
        this method but pausePlaying() instead).
        """
        self.paused = True

    def _advance(self, last, schedule, event=None):
        self.last = last
        if self.paused:
            self._paused_event = event
            return
        if event is not None:
            (func, args) = event

            # TODO exhaustCall is "BAD" b/c we might want to actually pass
            # functions! This should be replaced maybe by exhaustUgens which
            # has prequisite: unit generators (ugens). bl.player's ad-hoc ugens
            # should be put in bl.ugens (new module) and implement IUgen or
            # something


# 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/orchestra/base.py
from itertools import cycle
from twisted.python import log
from twisted.python.failure import Failure
from bl.utils import getClock, exhaustCall

        """
        Immediately start playing our schedule. (Generally you should not use
        this method but resumePlaying() instead).
        """
        self.paused = False
        event = self._paused_event
        self._paused_event = None
        self._advance(self.last, self.schedule, event=event)

    def pause(self):
        """
        Immediately pause playing our schedule. (Generally you should not use
        this method but pausePlaying() instead).
        """
        self.paused = True

    def _advance(self, last, schedule, event=None):
        self.last = last
        if self.paused:
            self._paused_event = event
            return
        if event is not None:
            (func, args) = event

            # TODO exhaustCall is "BAD" b/c we might want to actually pass
            # functions! This should be replaced maybe by exhaustUgens which
            # has prequisite: unit generators (ugens). bl.player's ad-hoc ugens
            # should be put in bl.ugens (new module) and implement IUgen or
            # something


            exhaustedArgs = dict((k, exhaustCall(v))