Hi,
I attach a patch for generating square-wave using the sinesum message. I'd like to do the same thing to generate a triangle-wave. I need to replace the [expr 1/$f1] with [expr 1/($f1*$f1)]. But I can't think of an elegant way to add the alternating + and - to the odd harmonics. Any suggestions?
Thanks a lot,
ymotion
-
Method for adding alternating +/- to a sinesum message
-
I did this, but it doesn't look very triangular...
-
Actually, i found a far easier way to do ^^
-
Hi Dwan,
The formula for triangle-wave is 1/(n^2), only odd harmonics, with alternating +-
So it should be: 1 0 -1/9 0 1/25 0 -1/49 0 1/81... I'm just looking for a convenient way to do the alternating + -.
Thanks -
Hi ymotion!
Take a look at the attachment, I used it as a part of my triangle wave generator. [mod] and [sel] objects are the answer to your question, I think.
-
That [mod 4] trick is clever. Nice, sinewave!
-
Hi Sinewave,
very nice indeed!
I found another option (attached)....
ymotion -
Hi ymotion!
I think the idea of raising the number of odd harmonics should make the triangle wave look "sharper". The waveform in your patch looks the same regardless the number of odd harmonics. Maybe I'm missing something. Anyway, take a look at the attachment, maybe you'll find it useful...
cheers! -
Hi sinewave,
yes, you're right. I've noticed that my rendering does not have sharp edges, though I don't see why we're getting different results. I square the odd harmonics and then add the alternating +/-. I see that my fifth harmonic is incorrect (should be 0.04). What am I missing?
Thanks a lot,
ymotion -
It's this bit:
- X
- I think you mean for that to be the alternating sign, but it's actually just taking the previous value, reversing the sign, and multiplying that by the new value.
-
Hi Maelstrom,
Thanks, I see that now. I think I'll adopt sinewave's method with [mod 4] for doing the alternating +/-