iterating initalizations

Rhodri James rhodri at wildebst.demon.co.uk
Tue Dec 23 16:38:34 EST 2008


On Tue, 23 Dec 2008 15:39:52 -0000, Aaron Stepp <stepp.aaron at gmail.com>  
wrote:

> import random
> from rtcmix import *
> from chimes_source import * # Chime.play()
> from rhythmblock import * # rhythmBlock.rhythmTwist() and  
> rhythmBlock.printStuff()
> from pitchblock import * # pitchBlock.pitchTwist() and  
> pitchBlock.printStuff()
> from lenEval import *  #greaterThan.sovler()
>
> indexrand = random.Random()
> indexrand.seed(2)
>
> chime = Chime()
> notes = pitchBlock()
> rhythm = rhythmBlock()
> solve = greaterThan()
>
> class arrayBlock:
> 	
> 	def __init__(self, theTempo, start):
> 		self.__A = []
> 		self.__B = []
> 		self.__start = start
> 		self.__tempo = theTempo
>
> 	def player(self, length, tempo, octave, pan, seed):
> 	
> 		tempo = (120, self.__tempo)
>
> 		for a in range(length):
> 	
> 			one = indexrand.randint(0, 3)
> 	
> 			two = indexrand.randint(0, 7)
>
> 			self.__A = self.__A + notes.pitchTwist(one , two)
>
> 		for b in range(length):
> 	
> 			one = indexrand.randint(0, 3)
> 	
> 			two = indexrand.randint(0, 7)
>
> 			self.__B = self.__B + rhythm.rhythmTwist(one , two)
> 		
> 		lenA = len(self.__A)
> 		lenB = len(self.__B)
>
> 		var = solve.solver(lenA, lenB)
>
>
> 		for c in range(var):
> 		
> 			print self.__A[c]
>
> 			self.__start = self.__start + tb(self.__B[var])
> 			
> 			chime.play(self.__start, self.__A[var], octave, pan, seed)
> 			
> This almost does exactly what I want, and is far cleaner than my  
> previous attempts.
>
> The only problem is that now all my arguments are being passed as zeros!

Which "all" your arguments?  There are an awful lot there; what *exactly*  
do
you mean?

> I assume this has to do with WHEN I'm referencing self.__A and self.__B?

If you mean __A and __B are full of zeroes, then you should suspect your
notes.pitchTwist() and rhythm.rhythmTwist() methods of returning zeroes.

-- 
Rhodri James *-* Wildebeeste Herder to the Masses



More information about the Python-list mailing list