Triangle/Saw/Ramp PWM Equation
Date | 2016-07-12 17:11 |
From | Emmett Palaima |
Subject | Triangle/Saw/Ramp PWM Equation |
Hi, I am trying to figure out how to program an equation that when given a control value would cycle smoothly between a saw at one end, a triangle in the middle and a ramp at the other end.
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Can anyone recommend a good function/method for doing this? I saw that the vco opcode has its feature, but I was having trouble decoding how it achieved this effect. I have come up with several methods that work for producing the 3 wave types, but the wave forms that occur in between have weird jumps in them, which I'm hoping to avoid. Thanks! |
Date | 2016-07-12 17:22 |
From | Anton Kholomiov |
Subject | Re: Triangle/Saw/Ramp PWM Equation |
I think that it's better to generate all three waveforms at the same time to get band limited result and then use `ntrpol` to crossfade between them: ~~~ aSaw vco2 1, kcps, iSawId aTri vco2 1, kcps, iTriangleId aRamp vco2 1, kcps, iRampId ares ntrpol aSaw, aTri, kcoeff, 0, 0.5 else ares ntrpol aTri, aRamp, kcoeff, 0.5, 1 endif ~~~ Or maybe we can try out to give some interval in the middle say (0.45, 0.55) to triangle only. Maybe it can produce more stable transition. 2016-07-12 19:11 GMT+03:00 Emmett Palaima <epalaima@berklee.edu>:
|
Date | 2016-07-12 17:53 |
From | Paul Batchelor |
Subject | Re: Triangle/Saw/Ramp PWM Equation |
I've typically done this by crossfading waveforms in a table-lookup oscillator. I have a modified version of oscili in soundpipe that does just this:https://github.com/PaulBatchelor/Soundpipe/blob/master/modules/oscmorph.c On Tue, Jul 12, 2016 at 9:22 AM, Anton Kholomiov <anton.kholomiov@gmail.com> wrote:
|
Date | 2016-07-12 19:42 |
From | Tarmo Johannes |
Subject | Re: Triangle/Saw/Ramp PWM Equation |
Of the top of my head, there is also tablemix opcode that works well. 12.07.2016 19:53 kirjutas kuupäeval "Paul Batchelor" <ralphbluecoat@gmail.com>:
Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
|
Date | 2016-07-12 21:10 |
From | Ffanci Silvain |
Subject | Re: Triangle/Saw/Ramp PWM Equation |
Anton Kholomiov, Jul 12 2016: > I think that it's better to generate all three waveforms at the same time > to get band limited result > and then use `ntrpol` to crossfade between them: ... Anton, will this version result in a sound resebling a crossfade in loudness of two waves or can it sort of fade between the spectra? ... Ta-ta, ---- Ffanci * Homepage: https://freeshell.de/~silvain * Twitter: http://twitter.com/ffanci_silvain * GitHub: https://github.com/fsilvain Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2016-07-12 21:20 |
From | Ffanci Silvain |
Subject | Re: Triangle/Saw/Ramp PWM Equation |
Emmett Palaima, Jul 12 2016: > Hi, I am trying to figure out how to program an equation that when given a > control value would cycle smoothly between a saw at one end, a triangle in > the middle and a ramp at the other end. Emmett, I discovered a formula to generate a waveform approaching a sawtooth - or you can use vco2 - and I found a way to blend between sawtooth and square wave. I didn't, however, find a way to change the squarewave spectrum to resemble a triangle. But, PWM can be performed. Does anyone know a method to synthesize a sqaurewave in such a way, that it can be changed to a triangle. I know that it can be done with additive synthesis, but that it too CPU hungry for my application. I thought about adding a lowpass filter in my tone generator. For that to work I'd need to know how to set up the filter exactly, which I don't. My waveform synthesis is based on a wave distortion method shown in a paper written, or co-written, by Victor Lazzarini. Unfortunately, I haven't discovered a good parameter tweak to morph from square to triangle spectra. Any ideas perhaps? I'd be happy to share my meagre code and the general theory to morph between saw and square and do the PWM. ... Ta-ta, ---- Ffanci * Homepage: https://freeshell.de/~silvain * Twitter: http://twitter.com/ffanci_silvain * GitHub: https://github.com/fsilvain Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2016-07-12 21:25 |
From | Richard |
Subject | Re: Triangle/Saw/Ramp PWM Equation |
The mathematical method to change a square wave into a triangle is integration... Richard On 12/07/16 22:20, Ffanci Silvain wrote: > Emmett Palaima, Jul 12 2016: > >> Hi, I am trying to figure out how to program an equation that when >> given a >> control value would cycle smoothly between a saw at one end, a >> triangle in >> the middle and a ramp at the other end. > Emmett, > I discovered a formula to generate a waveform approaching a sawtooth - > or you can use vco2 - and I found a way to blend between sawtooth and > square wave. I didn't, however, find a way to change the squarewave > spectrum to resemble a triangle. But, PWM can be performed. > > Does anyone know a method to synthesize a sqaurewave in such a way, > that it can be changed to a triangle. I know that it can be done with > additive synthesis, but that it too CPU hungry for my application. I > thought about adding a lowpass filter in my tone generator. For that > to work I'd need to know how to set up the filter exactly, which I > don't. My waveform synthesis is based on a wave distortion method > shown in a paper written, or co-written, by Victor Lazzarini. > Unfortunately, I haven't discovered a good parameter tweak to morph > from square to triangle spectra. > > Any ideas perhaps? I'd be happy to share my meagre code and the > general theory to morph between saw and square and do the PWM. > ... > > Ta-ta, > ---- > Ffanci > * Homepage: https://freeshell.de/~silvain > * Twitter: http://twitter.com/ffanci_silvain > * GitHub: https://github.com/fsilvain > > Csound mailing list > Csound@listserv.heanet.ie > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND > Send bugs reports to > https://github.com/csound/csound/issues > Discussions of bugs and features can be posted here Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2016-07-12 21:26 |
From | Ffanci Silvain |
Subject | Re: Triangle/Saw/Ramp PWM Equation |
Richard, Jul 12 2016: > The mathematical method to change a square wave into a triangle is > integration... Thank you, Richard. I'll give that a go from within Csound and see where it takes me. Otherwise, there's always python. ... Ta-ta, ---- Ffanci * Homepage: https://freeshell.de/~silvain * Twitter: http://twitter.com/ffanci_silvain * GitHub: https://github.com/fsilvain Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2016-07-12 22:13 |
From | Victor Lazzarini |
Subject | Re: Triangle/Saw/Ramp PWM Equation |
Try this: instr 1 a1 vco2 1,p5,10 a2 integ a1 a3 dcblock2 a2 out a3*p4 endin schedule(1,0,10,500,200) ======================== Dr Victor Lazzarini Dean of Arts, Celtic Studies and Philosophy, Maynooth University, Maynooth, Co Kildare, Ireland Tel: 00 353 7086936 Fax: 00 353 1 7086952 > On 12 Jul 2016, at 21:26, Ffanci Silvain |
Date | 2016-07-12 23:19 |
From | Ffanci Silvain |
Subject | Re: Triangle/Saw/Ramp PWM Equation |
Victor Lazzarini, Jul 12 2016: > Try this: > > instr 1 > a1 vco2 1,p5,10 > a2 integ a1 > a3 dcblock2 a2 > out a3*p4 > endin Hey hey Victor, this works really well, thank you. Unfortunately, there is still one feature that I can't realise with this solution: blending from a sqaurewave to a triangle. Is there a CPU friendly algorithm that can directly morph or cross synthesize between two waves? I think that the FFT based solutions wouldn't allow approximately 40 such operations in parallel on a 900MHz quadcore ARM architecture? Does anyone know what a typical virtual analogue synth writer would do to create such an oscillator architecture? It was - I think - implemented in the Yamaha AN1X and, there was a setting for the Clavia Nordlead 3 that could morph from a sine to a saw. That would be quite sufficient. ... Ta-ta, ---- Ffanci * Homepage: https://freeshell.de/~silvain * Twitter: http://twitter.com/ffanci_silvain * GitHub: https://github.com/fsilvain Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |