Pulse harmonics calculator

To create a Pulse train wavetable in Pure Data it is possible to use the cosinesum 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 pulse train we need that all harmonics have the same amplitude.

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 cosinesum command in Pure Data.

out_file=open("Coef-Pulse.txt","w")
MaxOrder=511
#The maximum number of harmonics to be computed in the table
x=round((1./MaxOrder),6)
out_file.write(str(0)+" ") #The DC component is equal to 0

for i in range(1,MaxOrder+1):
    out_file.write(str(x)+" ")
    #All the harmonics have the same amplitude
out_file.close()

Pulse-WaveTable

Contact me for help, comments and suggestions.