proper pulse width for SM OSCs

Suggest new features, components or other changes to the software

Moderator: electrogear

proper pulse width for SM OSCs

Postby infuzion on Sun Dec 30, 2007 11:08 am

With the correct PWM, bandlimiting, etc.
Requested twice in the past week. I have to agree that people who use & make synths expect Square PWM be apart of the toolbox. SE, Reactor, C++ SDKs have PWM as standard, as well as most commercial & many free VSTis.

Thanks to stefan's great help, here is what we have so far:
http://www.synthmaker.co.uk/dokuwiki/do ... :lab#jan07
Useable, but not quite a v1.0 release yet: I’m hoping for a phase-fix for the Square PWMod; I want all my OSCs to start their cycles positively! :) Also I would still like feed back from the updated Multi-OSC's output being reduced please.
cheers
Last edited by infuzion on Tue Jan 08, 2008 5:59 am, edited 2 times in total.
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6169
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Re: proper Square OSC

Postby TomC on Sun Dec 30, 2007 1:50 pm

infuzion wrote:With the correct PWM, bandlimiting, etc.
I tried adjusting SM's Square module using some code... ended up using Stream Power, 2 mults, add, and a compare. & still only had 0-50% width.
My solution isn't bandlimited, so it will be bad at high pitches. & sounds, urm synthy. One can use an Wave Draw hack, but modulating a Float Array at samplerate is asking for trouble.
related:
http://synthmaker.co.uk/forum/viewtopic.php?t=5103
I swear this worked before, but doesn't anymore:
http://synthmaker.co.uk/forum/viewtopic.php?t=3942
cheers


I'm not exactly what you'd call a PWM expert, but should the results look
somehow like this?


Image

Image

If so it'll be simple.



Tom
.signature failure
User avatar
TomC
smanatic
 
Posts: 709
Joined: Tue Oct 02, 2007 9:34 pm
Location: 3rd rock from the sun

Postby infuzion on Sun Dec 30, 2007 3:19 pm

Yes, that's what I got:
Code: Select all
streamin osc;streamin pwm;
streamout o;
o=1+(osc<pwm)&-2;
But it isn't anti-aliased, so it will sound weird, esp on higher freq. Not unless you have some anit-aliasing Code laying around...
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6169
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Postby TomC on Sun Dec 30, 2007 3:39 pm

infuzion wrote:Yes, that's what I got:
Code: Select all
streamin osc;streamin pwm;
streamout o;
o=1+(osc<pwm)&-2;
But it isn't anti-aliased, so it will sound weird, esp on higher freq. Not unless you have some anit-aliasing Code laying around...


Do you have a sound example that shows PWM aliased/unaliased so that
can hear how it SHOULD sound?.

Cheers,


Tom
.signature failure
User avatar
TomC
smanatic
 
Posts: 709
Joined: Tue Oct 02, 2007 9:34 pm
Location: 3rd rock from the sun

Postby infuzion on Mon Dec 31, 2007 5:41 am

TomC wrote:Do you have a sound example that shows PWM aliased/unaliased so that can hear how it SHOULD sound?.
No audio samples right now, but using SM's FFT I do notice a big difference between SM's OSCs and the Code.
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6169
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Postby stefan on Wed Jan 02, 2008 8:17 am

Subtracting one saw from another and modulating the phase difference between them works as it should. In some cases it might be better to modulate both phases, but in opposite "directions", than modulating just one of them.
Stefan
User avatar
stefan
smunatic
 
Posts: 2386
Joined: Wed Dec 15, 2004 9:24 pm
Location: Gothenburg, Sweden

Postby infuzion on Wed Jan 02, 2008 5:22 pm

stefan wrote:Subtracting one saw from another and modulating the phase difference between them works as it should. In some cases it might be better to modulate both phases, but in opposite "directions", than modulating just one of them.
Seems not anymore?
http://synthmaker.co.uk/forum/viewtopic ... ulse+width
http://www.synthmaker.co.uk/dokuwiki/do ... e8:lab#pwm
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6169
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Postby stefan on Thu Jan 03, 2008 6:35 am

Apart from distorting the DS Out and having the wrong range of the pulse width control that one seems correct? The "min" and "max" of the waveform SHOULD move away from -1 and +1 when you change the pulse width, otherwise you will introduce a DC offset in the waveform.

I corrected the volume and PWM range here.
Stefan
User avatar
stefan
smunatic
 
Posts: 2386
Joined: Wed Dec 15, 2004 9:24 pm
Location: Gothenburg, Sweden

Postby infuzion on Fri Jan 04, 2008 5:38 am

stefan wrote:I corrected the volume and PWM range here.

Thanks stefan!
Your solution works well, but too much quieter than the "stock" SM Square. Building upon your ideas, I came up with this:
http://www.synthmaker.co.uk/dokuwiki/do ... e8:lab#pwm
Warning: the DC offset might be a tad off, since my eyeballed the offset. Any more tweaking here would be great.
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6169
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Postby stefan on Fri Jan 04, 2008 6:40 am

infuzion wrote:
stefan wrote:I corrected the volume and PWM range here.

Thanks stefan!
Your solution works well, but too much quieter than the "stock" SM Square. Building upon your ideas, I came up with this:
http://www.synthmaker.co.uk/dokuwiki/do ... e8:lab#pwm
Warning: the DC offset might be a tad off, since my eyeballed the offset. Any more tweaking here would be great.


But you're doing it all wrong! :) By adding DC stuff you just, uhm, add DC.

If mine is too silent, just remove the * 0.5, but be aware that it will shoot outside of the +/- 1 range when having a non-symmetrical pulse width.
Stefan
User avatar
stefan
smunatic
 
Posts: 2386
Joined: Wed Dec 15, 2004 9:24 pm
Location: Gothenburg, Sweden

Postby infuzion on Fri Jan 04, 2008 7:15 am

stefan wrote:But you're doing it all wrong! :) By adding DC stuff you just, uhm, add DC.
I guess I don't understand DC. cheers
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6169
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Postby infuzion on Fri Jan 04, 2008 7:28 am

infuzion wrote:
stefan wrote:But you're doing it all wrong! :) By adding DC stuff you just, uhm, add DC.
I guess I don't understand DC. cheers
I really really don't understand your version stefan; when I change the PW to say around 0.5, the signal range of your version is about 0.23 to -0.66! To me, this would be very wrong; I would assume the pulse would be mirrored around 0, so the range should be +/-0.66 or whatever.
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6169
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Postby stefan on Fri Jan 04, 2008 7:41 am

infuzion wrote:
infuzion wrote:
stefan wrote:But you're doing it all wrong! :) By adding DC stuff you just, uhm, add DC.
I guess I don't understand DC. cheers
I really really don't understand your version stefan; when I change the PW to say around 0.5, the signal range of your version is about 0.23 to -0.66! To me, this would be very wrong; I would assume the pulse would be mirrored around 0, so the range should be +/-0.66 or whatever.


It's the average value of the waveform that matters. The integral is, and should be if you want zero DC offset, zero. So when the "length" of the positive side goes to zero, the "bottom" of the wave must rise towards zero as well, otherwise we will end up with a wave having an average close to -1.
Stefan
User avatar
stefan
smunatic
 
Posts: 2386
Joined: Wed Dec 15, 2004 9:24 pm
Location: Gothenburg, Sweden

Postby infuzion on Sat Jan 05, 2008 8:45 am

stefan wrote:It's the average value of the waveform that matters.
Ohhhh! I was thinking median of 0 when you meant mean=0! My bad mistake :) Silly English language.

Hopefully last update: 0.9
http://www.synthmaker.co.uk/dokuwiki/do ... e8:lab#pwm
I think your method of making the offset adjust the first OSC, then subtracting the 2 is best. Make the Square faster since it saves a -Mult! I inserted an input adjustment to prevent the output from flat lining to 0, & inverted it to make 0=no adjustment, 1=max.

I also updated the Multi OSC to test this out: Also reducing the other OSCs' amplitude by half to match the Square PW... what do you think of that?
Need help? First search the forum & WiKi, then post in the help forum with a clear topic, request, & OSM. Then please WiKi the correct solution. If you want my personal assistance, I charge by the hour or for an exchange of services.
infuzion
smstar
smstar
 
Posts: 6169
Joined: Wed May 04, 2005 8:02 pm
Location: Earth, USA, CO, Denver

Postby stefan on Mon Jan 07, 2008 7:37 am

infuzion wrote:Hopefully last update: 0.9
http://www.synthmaker.co.uk/dokuwiki/do ... e8:lab#pwm
I think your method of making the offset adjust the first OSC, then subtracting the 2 is best. Make the Square faster since it saves a -Mult! I inserted an input adjustment to prevent the output from flat lining to 0, & inverted it to make 0=no adjustment, 1=max.

Sounds good, remember however that when doing very fast PWM, you will probably end up moving the average frequency too, since you're only adjusting the phase on "one side", so to speak. For normal PWM duties, you won't notice a difference, and it uses less CPU, but if you start fiddling around with audio rate modulations you might need to use the "bipolar" kind of modulation (where one phase modulator is going up and the other down, like in my example).

infuzion wrote:I also updated the Multi OSC to test this out: Also reducing the other OSCs' amplitude by half to match the Square PW... what do you think of that?


Not sure about the amplitude thingy (not about any of the choices!), but apart from that, good! It doesn't really fit in in the Multi OSC though imho, since it offers something none of the other waveforms does. Kind of like throwing in a 2-op FM oscillator in there, for instance.
Stefan
User avatar
stefan
smunatic
 
Posts: 2386
Joined: Wed Dec 15, 2004 9:24 pm
Location: Gothenburg, Sweden

Next

Return to Ideas and Requests

Who is online

Users browsing this forum: No registered users and 2 guests

cron