I'm not so deeply into the theory about all this, I may use strange terminology...
If I put a square wave through a simple lowpass RC filter, the output will be a sort of "rounded sawtooth", well not so much a ramp but a capacitor charge curve followed by a discharge curve.
Like this:
So I tried to replicate this in a computer program, in a band-limited form. First, I made a function to add harmonics, as weighted sum according to the typical falloff for a square wave. That alone looks indeed like a slightly lowpass filtered square on an oscilloscope.
Next I wrote a second function, which was supposed to impose the LPF frequency response curve over the harmonics envelope of the square wave, i.e. such that the weights of the summands would take into account the lowpass response.
Now, of course, the result is not the same, I get a rectangle with both corners rounded off, instead of a saw-toothy asymmetrical wave. Intuitively I'd say that what's not taken into account here is the "lag" of such a low-pass filter.
How could I mathematically incorporate this information to produce the harmonics sum the correct way? (I.e. not using a sample-based 1-pole LPF implementation)
The actual goal of this is to obtain one precisely-cut, glitch-free, loopable period of the waveform. I.e. if a harmonic falloff function is known for this type of waveform ("capacitor nonconst charge sawtooth"), like there are for other known waveforms, that would be sufficient as an answer.
P.S. feel free to add pointers to further waveforms and the way to generate them via harmonic sums - other than square, tri, saw, which are in wiki ;)