First the question, then the context.
How would I go about adding corresponding elements of arrays passed in as a variable length argument list?
Now context and attempted progress:
I've created functions to generate sound waves as raw data, and I'm trying to write a function to combine multiple arrays of said data. It's been quite a trip, since this is the first time I've ever used Python. I tried using a "for in" loop to add each element to each other to create a third array, but it only appended the arrays. Since that version, I've changed my system a bit. I'm working on a function called CombineWaves() that takes in a variable length argument list, but I have no idea how to go about working with an array of arrays in Python.
My original setup worked like this. I had global variables "data" and "cumulativeData". Each wave generator output to "data", then CombineWaves() was called to add the corresponding elements of the arrays.
def CombineWaves(self): for i in range(len(self.cumulativeData)): self.cumulativeData[i] += self.data[i]
This appended data to cumulativeData. I still have no idea why.
After a few more attempts, I decided that I wanted my CombineWaves() to take in any number of waves. Here is an example of a function call for it.
gen.CombineWaves(gen.GenerateSineWave(3, 800, 25), gen.GenerateSquareWave(3, 800, 50), gen.GenerateSawtoothWave(3,800,50))
I'm thinking that gathering a general understanding of how to work with variable length argument lists to a function would help solve my problem. I've poked around on Google, but a few snippets of code I've seen don't produce as advertised. I'm just sleep deprived and confused X-D
Any and all help is much appreciated ^.^
This post has been edited by TheBeege: 05 April 2009 - 10:39 PM