To create a Square wave wavetable in Pure Data it is possible to use the sinesum command associated to an array. The arguments to provide to this command are: the desired size of the table (a power of two number) and a list of number that define the amplitude of the various harmonics.
To create a square wave we need to use only odd harmonics and their amplitude has to be inversely proportional to the order of the harmonic.
The following python code create a text file containing the sequence of the harmonics amplitude up to a given order (defined with the MaxOrder variable). Use python to run the script, then open the new text file that has been created, copy the list of number and paste them as argument of the sinesum command in Pure Data.
out_file=open("Coef-Square.txt","w") MaxOrder=100 #The maximum number of harmonics to be computed in the table for i in range(1,MaxOrder+1): if i%2==0: out_file.write(str(0)+" ") #For square wave all the even harmonics are equal to 0 else: x=round((1./i),6) out_file.write(str(x)+" ") #For square wave we use only odd harmonics! out_file.close()
Contact me for help, comments and suggestions.