Esempio n. 1
0
    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)) for (k, v) in args.iteritems())
            func(**exhaustedArgs)
            stoppedChildren = []
            for child in self._scheduleChildren:
                try:
                    (func, args) = child.next()
                except StopIteration:
                    stoppedChildren.append(child)
                    continue
                exhaustedArgs = dict(
                    (k, exhaustCall(v)) for (k, v) in args.iteritems())
                func(**exhaustedArgs)
            for child in stoppedChildren:
                while child in self._scheduleChildren:
                    self._scheduleChildren.remove(child)
        try:
            event = schedule.next()
        except StopIteration:
            return
        if event:
            when, event = exhaustCall(event[0]), event[1:]
            delta = when - last
            if delta < 0:
                log.err(
                    Failure(
                        ValueError(
                            'scheduled value in past? relative last tick=%d, when=%d'
                            % (last, when))))
            else:
                # TODO It would be nice to not do this instead override
                # callLater to ensure it really makes a call synchronously. (or
                # maybe that's a horrible idea since it could run into maximum
                # recursion).
                if not delta:
                    self._advance(when, schedule, event)
                else:
                    self.clock.callLater(delta, self._advance, when, schedule,
                                         event)
Esempio n. 2
0
    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))
                                  for (k, v) in args.iteritems())
            func(**exhaustedArgs)
            stoppedChildren = []
            for child in self._scheduleChildren:
                try:
                    (func, args) = child.next()
                except StopIteration:
                    stoppedChildren.append(child)
                    continue
                exhaustedArgs = dict((k, exhaustCall(v))
                                      for (k, v) in args.iteritems())
                func(**exhaustedArgs)
            for child in stoppedChildren:
                while child in self._scheduleChildren:
                    self._scheduleChildren.remove(child)
        try:
            event = schedule.next()
        except StopIteration:
            return
        if event:
            when, event = exhaustCall(event[0]), event[1:]
            delta = when - last
            if delta < 0:
                log.err(Failure(ValueError(
                    'scheduled value in past? relative last tick=%d, when=%d'
                    % (last, when))))
            else:
                # TODO It would be nice to not do this instead override
                # callLater to ensure it really makes a call synchronously. (or
                # maybe that's a horrible idea since it could run into maximum
                # recursion).
                if not delta:
                    self._advance(when, schedule, event)
                else:
                    self.clock.callLater(
                        delta, self._advance, when, schedule, event)
Esempio n. 3
0
 def __call__(self):
     if not self.values:
         return
     if self.index >= len(self.values):
         self.reset(self.values)
     v = self.values[self.index]
     self.index += self.direction
     self.index = self.index % self.count
     return exhaustCall(v)
Esempio n. 4
0
 def __call__(self):
     if not self.values:
         return
     if self.index >= len(self.values):
         self.reset(self.values)
     v = self.values[self.index]
     self.index += self.direction
     self.index = self.index % self.count
     return exhaustCall(v)
Esempio n. 5
0
 def __call__(self):
     if not self.count:
         return
     v = exhaustCall(self.arp())
     if v is not None:
         v += (self.currentOctave * 12)
     self.index += 1
     self.index = self.index % self.count
     if self.index == 0:
         self.currentOctave += self.direction
         if self.octaves:
             self.currentOctave = self.currentOctave % (self.octaves + 1)
             if self.oscillate and self.currentOctave in (0, self.octaves):
                 self.direction *= -1
         else:
             self.currentOctave = 0
     return v
Esempio n. 6
0
 def __call__(self):
     if not self.count:
         return
     v = exhaustCall(self.arp())
     if v is not None:
         v += (self.currentOctave * 12)
     self.index += 1
     self.index = self.index % self.count
     if self.index == 0:
         self.currentOctave += self.direction
         if self.octaves:
             self.currentOctave = self.currentOctave % (self.octaves + 1)
             if self.oscillate and self.currentOctave in (0, self.octaves):
                 self.direction *= -1
         else:
             self.currentOctave = 0
     return v
Esempio n. 7
0
 def __call__(self):
     v = exhaustCall(self.arp())
     if v is not None:
         if type(v) in (list, tuple):
             return [self.amount + vk for vk in v]
         return self.amount + v
Esempio n. 8
0
 def __call__(self):
     return self.func(exhaustCall(self.arp()))
Esempio n. 9
0
 def __call__(self):
     v = exhaustCall(self.arp())
     if v is not None:
         if type(v) in (list, tuple):
             return [self.amount + vk for vk in v]
         return self.amount + v
Esempio n. 10
0
 def __call__(self):
     return self.func(exhaustCall(self.arp()))