def __init__(self, *pats): l, p = [], [] for pat in pats: p.append(asStream(pat)) l.append(len(p[-1])) length = op.LCM(*l) self.data = zip(*[p[i].stretch(length) for i in range(len(p))])
def __init__(self, *patterns): self.data = [] item = [asStream(p) for p in patterns] size = op.LCM(*[len(i) for i in item]) for n in range(size): for i in item: self.data.append(op.modi(i,n)) self.make()
def PAlt(pat1, pat2, *patN): ''' Returns a Pattern generated by alternating the values in the given sequences ''' data = [] item = [asStream(p) for p in [pat1, pat2] + list(patN)] size = LCM(*[len(i) for i in item]) for n in range(size): for i in item: data.append(modi(i, n)) return Pattern(data)
def __sub__(self, other): if isinstance(other, self.__class__): new = other else: new = TimeVar(asStream(other), self.dur, self.metro) new.modifier = self new.multiplier = -1 return new
def update(self, values, dur=None): """ Updates the TimeVar with new values """ if dur is not None: self.dur = asStream(dur) if InfinityObj in self.dur: if self.dur[-1] != InfinityObj: raise else: self.has_inf = True self.data = [] a, b = 0, -1 for i, val in enumerate(asStream(values)): if isinstance(modi(self.dur, i), _infinity): # Replace infinity with a reasonable amount of time this_dur = GeomFill(Stretch(self.dur, i))[-1] else: # Get the duration for this value this_dur = modi(self.dur, i) a = b + 1 b = a + (self.metro.steps * this_dur) - 1 self.data.append(val) self.time.append((a, b)) return self
def update(self, values, dur=None): """ Updates the TimeVar with new values """ if dur is not None: self.dur=asStream(dur) if InfinityObj in self.dur: if self.dur[-1] != InfinityObj: raise else: self.has_inf = True self.data = [] a, b = 0, -1 for i, val in enumerate(asStream(values)): if isinstance(modi(self.dur,i), _infinity): # Replace infinity with a reasonable amount of time this_dur = GeomFill(Stretch(self.dur, i))[-1] else: # Get the duration for this value this_dur = modi(self.dur, i) a = b + 1 b = a + (self.metro.steps * this_dur) - 1 self.data.append( val ) self.time.append((a,b)) return self