Help me name this oscillator shape...

Chords, scales, harmony, melody, etc.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hope this is the correct forum for such a question... if not, feel free to move. <3

So... this is about oscillator waveforms, and it seems I'm having a bit of a brain fart.

I know what a square/rectangular wave looks like. One half cycle it's +1 and one half cycle it's -1. Well, basically, mathematically, ignoring any filtering or other distractions. Box on the 0 line, box below the 0 line, box on the 0 line, box below the 0 line, etc. See attachment 1 (bottom image).

I thought I knew what a pulse wave was. To me, it always was a square/rectangular wave, just with the positive and negative flanks not lasting for the entire 1/2 cycle, just a fraction of it. Basically, a square/rectangular wave with narrower "boxes" and air in between them. So the +1 flank doesn't last 1/2 cycle, but (1/2 cycle * width). See attachment 2 (upper image).

Okay... so is that really a pulse wave? Or is it something else?

Because if that's a pulse wave, then what do you call a wave that's -1 consistently except for the beginning of the cycle? Its +1 flank lasts from the start of the cycle to (width < 0.5) * cycle, and then it drops to -1 and stays there until the next cycle starts again. I have no fancy screenshot for that, but maybe it makes sense like this:

I''I______I''I______ (name?) instead of +'''+---+_+---+'''+---+_+--- (pulse?) or I''''''''I___I'''''''I___ (square)

Anyone got a clue for me? :)
You do not have the required permissions to view the files attached to this post.
Confucamus.

Post

The second image is definitely a square wave with pulse width close to 50%.
The first image to my knowledge has no name. It might be constructed by adding two square waves with the second one having a phase offset of 90 degrees.
We are the KVR collective. Resistance is futile. You will be assimilated. Image
My MusicCalc is served over https!!

Post

BertKoor wrote:The second image is definitely a square wave with pulse width close to 50%.
The first image to my knowledge has no name. It might be constructed by adding two square waves with the second one having a phase offset of 90 degrees.
I know how those waves are created, they stem from my code. ;)

I thought the wave on the upper image was a pulse wave, because its width a.k.a. "duty cycle" can be changed. But it seems like it's just a square wave after all, just not lasting 100% of the time. A real pulse wave seems to be unipolar, not bipolar as my supposed pulse wave.

Just about all the illustrations I find for pulse waves show the amplitude jumping from 0 to a positive value and back to 0, there's no negative state involved anywhere. This Wikipedia article first shows a waveform oscillating between 0 and 1, then further down it shows something that is also labelled as a pulse wave, but it oscillates evenly between positive and negative values.

Someone told me that a "real" pulse wave cycle starts with a jump from -1 to +1, stays at +1 for its duty cycle length (percentage of 2*pi), and then it drops down to -1 again and stays there without alternating back until 2*Pi is fully reached = the cycle is completed. So it's really just 1 short pulse, not 2 like in my wave.

And then I find this picture.

So now I'm outright confused, and I guess I'm just trying to figure out if that very narrow square-ish wave (upper image) that I generated is really a "pulse wave" or just a square with a shorter duty cycle. If it's NOT a pulse wave, then what else is it called instead of pulse wave? And how should a (then) "real" pulse wave oscillate, between [0,1] or between [-1,+1]...? :help:
Confucamus.

Post

An alternating, [shifted] pulse wave?

EDIT: [] Offset pulse wave?

Post

One thing to consider is that as you modulate the duty cycle of this three-value waveform, you will still be getting only odd harmonics, as in a square wave, whereas with a standard two-value ([-1,+1], [0,1] or any two values, really) pulse, modulating the duty cycle adds even harmonics as well.

So in terms of harmonic content, this wave is much closer to a square. Maybe think of it as a "skinny square," if that makes sense?

Post

I like "skinny square".

Or. Looks a bit like teeth. How about square tooth?

Rockatansky wrote:And how should a (then) "real" pulse wave oscillate, between [0,1] or between [-1,+1]...? :help:
I always thought a pulse wave should be a short burst between -1 and +1 followed by silence for the rest of the cycle.

Post

Unaspected wrote:I always thought a pulse wave should be a short burst between -1 and +1 followed by silence for the rest of the cycle.
That's exactly the tricky part. "Silence" as in revert back to -1 and stay there? Or as in return to 0 and stay there?

If you mean return from 1 to 0 and stay there, then what happens when the new cycle starts? Does it reset to -1, burst up to +1 and then fall back to 0? ... That would be weird.
cthonophonic wrote:So in terms of harmonic content, this wave is much closer to a square. Maybe think of it as a "skinny square," if that makes sense?
Unaspected wrote:I like "skinny square".
Or. Looks a bit like teeth. How about square tooth?
According to Keith McMillen, it's a pulse wave...
Keith McMillen blog wrote:One way is called pulse width modulation, also known as “PWM”. While a square wave has equal time between maximum voltage and minimum voltage, a pulse wave is essentially a square wave with an adjustable amount of time in between each cycle before the the voltage drops from maximum to minimum. The percentage of time that the signal is high is known as a duty cycle.
edit: Or... wait... I think I misunderstood that blog entry. If the wave shortly jumps from -1 to +1, then drops back to -1 and stays there until the cycle is over, THAT is a pulse wave. The "duty cycle", according to that KMM blog is the amount of time the +1 flank is up. When the duty cycle is 50%, so the positive and negative flank are equally long, THAT is a square wave.

Leaves the question... what is "my" wave? Just an ordinary variable-width square? :shrug:
Confucamus.

Post

Rockatansky wrote:
Unaspected wrote:I always thought a pulse wave should be a short burst between -1 and +1 followed by silence for the rest of the cycle.
That's exactly the tricky part. "Silence" as in revert back to -1 and stay there? Or as in return to 0 and stay there?

If you mean return from 1 to 0 and stay there, then what happens when the new cycle starts? Does it reset to -1, burst up to +1 and then fall back to 0? ... That would be weird.
-1,1,0

Doesn't seem weird to me. I also thought you could turn any waveform into a pulse: Amplify your clock oscillator but clip and have the logic test force anything over 1 to be replaced with 0.

Rockatansky wrote:
cthonophonic wrote:So in terms of harmonic content, this wave is much closer to a square. Maybe think of it as a "skinny square," if that makes sense?
Unaspected wrote:I like "skinny square".
Or. Looks a bit like teeth. How about square tooth?
According to Keith McMillen, it's a pulse wave...
Keith McMillen blog wrote:One way is called pulse width modulation, also known as “PWM”. While a square wave has equal time between maximum voltage and minimum voltage, a pulse wave is essentially a square wave with an adjustable amount of time in between each cycle before the the voltage drops from maximum to minimum. The percentage of time that the signal is high is known as a duty cycle.
edit: Or... wait... I think I misunderstood that blog entry. If the wave shortly jumps from -1 to +1, then drops back to -1 and stays there until the cycle is over, THAT is a pulse wave. The "duty cycle", according to that KMM blog is the amount of time the +1 flank is up. When the duty cycle is 50%, so the positive and negative flank are equally long, THAT is a square wave.

Leaves the question... what is "my" wave? Just an ordinary variable-width square? :shrug:
I didn't think a pulse should have a DC offset. Though McMillen's definition suggests a pulse is a square with a state defined by PWM. And, indeed, when you employ PWM on a waveform, 50% would be the original wave without any transformation.

I don't know if this might help in some way: https://unaspectedstudios.wordpress.com ... -waveform/

Initially, I wasn't sure if you wanted to be creative or technically accurate. Personally, I would just choose an interesting name and know how you generated it.

Post

Unaspected wrote:-1,1,0
Doesn't seem weird to me.
Seems pretty weird to me. Thinking in "phase" as in fraction of 2*Pi, how long would the transition from state 0 (end of cycle) to state -1 (super beginning) take, and how long would the transition from state -1 to state +1 (actual positive signal) take? Unless you're after a weird click effect and you enforce at least one sample of -1 at the beginning of each cycle, the jump from 0 to +1 would be immediate.

In theory, looking at an oscilloscope, the vertical line connecting the flat top and bottom parts of the wave isn't there. There is, in theory, no transition phase. It's either +1 or -1, there's no amount of time where a square or pulse wave would be at anything in between. The fact that some (well, most) synthesizers may have transitional times is based on inaccuracies, either the time it takes to discharge analog components, or maybe from bandlimiting or filtering digital oscillators. But a 100% pure square/pulse wave will never have a transitional 0 state, it will -again, theoretically- always only ever be +1 or -1.
Unaspected wrote:I didn't think a pulse should have a DC offset. Though McMillen's definition suggests a pulse is a square with a state defined by PWM. And, indeed, when you employ PWM on a waveform, 50% would be the original wave without any transformation.
So based on a pulse jumping from -1 to +1 once and returning to -1 for the rest of the cycle, that would make "my wave" not a pulse. Since "my wave" has its silence position at 0, not offset to -1. That would then make it a square wave, just with a pulse-ish duty cycle per 1/2 cycle... :scared: :ud:
Unaspected wrote:I don't know if this might help in some way: https://unaspectedstudios.wordpress.com ... -waveform/
Thank you for the link, bookmarked. So much to read, I'll have to check it out later, I should now probably try to get an hour or two of sleep before work. ;)
Unaspected wrote:Initially, I wasn't sure if you wanted to be creative or technically accurate.
I just coded what I thought was a pulse wave. Then someone told me it isn't. Then I started reading and trying to figure it out... that's all there's to it. That, and losing track of what's a pulse wave and what's not. :)
Unaspected wrote:Personally, I would just choose an interesting name and know how you generated it.
Let me see if I can make this work... this is not the actual code I'm using, it's "dumbed down" and un-optimized for better readability, but I hope it's good enough to explain the concept. Which is pretty trivial, actually. Just keep track of the phase position, handle width as a fraction of the phase, then decide if the sample should be +/- 1 or 0-silence depending on the relation of phase position to width.

Code: Select all

// p = phase (keep track outside getNextSample)
// f = tone freq / sample rate
// w = parameter in range [0.0,1.0] but * 0.5
// a = amplitude

float getNextSample ()
{
    // update phase cycle
    p += f;

    // constrain phase to 0-1
    if (p >= 1.f) { p -= 1.f; }
    else if (p < 0.f) { p += 1.f; }
    
    // check if phase relation to width wants +/- 1 value
    if (p < w) { return a; }
    else if (p >= 0.5f && p < 0.5f + w) { return -a; }
    
    // if none of the above, default
    return 0.f;
}
Confucamus.

Post Reply

Return to “Music Theory”