Example #1
0
    def get_pitch(self, inst, fn):
        target = inst.pitch
        if not hasattr(inst, 'prev_pitch'):
            return fn()

        diff = target - inst.prev_pitch
        dur = inst._get('dur')
        fraction_sliding = float(self.amt)/dur # the fraction of total dur spent sliding
        if fraction_sliding >= 1: # we never actually get there...
            slidetable = rtcmix.maketable('line', 'nonorm', 1000, 0,0, 1, diff / fraction_sliding)
        else:
            slidetable = rtcmix.maketable('line', 'nonorm', 1000, 0,0, fraction_sliding,diff, 1,diff)
        return fn()-diff+slidetable
Example #2
0
 def get_amp(self, inst, fn):
     points = []
     total_time = 0
     prev_amp = 0
     for time,amp in (0,0), (self.a,1), (self.d,self.s):
         if total_time+time > inst.dur:
             new_time = inst.dur-total_time
             total_time += new_time
             new_amp = prev_amp - (float(prev_amp - amp) * new_time/time)
             time = new_time
             amp = new_amp
             points.append((time, amp))
             break
         total_time += time
         prev_amp = amp
         points.append((time, amp))
     if total_time < inst.dur:
         points.append((inst.dur-total_time,self.s))
     points.append((self.r, 0))
     
     
     args = []
     total_time = 0
     for time,amp in points:
         total_time += time
         args.extend((total_time, amp))
     
     env = rtcmix.maketable('line', 'nonorm', 1000, 0,0, *args)
     return fn() * env
Example #3
0
 def get_pitch(self, inst, fn):
     if self.amt <= 0:
         return fn()
     return fn() * (1+rtcmix.maketable('random', 'nonorm', self.points, "even", 1./(1+self.amt)-1, self.amt))