#!/usr/bin/python from random import randint def array_sum(array): sum=0 for sample in array: sum=sum+sample return sum def pink_noise(number_of_dice,size_of_die): array=[] dice=[] for x in range(number_of_dice): dice.append(randint(1,size_of_die)) array.append(array_sum(dice)) for sample in range(1,2**number_of_dice): for x in range(number_of_dice): if sample%(2**x) == 0: dice[x]=randint(1,size_of_die) array.append(array_sum(dice)) ##### scale between 0 and array_max: array_min=min(array) for item in range(len(array)): array[item]=array[item]-array_min return array def selfsimilar_pink_noise(depth,phrase_length): array=[] phrase=[] pointers=[] for x in range(phrase_length): phrase.append(randint(1,6)) for x in range(depth): pointers.append(0) for sample in range(2**depth): for x in range(depth): if sample%(2**x) == 0: pointers[x]=(pointers[x]+1) % phrase_length sum=0 for point in pointers: sum=sum+phrase[point] array.append(sum) #### scaled between 0 and array_max: array_min=min(array) for item in range(len(array)): array[item]=array[item]-array_min return array def sspn_linear(total_length, phrase_length, size_of_die): array=[] phrase=[] pointers=[] for x in range(phrase_length): phrase.append(randint(1,size_of_die)) pointers.append(0) for sample in range(total_length): for x in range(1,phrase_length+1): if sample % x == 0: pointers[x-1]=(pointers[x-1]+1) % phrase_length sum=0 for point in pointers: sum=sum+phrase[point] array.append(sum) #### scaled between 0 and array_max: array_min=min(array) for item in range(len(array)): array[item]=array[item]-array_min return array