import wave from array import array import struct life = 44100 * 300 #sasa #srgmpdn = [[1,2],[9,16],[5,8],[3,4],[13,16],[1,4],[1,8]] #sari #srgmpdn = [[1,2],[9,16],[8,9],[81,128],[64,81],[729,1024],[512,729],[1,4],[1,8]] #saga #srgmpdn = [[1,2],[5,8],[4,5],[25,32],[16,25],[125,128],[64,125],[1,4],[1,8]] #sama #srgmpdn = [[1,2],[11,16],[8,11],[121,128],[64,121],[1331,2048],[1024,1331],[1,4],[1,8]] #sapa #srgmpdn = [[1,2],[3,4],[2,3],[9,16],[8,9],[27,32],[16,27],[1,4],[1,8]] #sada #srgmpdn = [[1,2],[13,16],[8,13],[169,256],[128,169],[2197,4096],[2048,2197],[1,4],[1,8]] #sani #srgmpdn = [[1,2],[15,16],[8,15],[225,256],[128,225],[3375,4096],[2048,3375],[1,4],[1,8]] #ga srgmpdn = [[1,2],[16,27],[27,32],[512,729],[729,1024],[1,4],[1,8]] #srgmpdn = [[1,2],[8,13],[13,16],[128,169],[169,256],[13,16],[8,26],[13,32],[1,4],[1,8]] #pa #srgmpdn = [[1,2],[9,16],[5,8],[3,4],[13,16],[7,8],[1,4],[1,8]] #srgmpdn = [[1,2],[2,3],[3,4],[1,4],[2,6],[3,8],[1,8],[2,12],[3,16]] #srgmpdn = [[11,16],[33,64],[99,128],[11,32],[33,128],[99,256],[11,64],[33,256],[99,512]] # nisa #srgmpdn = [[1,2],[5,8],[4,5],[11,16],[8,11],[3,4],[2,3],[1,4],[1,8]] # niri #srgmpdn = [[1,2],[3,4],[2,3],[13,16],[8,13],[7,8],[4,7],[1,4],[1,8]] # niga #srgmpdn = [[1,2],[19,32],[16,19],[5,8],[4,5],[3,4],[2,3],[1,4],[1,8]] # nima #srgmpdn = [[1,2],[17,32],[16,17],[3,4],[2,3],[15,16],[8,15],[1,4],[1,8]] # nipa #srgmpdn = [[1,2],[9,16],[8,9],[3,4],[2,3],[25,32],[16,25],[1,4],[1,8]] # nida #srgmpdn = [[1,2],[3,4],[2,3],[7,8],[4,7],[15,16],[8,15],[1,4],[1,8]] # nini #srgmpdn = [[1,2],[5,8],[4,5],[3,4],[2,3],[13,16],[8,13],[1,4],[1,8]] # sho #srgmpdn = [[9,8],[243,256],[27,32],[729,1024],[81,128],[1,2],[27,64],[3,8],[243,512],[9,16],[4,6],[3,4],[16,18],[2,2],[81,64],[1,4],[1,8]] # 0 = organic, 1 = griddy # when griddy use mizu[4] as [shortest, sum_of_all] mode = 1 # [lf twister, change pattern freq, foward or backward, harm twist, [shortest, longest]] mizu = [11, 5, 5, 3, [15351, 175571]] #mizu = [11, 5, 5, 3, [11111, 97579]] #mizu = [11, 3, 5, 3, [7777, 44100 * 5]] f_names = [ # "congasarigari.wav", # "radiation0.wav", # "radiation1.wav", # "radiation2.wav", "water.wav", "spice.wav", "veg.wav", "nuka.wav" ] def rsrc(fn): w = wave.open(fn, "r") b = w.readframes(w.getnframes()) s = list(struct.unpack('%dh' % (len(b) / w.getsampwidth()), b)) print (s[100], s[200], s[300]) w.close() b = [] return [s, int(len(s) / 2)] def l2h(thang): h_thang = array('h') l_thang = len(thang) for gas in range(l_thang): h_thang.append(thang[gas]) return h_thang def calcf(n, s): tf = int(n[3][n[2]][1] + n[3][n[2]][3] * (n[0] * n[3][n[2]][4][0]) / n[3][n[2]][4][1]) if int(tf / s[n[3][n[2]][0]][1]) % 2 == 0: tf = tf % s[n[3][n[2]][0]][1] else: tf = s[n[3][n[2]][0]][1] - 1 - (tf % s[n[3][n[2]][0]][1]) return tf def shikomi(p, s, v, m, o): o_len = len(o) mx = 2147483640 - v - p[2] p[0] = mx % len(s) p[1] = (mx - (1 + p[0]) * p[1]) % s[p[0]][1] p[2] = m[4][0] + (mx - p[1]) % m[4][1] if (p[1] + p[2]) % m[2] == 0: p[3] = -1 else: p[3] = 1 if (p[1] + (2 + p[3]) * p[2]) % m[3] == 0: cz = (mx - (2 + p[3]) * v) % o_len p[4][0] = o[cz][0] p[4][1] = o[cz][1] else: p[4][0] = 32 p[4][1] = 32 print(p) def sabaki(n, s, v, m, o): mx = 2147483640 - v o_len = len(o) n_len = len(n[3]) r = m[4][1] - n_len * m[4][0] for i in range(n_len): if i < n_len -1: if r == 0: n[3][i][2] = m[4][0] else: ad = (mx - n[3][i][2]) % r n[3][i][2] = m[4][0] + ad r = r - ad else: n[3][i][2] = m[4][0] + r n[3][i][0] = (mx - n[1][0] - n[3][i][4][0]) % len(s) n[3][i][1] = (mx - n[1][1] * n[3][i][2]) % s[n[3][i][0]][1] if (mx - n[3][i][1]) % m[2] == 0: n[3][i][3] = -1 else: n[3][i][3] = 1 if (n[3][i][1] + (2 + n[3][i][3]) * n[3][i][2]) % m[3] == 0: cz = (mx - (2 + n[3][i][3]) * v) % o_len n[3][i][4][0] = o[cz][0] n[3][i][4][1] = o[cz][1] else: n[3][i][4][0] = 32 n[3][i][4][1] = 32 print(n) def mazemaze(n, s, v, m, w, o): n[0] = n[0] + 1 if n[0] >= n[3][n[2]][2]: if w == 0 and v % m[1] == 0: shikomi(n[3][n[2]], s, v, m, o) elif w==1 and n[2] == (len(n[3]) - 1) and (v + n[1][1] + n[3][n[2]][1]) % m[1] == 0: sabaki(n, s, v, m, o) n[0] = 0 n[2] = (n[2] + 1) % len(n[3]) def fifo(n, s): ys = n[3][n[2]][0] yf = calcf(n, s) lr = [s[ys][0][2 * yf], s[ys][0][2 * yf + 1]] if n[0] < 1000: lr[0] = int((n[0] * lr[0]) / 1000) lr[1] = int((n[0] * lr[1]) / 1000) elif n[0] >= n[3][n[2]][2] - 1000: lr[0] = int(((n[3][n[2]][2] - n[0]) * lr[0]) / 1000) lr[1] = int(((n[3][n[2]][2] - n[0]) * lr[1]) / 1000) return lr def moritsuke(no, nu, s): yiv = fifo(no[0], s) yav = fifo(no[1], s) nu.append(int((no[0][1][0] * yiv[0] + no[1][1][0] * yav[0]) / 100)) nu.append(int((no[0][1][1] * yiv[1] + no[1][1][1] * yav[1]) / 100)) src = [] for fn in f_names: src.append(rsrc(fn)) s_len = len(src) for i in range(s_len): print('src no.', i, '=', src[i][1]) nukadoko = [ [0, [70, 30], 0, [ [0, 3400, 54100, 1, [30, 32]], [1, 44100 * 9, 72050, 1, [30, 32]], [2, 44100 * 13, 31000, 1, [32, 32]] ] ], [0, [30, 70], 0, [ [2, 44100 * 12, 51100, -1, [29, 32]], [1, 44100 * 7, 44444, 1, [25, 32]], [0, 55555, 77777, 1, [22, 32]] ] ] ] sabaki(nukadoko[0], src, 85958, mizu, srgmpdn) sabaki(nukadoko[1], src, 4316134, mizu, srgmpdn) nukaduke = [] salt = 0 kuso = 0 for f in range(life): if f % 44100 == 0: print(int(f / 44100), kuso) kuso = 0 for material in nukadoko: mazemaze(material, src, salt, mizu, mode, srgmpdn) moritsuke(nukadoko, nukaduke, src) salt = abs(nukaduke[f] + nukaduke[2 * f + 1]) salty = salt % mizu[0] if salty == 0 and nukadoko[1][1][0] > 10: nukadoko[0][1][0] = nukadoko[0][1][0] + 1 nukadoko[1][1][0] = nukadoko[1][1][0] - 1 kuso = kuso + 1 elif salty == 1 and nukadoko[0][1][0] > 10: nukadoko[0][1][0] = nukadoko[0][1][0] - 1 nukadoko[1][1][0] = nukadoko[1][1][0] + 1 kuso = kuso + 1 elif salty == 2 and nukadoko[1][1][1] > 10: nukadoko[0][1][1] = nukadoko[0][1][1] + 1 nukadoko[1][1][1] = nukadoko[1][1][1] - 1 kuso = kuso + 1 elif salty == 3 and nukadoko[0][1][1] > 10: nukadoko[0][1][1] = nukadoko[0][1][1] - 1 nukadoko[1][1][1] = nukadoko[1][1][1] + 1 kuso = kuso + 1 if f % 44100 == 0: print("duke", nukaduke[-1], nukaduke[-2]) print("tabegoro!") print(nukadoko[0][1][0], "+", nukadoko[1][1][0], "=", nukadoko[0][1][0] + nukadoko[1][1][0]) print(nukadoko[0][1][1], "+", nukadoko[1][1][1], "=", nukadoko[0][1][1] + nukadoko[1][1][1]) for i in range(10000): nukaduke[2 * i] = int((i * nukaduke[2 * i]) / 10000) nukaduke[2 * i + 1] = int((i * nukaduke[2 * i + 1]) / 10000) nukaduke[2 * life - 1 - 2 * i] = int((i * nukaduke[2 * life - 1 - 2 * i]) / 10000) nukaduke[2 * life - 2 - 2 * i] = int((i * nukaduke[2 * life - 2 - 2 * i]) / 10000) e_thang = l2h(nukaduke) a_thang = wave.open("nukaduke.wav", "w") a_thang.setnchannels(2) a_thang.setsampwidth(2) a_thang.setframerate(44100) #a_thang.writeframes(e_thang.tostring()) a_thang.writeframes(e_thang.tobytes()) a_thang.close() print('done')