Square wave osc and pulse width duty cycle

Hi all,

I was wondering, when looking at the square wave when using the osc, i was wondering if there was a way to set the width of the square wave. Example i’m at frequency X but would like the pulse to only be X% wide at that frequency.

Thanks for any thoughts you have on this.

Brett

you can easily write your own square oscillator.

an oscillator cycle is
(1.0 / frequency)
seconds long, and therefore lasts
n = sampleRate / frequency
blocks in the output buffer.

of those n blocks you set you desired percentage to 1.0 and the rest to -1.0.

1 Like

Another way to create a PW-variable rectangle wave: subtract two phase-shifted sawtooth waveforms.

1 Like

@Firesledge, @xavierxeon,

Thank you for the info, this is super helpful.

Brett