import wave from array import array import struct import math class Zero: def __init__(self): self.sarigama = [] self.padanisa = [ [[0,0],0,0], [[0,0],0,0], [[0,0],0,0], [[0,0],0,0], [[0,0],0,0], [[0,0],0,0], [[0,0],0,0] ] for s in range(7): if s == 0: w = wave.open("food1.wav", "r") elif s == 1: w = wave.open("food2.wav", "r") elif s == 2: w = wave.open("food3.wav", "r") elif s == 3: w = wave.open("food4.wav", "r") elif s == 4: w = wave.open("food5.wav", "r") elif s == 5: w = wave.open("food6.wav", "r") else: w = wave.open("food7.wav", "r") buf = w.readframes(w.getnframes()) self.sarigama.append(list(struct.unpack('%dh' % (len(buf) / w.getsampwidth()), buf))) w.close self.padanisa[s][1] = len(self.sarigama[s])-1 print "makin song", s, "vector oriented" tmp = self.sarigama[s][0] for g in range(1,self.padanisa[s][2]+1): self.sarigama[s][g-1] = self.sarigama[s][g]-tmp tmp = self.sarigama[s][g] del self.sarigama[s][-1] mn = min(self.sarigama[s]) d = float(max(self.sarigama[s])-mn) for g in range(self.padanisa[s][1]): self.sarigama[s][g] = int(32767*((self.sarigama[s][g]-mn)/d)) self.padanisa[s][2] = max(self.sarigama[s]) # [[whereyang,whereyin], length, max] self.yinyang = [[0,1,2,3,4,5,6],[0,1,2,3,4,5,6]] self.sang = [[],[0,44100]] # [smallest,erectionwidth] self.thang = [7887,34543] def age(self,w,y,yy): self.padanisa[w][0][yy] = (self.padanisa[w][0][yy]+y)%self.padanisa[w][1] def o_m_r(self,x,y,z,yy): self.padanisa[x][0][yy] = (self.padanisa[x][0][yy]+int(z*self.sarigama[y][self.padanisa[y][0][yy]]/float(self.padanisa[y][2])))%self.padanisa[x][1] def noiz(self,wyy,yy): w = self.yinyang[yy][wyy] self.padanisa[w][0][yy] = (self.padanisa[w][0][yy]+1)%self.padanisa[w][1] return self.sarigama[w][self.padanisa[w][0][yy]]/float(self.padanisa[w][2]) def sine(self,wyy,yy): w = self.yinyang[yy][wyy] self.padanisa[w][0][yy] = (self.padanisa[w][0][yy]+1)%self.padanisa[w][1] return 0.5 + 0.5 * math.sin(math.radians(360*self.padanisa[w][0][yy]/float(self.padanisa[w][1]))) def sn_g(self,yy): s = self.yinyang[yy][0] g = self.yinyang[yy][2] self.age(g,1,yy) self.o_m_r(s,g,100,yy) return self.sarigama[s][self.padanisa[s][0][yy]]/float(self.padanisa[s][2]) def ss_g(self,yy): s = self.yinyang[yy][0] g = self.yinyang[yy][2] self.age(g,1,yy) self.o_m_r(s,g,100,yy) return 0.5 + 0.5 * math.sin(math.radians(360*self.padanisa[s][0][yy]/float(self.padanisa[s][1]))) def sn_r_g(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] self.age(g,1,yy) self.o_m_r(r,g,100,yy) self.o_m_r(s,r,100,yy) return self.sarigama[s][self.padanisa[s][0][yy]]/float(self.padanisa[s][2]) def ss_r_g(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] self.age(g,1,yy) self.o_m_r(r,g,100,yy) self.o_m_r(s,r,100,yy) return 0.5 + 0.5 * math.sin(math.radians(360*self.padanisa[s][0][yy]/float(self.padanisa[s][1]))) def sn_r_g_d(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] d = self.yinyang[yy][5] self.age(d,1,yy) self.o_m_r(g,d,100,yy) self.o_m_r(r,g,100,yy) self.o_m_r(s,r,100,yy) return self.sarigama[s][self.padanisa[s][0][yy]]/float(self.padanisa[s][2]) def ss_r_g_d(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] d = self.yinyang[yy][5] self.age(d,1,yy) self.o_m_r(g,d,100,yy) self.o_m_r(r,g,100,yy) self.o_m_r(s,r,100,yy) return 0.5 + 0.5 * math.sin(math.radians(360*self.padanisa[s][0][yy]/float(self.padanisa[s][1]))) def sn_r_g_m_d(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] m = self.yinyang[yy][3] d = self.yinyang[yy][5] self.age(d,1,yy) self.o_m_r(m,d,100,yy) self.o_m_r(g,m,100,yy) self.o_m_r(r,g,100,yy) self.o_m_r(s,r,100,yy) return self.sarigama[s][self.padanisa[s][0][yy]]/float(self.padanisa[s][2]) def ss_r_g_m_d(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] m = self.yinyang[yy][3] d = self.yinyang[yy][5] self.age(d,1,yy) self.o_m_r(m,d,100,yy) self.o_m_r(g,m,100,yy) self.o_m_r(r,g,100,yy) self.o_m_r(s,r,100,yy) return 0.5 + 0.5 * math.sin(math.radians(360*self.padanisa[s][0][yy]/float(self.padanisa[s][1]))) def sn_r_g_m_d_n(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] m = self.yinyang[yy][3] d = self.yinyang[yy][5] n = self.yinyang[yy][6] self.age(n,1,yy) self.o_m_r(d,n,100,yy) self.o_m_r(m,d,100,yy) self.o_m_r(g,m,100,yy) self.o_m_r(r,g,100,yy) self.o_m_r(s,r,100,yy) return self.sarigama[s][self.padanisa[s][0][yy]]/float(self.padanisa[s][2]) def ss_r_g_m_d_n(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] m = self.yinyang[yy][3] d = self.yinyang[yy][5] n = self.yinyang[yy][6] self.age(n,1,yy) self.o_m_r(d,n,100,yy) self.o_m_r(m,d,100,yy) self.o_m_r(g,m,100,yy) self.o_m_r(r,g,100,yy) self.o_m_r(s,r,100,yy) return 0.5 + 0.5 * math.sin(math.radians(360*self.padanisa[s][0][yy]/float(self.padanisa[s][1]))) def sn_r_g_m_d_p_n(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] m = self.yinyang[yy][3] p = self.yinyang[yy][4] d = self.yinyang[yy][5] n = self.yinyang[yy][6] self.age(n,1,yy) self.o_m_r(d,n,100,yy) self.o_m_r(p,d,100,yy) self.o_m_r(m,p,100,yy) self.o_m_r(g,m,100,yy) self.o_m_r(r,g,100,yy) self.o_m_r(s,r,100,yy) return self.sarigama[s][self.padanisa[s][0][yy]]/float(self.padanisa[s][2]) def ss_r_g_m_d_p_n(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] m = self.yinyang[yy][3] p = self.yinyang[yy][4] d = self.yinyang[yy][5] n = self.yinyang[yy][6] self.age(n,1,yy) self.o_m_r(d,n,100,yy) self.o_m_r(p,d,100,yy) self.o_m_r(m,p,100,yy) self.o_m_r(g,m,100,yy) self.o_m_r(r,g,100,yy) self.o_m_r(s,r,100,yy) return 0.5 + 0.5 * math.sin(math.radians(360*self.padanisa[s][0][yy]/float(self.padanisa[s][1]))) def sn_rg(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] self.age(g,1,yy) self.age(r,1,yy) rg = int(100*(self.sarigama[r][self.padanisa[r][0][yy]]+self.sarigama[g][self.padanisa[g][0][yy]])/float(self.padanisa[r][2]+self.padanisa[g][1])) self.age(s,rg,yy) return self.sarigama[s][self.padanisa[s][0][yy]]/float(self.padanisa[s][2]) def ss_rg(self,yy): s = self.yinyang[yy][0] r = self.yinyang[yy][1] g = self.yinyang[yy][2] self.age(g,1,yy) self.age(r,1,yy) rg = int(100*(self.sarigama[r][self.padanisa[r][0][yy]]+self.sarigama[g][self.padanisa[g][0][yy]])/float(self.padanisa[r][2]+self.padanisa[g][1])) self.age(s,rg,yy) return 0.5 + 0.5 * math.sin(math.radians(360*self.padanisa[s][0][yy]/float(self.padanisa[s][1]))) def mn_d(self,yy): m = self.yinyang[yy][3] d = self.yinyang[yy][5] self.age(d,1,yy) self.o_m_r(m,d,100,yy) return self.sarigama[m][self.padanisa[m][0][yy]]/float(self.padanisa[m][2]) def ms_d(self,yy): m = self.yinyang[yy][3] d = self.yinyang[yy][5] self.age(d,1,yy) self.o_m_r(m,d,100,yy) return 0.5 + 0.5 * math.sin(math.radians(360*self.padanisa[m][0][yy]/float(self.padanisa[m][1]))) def pn_n(self,yy): p = self.yinyang[yy][4] n = self.yinyang[yy][6] self.age(n,1,yy) self.o_m_r(p,n,100,yy) return self.sarigama[p][self.padanisa[p][0][yy]]/float(self.padanisa[p][2]) def ps_n(self,yy): p = self.yinyang[yy][4] n = self.yinyang[yy][6] self.age(n,1,yy) self.o_m_r(p,n,100,yy) return 0.5 + 0.5 * math.sin(math.radians(360*self.padanisa[p][0][yy]/float(self.padanisa[p][1]))) def yang(self): return self.noiz(0,0) def yin(self): return (self.sine(3,1)+self.sine(4,1))/2 def twist(self): sa = self.sarigama[0][self.padanisa[0][0][0]] ri = self.sarigama[1][self.padanisa[1][0][1]] ga = self.sarigama[2][self.padanisa[2][0][1]] ma = self.sarigama[3][self.padanisa[3][0][1]] pa = self.sarigama[4][self.padanisa[4][0][1]] da = self.sarigama[5][self.padanisa[5][0][0]] ni = self.sarigama[6][self.padanisa[6][0][0]] if (self.padanisa[0][1]+self.padanisa[3][2]+self.padanisa[4][2]+sa+ri+ga+ma+pa+da+ni)%11111 == 7: thi = (self.sarigama[0][self.padanisa[0][0][0]]+self.sarigama[4][self.padanisa[4][0][1]])%7 tha = (self.sarigama[3][self.padanisa[3][0][1]]+self.sarigama[4][self.padanisa[4][0][0]])%7 thiv = self.yinyang[0][thi] thav = self.yinyang[0][tha] print "ya twist", thiv, "<->", thav self.yinyang[0][thi] = thav self.yinyang[0][tha] = thiv thi = (self.sarigama[0][self.padanisa[0][0][1]]+self.sarigama[3][self.padanisa[3][0][1]])%7 tha = (self.sarigama[4][self.padanisa[4][0][1]]+self.sarigama[3][self.padanisa[3][0][0]])%7 thiv = self.yinyang[1][thi] thav = self.yinyang[1][tha] print "yi twist", thiv, "<->", thav self.yinyang[1][thi] = thav self.yinyang[1][tha] = thiv def reincarnate(self, a_value): w = (a_value+self.sang[1][0])%7 if w == 0 or w == 3 or w == 4: w = w + 2 if a_value%11 == 7 or self.sang[1][0] < int(0.75*self.sang[1][1]): print "generating new idea por",w,"instead of bringin out odor" sa = self.sarigama[0][self.padanisa[0][0][0]] ri = self.sarigama[1][self.padanisa[1][0][0]] ga = self.sarigama[2][self.padanisa[2][0][0]] ma = self.sarigama[3][self.padanisa[3][0][1]] pa = self.sarigama[4][self.padanisa[4][0][1]] da = self.sarigama[5][self.padanisa[5][0][1]] ni = self.sarigama[6][self.padanisa[6][0][1]] chz = (a_value+sa+ma+pa)%5 if chz == 0: self.sarigama[w] = sum([y*[x] for y in [sa%2500,ma%2500,pa%2500] for x in [ri,ga,da,ni]],[]) elif chz == 1: self.sarigama[w] = sum([y*[(y+x)/2] for y in [ni%555,da%555,pa%555,ma%555,ga%555,ri%555,sa%555] for x in [sa,ri,ga,ma,pa,da,ni]],[]) elif chz == 2: srgmpdn = [sa%100,ri%100,ga%100,ma%100,pa%100,da%100,ni%100] self.sarigama[w] = sum([z*[(y+x)%23232] for z in srgmpdn for y in srgmpdn for x in srgmpdn],[]) elif chz == 3: srgmpdn = [a_value%(sa+1),a_value%(ri+1),a_value%(ga+1),a_value%(ma+1),a_value%(pa+1),a_value%(da+1),a_value%(ni+1)] self.sarigama[w] = sum([z%100*[(y+x)%23232] for z in srgmpdn for y in srgmpdn for x in srgmpdn],[]) else: self.sarigama[w] = sum([z*[z+y*x] for z in [1+(ri+ga)%3,(da+ni)%5] for y in [1+ma%33,3+pa%55] for x in range(11+sa%77)],[]) self.padanisa[w][1] = len(self.sarigama[w]) if self.padanisa[w][1] == 0: self.padanisa[w][1] = 5000+a_value%10000 self.sarigama[w] = self.padanisa[w][1]*[0] self.padanisa[w][2] = 1 else: self.padanisa[w][2] = max(self.sarigama[w]) if self.padanisa[w][2] == 0: self.padanisa[w][2] = 1 self.padanisa[w][0][0] = self.padanisa[w][0][0]%self.padanisa[w][1] self.padanisa[w][0][1] = self.padanisa[w][0][1]%self.padanisa[w][1] print "length=",self.padanisa[w][1],"max=",self.padanisa[w][2],"logic=",chz self.sang[1][1] = self.thang[0]+(a_value+self.padanisa[w][1]+self.padanisa[w][2])%self.thang[1] self.sang[1][0] = 0 else: print w,"brings out odor", self.sarigama[w] = self.sang[0] self.sang[0] = [] self.padanisa[w][1] = len(self.sarigama[w]) self.padanisa[w][0][0] = self.padanisa[w][0][0]%self.padanisa[w][1] self.padanisa[w][0][1] = self.padanisa[w][0][1]%self.padanisa[w][1] self.padanisa[w][2] = max(self.sarigama[w]) self.sang[1][1] = self.thang[0]+(a_value+self.padanisa[w][1]+self.padanisa[w][2])%self.thang[1] self.sang[1][0] = 0 print "length=",self.padanisa[w][1],"max=",self.padanisa[w][2] # [where[y,y], length, max] def sing(self): self.twist() song = self.yang()-self.yin() self.sang[0].append(16383+int(16383*song)) self.sang[1][0] = self.sang[1][0]+1 if self.sang[1][0] == self.sang[1][1]: self.reincarnate(int(987654321*song)) return song def fuck(self, other_one): w = self.sang[1][0]%7 if w == 0 or w == 3 or w == 4: w = w + 2 other_one.sarigama[w].extend(self.sang[0]) other_one.padanisa[w][1] = other_one.padanisa[w][1]+self.sang[1][0] if other_one.padanisa[w][1] > 55555: d = other_one.padanisa[w][1]-55555 del other_one.sarigama[w][:d] if len(other_one.sarigama[w])-d > self.thang[0]: del other_one.sarigama[w][-d:] other_one.padanisa[w][1] = len(other_one.sarigama[w]) other_one.padanisa[w][0][0] = other_one.padanisa[w][0][0]%other_one.padanisa[w][1] other_one.padanisa[w][0][1] = other_one.padanisa[w][0][1]%other_one.padanisa[w][1] other_one.padanisa[w][2] = max(other_one.sarigama[w]) #noiz class One(Zero): def yang(self): return self.noiz(0,0) def yin(self): return (self.noiz(3,1)+self.noiz(4,1))/2 ##sin class Two(Zero): def yang(self): return self.sine(0,0) def yin(self): return (self.sine(3,1)+self.sine(4,1))/2 #noiz class Three(Zero): def yang(self): return (self.sn_g(0)+self.pn_n(0))/2 def yin(self): return (self.mn_d(1)+self.sn_rg(1))/2 #sin class Four(Zero): def yang(self): return (self.ms_d(0)+self.ss_rg(0))/2 def yin(self): return (self.ss_g(1)+self.ps_n(1))/2 #noiz class Five(Zero): def yang(self): return (2*self.sn_r_g_d(0)+(self.noiz(3,0)+self.noiz(4,0))*self.noiz(6,0))/4 def yin(self): return (self.sn_r_g(1)+self.mn_d(1)+self.noiz(4,1)*self.noiz(6,1))/3 ##sin class Six(Zero): def yang(self): return (self.ss_r_g(0)+self.ms_d(0)+self.sine(4,0)*self.sine(6,1))/3 def yin(self): return (2*self.ss_r_g_d(1)+(self.sine(3,1)+self.sine(4,1))*self.sine(6,1))/4 #mix class Seven(Zero): def yang(self): return (self.ss_r_g_m_d(0)+self.pn_n(0))/2 def yin(self): return (self.sn_r_g_m_d(1)+self.ps_n(1))/2 #mix class Eight(Zero): def yang(self): return self.ss_r_g_m_d_n(0)*self.noiz(4,0) def yin(self): return self.sn_r_g_m_d_n(1)*self.sine(4,1) #mix class Nine(Zero): def yang(self): return self.ss_r_g_m_d_p_n(0) def yin(self): return self.sn_r_g_m_d_p_n(1)