From the original SynthMaker forum (2004–2014), with its members’ names and dates.
infuzion ·
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:
[old link]
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
TomC ·
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:
PWM
I swear this worked before, but doesn't anymore:
Pulse Width Modulation?
cheers
I'm not exactly what you'd call a PWM expert, but should the results look
somehow like this?
If so it'll be simple.
Tom
infuzion ·
Yes, that's what I got:
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...
TomC ·
infuzion wrote: Yes, that's what I got:
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
infuzion ·
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.
stefan ·
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.
infuzion ·
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?
oscillators
[old link]
stefan ·
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.
infuzion ·
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:
[old link]
Warning: the DC offset might be a tad off, since my eyeballed the offset. Any more tweaking here would be great.
stefan ·
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:
[old link]
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.
infuzion ·
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
infuzion ·
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.
stefan ·
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.
infuzion ·
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
[old link]
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?
stefan ·
infuzion wrote: Hopefully last update: 0.9
[old link]
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.
infuzion ·
stefan wrote: 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).
Ah, thanks for cluing me in! So we have 2 versions now: 1 using green maths for a simple knob, & the other using your method in ASM (I also have the cycle start the same as the SM Square when PW=0). Might be confusing; I'd pick your version w/my ASM if I had to pick 1.
Is there a way to ensure the wave cycle always starts positive while fixing the pitchshift issue?
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.
See first post for file & reasoning. I'd also use similar logic in stating that SM should have FM, Ring... modules shiped with the install as example OSMs, if not part of the standard toolbox: I thought SM is to appeal to those with little synth experience? That's why the "Developer" switch, etc. I'm surprised (& grateful) something as advanced as the Multi Stage ENV made it into the toolbox. PW is much more simpler & expected then the MSE IMHO.
cheers
stefan ·
infuzion wrote: Is there a way to ensure the wave cycle always starts positive while fixing the pitchshift issue?
Let the positive saw start at phase 0.5, and the pwm go up to 0.75. Let the negative (the subtracted) one go from phase 0.0 to -0.25. Should work I think.
infuzion wrote: See first post for file & reasoning. I'd also use similar logic in stating that SM should have FM, Ring... modules shiped with the install as example OSMs, if not part of the standard toolbox: I thought SM is to appeal to those with little synth experience? That's why the "Developer" switch, etc. I'm surprised (& grateful) something as advanced as the Multi Stage ENV made it into the toolbox. PW is much more simpler & expected then the MSE IMHO.
cheers
Oh, I too think that such oscillators would do good either as schematics or in the toolbox, I just don't see them fitting in inside the Multi Osc.
infuzion ·
stefan wrote:
infuzion wrote: Is there a way to ensure the wave cycle always starts positive while fixing the pitchshift issue?
Let the positive saw start at phase 0.5, and the pwm go up to 0.75. Let the negative (the subtracted) one go from phase 0.0 to -0.25. Should work I think.
I thought I replied to this already...
Thanks! That worked well, after chopping the PW input in half. Worked perfectly when connected to a LFO, but got off phase when connected to a static knob. Found a workaround for that also.
Let me know if you want my version for SM's Toolbox Stefan.
datsound ·
infuzion wrote: Yes, that's what I got:
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...
Why would a square need antialiasing, i reckoned it would still sound good with just -1 and 1 values in it, the frequency would be ok and it would sound good through a filter.
I just measured the built in square wave to be 20 percent more processor usage in my synth than the sine module. so if you use a sine and then put
streamin in;
streamout out;
out = -1.0 + (in > 0 & 2.0);
it is a square wave that uses 20 percent less than the built in one, and you can change the 0 value from -1 to 1 to vary PWM.
the triangle also uses alot more cpu than the sine and the sawtooth i would recommend making a new efficient triangle by putting 3 lines of code after a sawtooth to turn the ramp into a triangle.
trogluddite ·
Whether you need anti-aliasing is ultimately a matter for your ears to decide! For example, some people love old 8bit/12bit samplers running at 8kHz sample rates because the aliases make drums sound really crunchy and punchy.
However, a pure -1/+1 square has harmonics that stretch off to infinite frequencies - and all the frequencies beyond half the sample rate can't be reproduced and become nasty inharmonic aliases. If you're trying to make something that sounds 'analogue' or 'pure' then they have to be removed (or not generated in the first place). Some of them will be at very low frequencies, so just sticking a filter after the oscillator wont get rid of them all.
MichaelBenjamin ·
sticking a filter after the oscillator wont save anything, the aliases are already in the spectrum, and with a filter behind you only suppress a range of equally "pure" and aliased harmonics. to create pure spectrums with sm either use the wavetable oscillator (which seems to still? have some problems with its harmonics distributions at low base freqs, i dont know much about it, havent used it so much) or build additive with basic sine or triangles and for example cheby overtones or other shaping to directly control what frequencys at what pitch occur.
a third option would then indeed be using oversampling with crude aliased code and lowpassfiltering so that you record your plugin at 96khz with the 2x oversampling wrapper vst thing or even at 192 khz if your soundcard supports that to minimize aliasing to a somewhat inaudible level.
infuzion ·
datsound wrote: ..if you use a sine and then put
streamin in;
streamout out;
out = -1.0 + (in > 0 & 2.0);
it is a square wave that uses 20 percent less than the built in one, and you can change the 0 value from -1 to 1 to vary PWM.
This creates DC offset if you use PWM.
infuzion ·
SM's 2.03+ PWM module creates DC offset... even though it is freshly recoded for SM2.0+!
A waveform's values worth of a single complete cycle should sum to 0, just like all the other balanced waveforms do (Sine, Saw, Triangle). See Stefan's lessons above.
Still seems to work fine: [old link]
Wrote something here? To have a post removed or your name hidden, write to [email protected].