コード例 #1
0
ファイル: dynamic_value.py プロジェクト: bennymartinson/Oort
 def table_is_non_negative(self):
     if self.is_non_negative is None:
         length = rtcmix.tablelen(self.table)
         self.is_non_negative = True
         for x in xrange(50):
             if rtcmix.samptable(self.table, length*x/50.) < 0:
                 self.is_non_negative = False
                 break
     return self.is_non_negative
コード例 #2
0
ファイル: dynamic_value.py プロジェクト: bennymartinson/Oort
 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.
コード例 #3
0
ファイル: utilities.py プロジェクト: bennymartinson/Oort
def jointables(*tables):
    """joins any number of tables into a resulting 1000-point table.
    
    Takes any number of arguments.  Each arg can be either a table handle, 
    or a tuple as follows:  (table, scale)
    where scale is the relative size of this table in the sum.
    Otherwise, scale defaults to 1."""
    
    points = []
    
    # we really don't want to log all these samptables:
    printing_was_on = rtcmix.is_print_on
    rtcmix.print_off()
    
    scalesum = 0
    tables_and_scales = []
    for t in tables:
        if type(t) is tuple:
            scale=t[1]
            table=t[0]
        else:
            scale=1
            table=t
        scalesum += scale
        tables_and_scales.append((table, scale))
    
    for table, scale in tables_and_scales:
        allotted_points = int(1000 * scale/float(scalesum))
        tlen = rtcmix.tablelen(table)
        poll_period = tlen/allotted_points
        for i in xrange(allotted_points):
            points.append(rtcmix.samptable(table, i * poll_period))
    #turn printing back on if it was off
    if printing_was_on:
        rtcmix.print_on()
    return rtcmix.maketable('literal', len(points), points)