Dumb question – Sawtooth to triangle
Maths scares me! How can i convert a sawtooth wave into a triangle. I can do sawtooth to sine but cant suss out traingle. Driving me mad.
Also any ideas on some good reading on this sort of mathmatics.
If math scares you then think of it visually or analytically! To make a sawtooth wave look the same as a triangle wave, you would take the latter half of the sawtooth wave and flip it down, so that the wave ramps up and then ramps down, instead of the long ramp and then the jump down to "0" that a sawtooth wave does.
Here’s a patch that explains it in simple terms, albeit the process is slow and impractical:
----------begin_max5_patcher---------- 1086.3oc0Y17jZaCE.+L7Wwq9XJICR1FamacZtjCYlNS6zKcxzQXK.kXKwXI GVZlve6UeX1.aM1tKrNlCq0fr3wS+deJsec5DukhGnRO3sveASl70oSlXmxL wj5OOwqf7PZNQZWlWpnnfxUdybuSQePYm+O1PKo.Q+2RpRQKmAqHR6XNUJgB 8i8.rirWBJAjI.0FlbFrrRAuG1H1R0SPT1YgMz7sRXunxrzJdFsTpH7L8x1Y loPjwVsGHZo8E5JQYwOcTaxYbZpnhaUof5I2VRkZMlnXB9eWRSUtsqeXzalO CBhCLCyqe.er9awxraKwxO8Z+3ixeKQktgwWelXvmHFLx2Lr.ehjVI3JNofZ k2uTxH4GEGupfwyoJKYQmrbI6erKGYj8iqUToNt34lI+1zolGytVKWUIGDb3 c+9u40NxBrDCE1IvhZAXAVPgPlmwKrPa98FsXJfw0dhDPxVyI4yfT8Zok5WL CLdpLdZIkHMN05fhhs4LUUFsQ2Tb6LGmDa8uvIcR8EsPcruE39QN56.uevcD 3+UQwRM2bDMWCaZFH0XzjWfjuBDqruRR1oDB0FaxAXKsjIxfcL8Dl2thoSkX W+ywV3OetChcaKB6gs.k3RYDOZsEb5N8t4+XJd0A.+FuF10AGmz86p1uk51x dt3DuG2gMfETjyoLwM7rSMf++PEzsiJ+7As2.NrIt3eK3hKzMDMZ4xkhb+.4 yTSJSNcsNh5KTutx3YKyTOzZTFt6nLbfs9bsLumpz7doHmnbI75JQWGH0Gaa KAkf5Don1PZnSL9XGYiu6X5eRxqnxVQ3ovXd29WI1j3nE9iVVrJWnERCaOb7 ESKo+NDM8.ukD95dkcxULKb9ffA7y.CxT8gLNzUtGW1h.WM41BTvs0sUMTBB l6hW99vihpwTyuXUr0kYNzjGP3snvj6DP9CSD.5lFADb6h.vtdpGwQ.Wv230 ZW7lXCtC1zGl3JXnqWDde0K2qZtAWL5ZXRrqGj5t+GuL47vkK0RAx4n65rns LknaQYlZpgVDNxCxtXtFTzsKWy3GCWpNj4lPzNJ.povKTX2Hp24dp6RM5Y23 u+ONWE+amqRRxcpmBmrUtQnN.nlHD55KN47LhFu2yv4crdxtOosikX85iiG5 FOUh0qya5PTWNsGi2tcxsUPOdgGOwL0na5KVGAjrzlLEcdyNy5Uqz3SZg1O5 tKVkr6.fapeoq43ENlDZqzEjL3Qo1eH60C+j++XVU0L+4fRJpJSOt8Ndanv2 02LpTw311nNYQliQdxh1vxxn12eTAKXYaE5HkZk.9XilsdqS98Pmdhh+RqSl Cg1sN4On5joYstsc3QnNgFVaWbezovgUm5UbW7vZ6hGe5zSbUZwGGMb5DtO5 z.mepGpDZXC6P8wzgF3Tlgm4obAcJd30oN4TzvpS8oDLJbz4hmLnZTep0cM9 25O7so+aY+pZ. -----------end_max5_patcher-----------
Love the patch, Thx. I was trying to achieve it with just math which was hurting my head. The split object made perfect sense as soon as I saw it.
Any chance I could get some guidance on making a square wave from phasor or saw. Obviously its a case of detecting mid point of a wave, Im pretty new to all this so implementing is hard without experience.
Its more involved then I thought? Thx for help.
Another option would be to just take the absolute value of a saw wave from -1 to 1 with [abs~] to get a triangle wave that goes from 0 to 1. Using the split this way is actually a pretty awful idea if you’re doing anything with MSP, because you’re essentially downsampling from 44.1khz to below 1khz when you snapshot the values like that… and I’m not sure there’s a single MSP object that will provide that split function (though all I did to check was try to make a [split~]…)
----------begin_max5_patcher---------- 554.3oc0WssahCCD84juBK+3JJJ1w419V+NppVYRRAuBbhvFU1sp7suISRnv Jn06hsU6KYjmwL9LmLb7jWBCvKZ1Wqvnuid.ED7RXP.3p2Qv35.7F99x0bEr Mrr94lE+DOaHjtduFb+sCH1jylc500Z8uZqGRLVIVJ4qwnGG2vSMRsR7aHLg NOZzcKWWtRHW9is0k5geZbReXDcvDSmmzsHZdzwTI2sQH6NM.bzSxujuAxO9 9shtydLhnB70UA2QxvukiAHCIgz670vv9GytMR4tCnn4zDGxKjzdCKGVXIdI 247Beg5f6HERNPGwYuOoP9mHkB6QJpxl15i0+kpi3gtcFCJmDBXhIezq2Swa xkwajKvKq3L7FGczXNdSsGduRSmh+7ATrCZ6FKeBEZ6XE17+hL+nQ4BIJxX6 PJXXTaRKT6QKOstoKIWs96By03YH7Btb4+EMT.RzYvyjHKpIcEcZpSjjRuUE oTOJHMx42hfThy0ibzDSDJTzzzbqOwD6K7.SSzxvUqVcfo3upyKMwIQLqOuD 04bR6JtpYqatQeT+fPAgiTlMu55iIF3TvqEx+9Cy.j16+b1R0raa4TQOM0.5 MvVUqzBIWKZjmtozy1zJQUUMDehW1HpZaDR8HHPOdw2clhobSfDyqPxLZp3y GM4WVx.Dk7oCQ8SH5SHkYBl7LMUXBlx8KlLp+NyqXxDU.+pUFa.h7qTI0.DE 62NISfzsHBzs30v+.7DxQ2N -----------end_max5_patcher-----------
I missed your question about square waves the first time around. You’re right about detecting the midpoint of a wave, and in this case, [greaterthan~] is your friend. When you give it a signal, it outputs 1 for true and 0 for false. Given an oscillating signal as an input and the average of said signal as the argument, it’ll output a nice periodic square wave.
----------begin_max5_patcher---------- 849.3oc0XssiaBCD84juhQ7TqTBxlagTUUo9X+FZqpbHdS7tfMBLMIc0lu8Z LPtzR1vpXnou.ggggyblYNXmmGOxZgXKM2B9.7UXznmGOZj1TogQ0WOxJgrM JljqcyJRjjP4RqIU2SR2J01WkQIRZlbMguGDExzBYNfAQFfl.4QjXJPRSyDo YLkew6.o.RHOQgbQBE3B1unMwLlwoQhBtNvt0FePvk4kNorgcrQMlyVsnB9H 6P+vPGuIs9KrMB9d8yjRjQqY7U+HiFIqd3fPUDAmYkAFvtyKO4EdxyvKRX7X pTSB3SvDmjnwj0mUIVbSJvVpsIV73T2PqiwPQLMAAUZ7kwiKOL4FI+ONcCKN FHw4BXiH6oIvhBI7EPpRym.lTwz6fET0oHPvi2YaaCmUvX4JeU0BUx.zsjHI nfthczwQemcIKDwk98XQtDdPUWiD7eR4LJOhZ2ZoyePJctgHcsSeDG3WdZlu YJcAlqzwoaTg7upbeZuJS8aLW8Nj6RoU4lUNaEWAsC4xEnx1nEWmizhmeyua mUbdSrhW6rB1fMzoEw4zMrkx0ei+toJFBlVxSuu09LmAoOyyotOSKULSez0y L8YXy0m8PrPEjK1PotMQQ2f0BBe0U6qTIDKQEMk0xhvqPNHO83WnlV7Qud61 aibPMFU4YCZNBlyYLGyMYNsumLq9XimiAGMclYtQyKPKm8YCTOROZufv4ljd BFXkKj8Tr8+RQKraPE+gLtnki+8unE50Zzv3fJMKOiqY431hlE9.X9+SyxoZ 8wUTkYkrvCrjU+noWMlU0QM2nZVHywO4QhT5dqqp855U80beb01gvWKSNAuX CJKbU75M+L75hNbp63s+WieNYydvsG55pSeb0zomIa6vFbQ9FUcuMg745wtY AFWG+Bac2oWl8Bt0QufAbxqlyukIO+devKcMIWj0Oyd0D.tZWgAdlb165id5 2hdAk+wedmFok1OmsxEEYQMIcytpfifcIMWx3DISvOwox0KC3CNslsbIUe+i K0ZYpfwk0f.9dq0tthI8q6pXZ1YN06XZVGvT427FPLUpM2sZ2.xStcASngse B2ALMvzTmF6vCa6TWqb2Yc33gszE1EH4c+Ao6tdoaQrTcwKi+MvJFAST -----------end_max5_patcher-----------
But you know there are also antialiased tri~ and rect~ objects, works without math…
And if you want to go seemless from saw to triangle have a look at triangle~…
You can sync them with a phasor~…
[quote title=Bryan Dodson wrote on Wed, 29 April 2009 21:30]and I’m not sure there’s a single MSP object that will provide that split function (though all I did to check was try to make a [split~]…)
(if you use > or >= will not matter when the 0.5 will
be the 0. later!)
Right, but what I was saying is that no single object would split the signal. [>] will only give you a 0 or 1, and must be combined with a routing object as part of a sidechain in order to split the signal.
right right, as you can see i thought about non
signal, probably the coffee level was not high enough.
i also use my custom split~, btw.
|MadBeat wrote on Wed, 29 April 2009 08:16|
|Maths scares me! How can i convert a sawtooth wave into a triangle. I can do sawtooth to sine but cant suss out traingle. Driving me mad.|
A non-math way to work with this is to use [table] with its line tool to draw the shapes, then put into buffer~ with peek~. You could also use multislider with (say) 512 sliders and draw whatever wave you want, then use [pattr] to interpolate between them, which might give you some interesting new waves to play with. And of course you can just draw into waveform~ with the pencil, though there’s no direct way to interpolate.
jit.buffer~ also might give you some ideas, since you can use cool stuff like jit.xfade between two, or run it through other "video" effects, which could create some interesting new shapes you might not otherwise think of.
but math is also fun.