def get_outsk(self, inst, fn): import random while True: variance = random.uniform(-self.time_variance, self.time_variance) if schedule.now() >= -variance: break outsk = fn() + variance return outsk
def value(self): cur_time = schedule.now() if cur_time < self.start_time: return self.start_val elif cur_time >= self.start_time + self.dur: return self.end_val else: elapsed = cur_time-self.start_time return self.start_val + (self.end_val-self.start_val) * (float(elapsed) / self.dur)
def __init__(self, minval=0., maxval=1., dur=10, table=None, loop=False): if table is None: table = rtcmix.maketable('line',1000, 0,0, 1,1) self.min=minval self.max=maxval self.dur=dur self.table=table self.start_time=schedule.now() self.loop=loop
def value(self): cur_time = schedule.now() if cur_time >= self.start_time + self.dur: if not self.loop: return self.end_val elapsed = cur_time-self.start_time if self.loop: elapsed = elapsed%self.dur index = float(elapsed)/self.dur*rtcmix.tablelen(self.table) val = rtcmix.samptable(self.table, index) if self.table_is_non_negative(): return self.min + (self.max-self.min) * val else: return self.min + (self.max-self.min) * (val+1.)/2.
def get_outsk(self): return self.outsk + schedule.now()
def __init__(self, start_val=0., end_val=1., dur=10): self.start_time = schedule.now() self.start_val = start_val self.end_val = end_val self.dur = dur