SynthMaker

Pulse Width applied to waveforms other than Square?

Archive · 2007 23 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

PaulRiedel ·

Hi!

Does Pulse Width (modulation) make sense when applying it to any waveform other than Square? As far as I can think right now wouldn't this just modify the frequency?

Please enlighten me or join the ?-Train 😀

Thanks!!

- Paul

5010 ·

Only for square waves.

Check this out: http://en.wikipedia.org/wiki/Pulse-width_modulation

With synths, you typically modulate the pulse width via LFO, but assigning a mod wheel or auxilliary adsr to pulse width can be interesting too. Users expect a pulse width knob or assignment to do nothing when the VCO's oscillator is set to something else such as sine or saw.

infuzion ·

My understanding of how waves work is that wave width = how fast osculations = pitch? For squares, yes you are changing the "width" of the hump, but the start/stop point for the entire cycle only changes w/pitch.

5010 ·

infuzion wrote: My understanding of how waves work is that wave width = how fast osculations = pitch? For squares, yes you are changing the "width" of the hump, but the start/stop point for the entire cycle only changes w/pitch.

Yes, and you would want the width of the hump to be a percentage of the period of the cycle. So raising the pitch would change the 'width' of the hump proportionately to the 'width' of the whole wave.

unkargherth ·

Well. from last two post, i assume that PUlse with modulation si some kind of de-centering the middle zero cross to the left or to the right, true....?

Then... It's imposible to do it with for example, a sine wave ?, or... in general for any kind of simetric wave ? Nobody tried it?

i mean, if for the first 25% of cycle we usea double frequency wave and for the resting 75% we use freq/3 wave of same type ... dont' we are in fact pulse modulating that wave? ( with some alliasing, of course)

Can this could be done efficeintly enough for aplying it in a generic way for all standard waves?

Dave B ·

How would you pulse width modulate a waveform that is not a pulse waveform?

Dave B ·

unkargherth wrote: i mean, if for the first 25% of cycle we usea double frequency wave and for the resting 75% we use freq/3 wave of same type ... dont' we are in fact pulse modulating that wave? ( with some alliasing, of course)

Can this could be done efficeintly enough for aplying it in a generic way for all standard waves?

Interesting thought. I suppose if you computing a sine and changed the rate of the phase angle at the zero crossing you might be able to do this. Seems you would have to be significantly over sampling for this to work, or at least at frequencies well under the Nyquist rate.

angstrom ·

I know that in some synths triangle or saw can be 'pulse width-ed'. The technique being that, in the case of a saw, the downward slope angle is steeper it hits 0 and stays there for the remainder of the duty cycle.

so instead of the signal descending from 1 straight through 0 to -1, it sits waiting patiently at 0 for a time.

I searched for an image on google but cant find one. damn. Hope you understood that.

stefan ·

Pulse width = pulse wave duty cycle Duty cycle = applicable on all waveforms. Google for that instead 🙂

angstrom ·

I actually searched for 'waveform' and manually trawled the results for the appropriate image.

5010 ·

The saw width modulation you speak of could be a phase distortion oscillator.

It is possible to code an oscillator that breaks a triangle down into interpolated segments. You can then modulate the end points to warp it between saw and triangle. I've been experimenting with such a beast. Warping between saw and triangle produces a harmonic sweeping effect similar to modulating a pulse width. It is possible to apply a sine function to the interpolation, allowing for warped sine waves. I plan to experiment with that as well but haven't yet coded it.

stefan ·

Like this? 🙂 [old link]

5010 ·

Oooh thanks! It's good to see that solution also includes the dreaded divide operation. 😮

I can relax now...

unkargherth ·

Interesting example stefan.... very interesting

Any way.... could this be applied GENERICALLY to any kind of osc ? ( i'm thinking specifically in sine osc, but a generic way to do it on any symetric waveform would be perfect)

Also, as it is coded, and based on my one-minute test, it seems to be aliased like helll on higher frequencies...

My own approximation is far from beign finishedbut.. what you people think about the following:

Take a ramp an use ouput as the phase input for a sine osc. Then between ramp and osc insert some kind of math function that converts the linear ramp into something more "curvish" ( the pair log/exp could be a nice start) then crossmix the linear ramp and the output of function to use it as "with modulation"

As far as the function out range goes in 0.1 range, we are manipulating "how fast" the phase is moving, thus geenerating the "variable width"

I supose that aliasing problems appear at some point, and that CPU compsumption will be a bit heavier, but this is only a design exercise, not proven to be a viable project

Sorry for not providing an example.. by now it's only a thought.

Opinions ?

stefan ·

Well... If you change the code in the above example like this you get proper sine duty cycle behaviour:

streamin freq; streamin dutyCycle; streamout out; float phase;

phase = phase + freq; phase = phase - (phase >= 1 & 1); out = ((phase <= dutyCycle) & (phase / dutyCycle) + (phase > dutyCycle) & (1 - (phase - dutyCycle) / (1 - dutyCycle))); out = sin1(0.25 + out * 0.5);

You could alter the code to give a proper phase output which you then could use to feed any oscillator too:

streamin freq; streamin dutyCycle; streamout out; float phase;

phase = phase + freq; phase = phase - (phase >= 1 & 1); out = ((phase <= dutyCycle) & (phase * 0.5 / dutyCycle) + (phase > dutyCycle) & (0.5 + (phase - dutyCycle) * 0.5 / (1 - dutyCycle)));

BUT! If you want this to work properly for for instance a sine, you have to add 0.25 to the sines input, to properly set around which point the duty cycle changes. You can try using different points. 0.25 gives interesting results on a sawtooth 🙂

Cheers!

edit: And yes, this aliases "like hell". So will altering the phase input for a sine 🙂

5010 ·

Unkargherth that sounds interesting, and I wonder if aliasing could be helped by crossfading between the function(ramp) and raw ramp based on pitch. Therefore as pitch increases the phase sweep flattens to drive a progressively purer sine.

5010 ·

Giving it more thought, it might be a good idea to explore oversampling with jitter. In other words, audio version of visual dithering:

Given a random jitter between 0 and 1, phase2 = phase + (freq*jitter); Calculate out and out2 like stefan's code above using phase and phase2, then average out = (out + out2) * 0.5;

Unfortunately that's double cpu + jitter cpu over the simpler code. Maybe selector only chooses this version at higher frequencies? I'm going to experiment with it.

stefan ·

If it's for the variable triangle/sawtooth only you could reduce aliasing by integrating the waveform from last phase to current phase and divide by the 'length' (current phase - last phase) to get the average output of the waveform for that period of time. That will give you a -6dB/oct aliasing noise reduction. It will however include another divide...

If you don't have to be able to modulate the duty cycle you could use a wave table instead that you recalculate when the duty cycle changes. Like I do in Anna.

unkargherth ·

5010 wrote: Unkargherth that sounds interesting, and I wonder if aliasing could be helped by crossfading between the function(ramp) and raw ramp based on pitch. Therefore as pitch increases the phase sweep flattens to drive a progressively purer sine.

Well crosfading that way is what to allow me to generate de the width modulation

I try to explain better:

freq--------->ramp---------------------------------------->crosfade----------->sine---->out | ^ ^ ------------------->curvefun----------------- | | ^ | PWM -----------------------------------+----------------------------

So what we have here is a curvefunc that converts linear ramp into a curved one so accelerating or brealing how fast the increment of phase occur. BUT, the real Width modulation ocuurs when you crossfade this with the original ramp ( linear phase)

In fact i agree with stefan that this SHOULD alias, basically becuse we ae aplying a non liner modification of ramp , ie non-linear phase

NOTE: the above schema assumes that nothing is connected to the fre sine input

In fcat this could ve seen as some kind of highrate Phase distortion, alla Casio CZ Family

asemcken ·

This was included in at least three synths that I know of...

Roland D550 Rhodes Chroma Polaris Marion MSR2

I've still got two of those (Polaris was a goner years ago...).

RWM on the Marion works digitally, as does the 550. Polaris was decidedly analog (CEM VCO). The sound is really quite nice on the two I still own.

I'm going to look at the schematics for the Polaris VCO to figure out how they did it. Marion actually changes the slopes of the positive- and negative-going portions of the waveform. It actually adjusts from Saw to Triangle, with amplitude symmetry (might even go from Saw through Tri to Ramp, will have to check when I fire it up).

It's one of the 'to do' items on the Osc core I'm messing with. As both the Roland and Marion limit RWM to LFO/transient mod sources, I'm curious to see what audio-rate modulation does to the waveform...

angstrom ·

ker-bump : an OSM example

here's something I've been meaning to try for a while, this is what I think of when I imagine a triangle that is 'pulse-width-able' (!)

that's a 'pulse-width-able' triangle from the OSM . The wave shown above is at about 90% pulse-width. In this example 0% is just a normal triangle.

This osm takes the standard wavetable input from the triangle waveform, it turns it up very loud then uses min and max to only make use of the top and bottom sections of that wave (if that makes sense). This is done as my feeble attempt at avoiding aliasing which arises through the usual code-only methods.

this is my usual hacky style. Pulse width runs 0-1 rather than -1 to 1. Any improvements?

Acrobat ·

angstrom wrote: ker-bump : an OSM example

here's something I've been meaning to try for a while, this is what I think of when I imagine a triangle that is 'pulse-width-able' (!)

that's a 'pulse-width-able' triangle from the OSM . The wave shown above is at about 90% pulse-width. In this example 0% is just a normal triangle.

This osm takes the standard wavetable input from the triangle waveform, it turns it up very loud then uses min and max to only make use of the top and bottom sections of that wave (if that makes sense). This is done as my feeble attempt at avoiding aliasing which arises through the usual code-only methods.

this is my usual hacky style. Pulse width runs 0-1 rather than -1 to 1. Any improvements?

I'll check how it sounds, from the picture I guess it sounds... mmh... guess between a wild sine and a distorted saw, am I correct?

angstrom ·

well it sounds as you should expect, in the first case it sounds just like a triangle wave - because it is. Then if you narrow the width it has the same tonal change as when you narrow a square pulse, the high frequencies are emphasised and the wave sounds more 'thin'

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.