I'm trying to implement what the topic's title says, but don't seem to nail it yet.
I've done this for now
but I get a pitch change as I change the duty cycle. Any suggestions? I've attached the patch so you can play with it (it uses the [bl_squarewave] abstraction that I just posted in the abstract~ group of this forum)
Duty cycle on a band limited square wave
I think you forgot to share your abstraction [bl_squarewave], or did I understand anything wrongly?
I've posted it in the abstract~ section of the forum...
Sorry Alexandros, I've missed the phrase you mentioned it before.
About your patch, I think there is a problem with your algorithm. I believe you will need to do some kind of normalization after altering the duty cycle. Look:
Let's say the regular output of [phasor~] goes from 0. to 1. in a time t (and thus each half, 0. until 0.5 and 0.5 until 1., will each take t/2). Then it follows that, after your manipulations, the signal that will be output by [phasor~] must still go from 0. until 1. in the same time t or else the frequency will have changed.
Now let's take the example of duty cycle = 2.0. In that case, you are multiplying the frequency of the first half of [phasor~] by 2. and the second half by 0.5. This means that their period will be multiplied by the inverse of those values. Thus, the first half will now take t/4 while the second half will take t, and the total period will now be 5t/4, which will have changed the frequency.
So it means that now those two frequencies are in the correct relationship to each other, but both have to be multiplied by some value in order to normalize the output. Does this make sense to you?
I gave a try to your patch, Alexandros. Very interesting.
I noticed that there are lots of sidebands, both for 0.5 and 2. And, if you use values >0.5 or >2, then the sidebands become pseudo white noise.
Also swapping [>~ 0.5] and [==~ 0] creates the possibility of using the duty cycle as a pitch control. Not really useful, I know.
I cannot give you a suggestion according to that patch. However, I can suggest the following.
We know that a square wave has odd numbered partials. We also know that, when we alter the 50:50 ratio, we not only get odd numbered partials...we also get some even numbered partials. So doing pulse width modifications is like going from square to sawtooth, and viceversa, repeatedly. Unfortunately, this is an oversimplification...since the (dynamic) spectral envelope of pulse width modulated has a series of moving lobes.
I think that it might be possible to do what you want by combining a band limited square wave with a band limited sawtooth. By combining I mean adjusting relative levels. Then the moving spectral lobes can be easily achieved in various ways...with a comb filter, or similar effect.
If you don't need to go so far as (lfo) modulation, and you're happy enough with just altering the duty cycle, then you don't need the comb filter thing...you only need the square and the sawtooth.
The advantage of this could be both the band limited nature as well as some variety of wave flavours.
One more thing: I doubt the resulting waveforms will look like the ideal ones...the phases will be different, I guess. I also doubt that extreme pulse narrowing can be achieved.
This strategy is in my to-do list, since a few weeks ago, but I'll be very glad if you give it a try first!
I live and love in Argentina
"I also doubt that extreme pulse narrowing can be achieved".
I correct myself. If, instead of using a standard sawtooth, you use a pulse like sawtooth, you can achieve those narrrowing effects...somewhat like glottal pulses. You should be able to do that kind of wave (somewhat easily) with Pd's sinesum or cosinesum funtions.
I live and love in Argentina