• ### why saw and square 'sound' louder?

Hi good people
I'm building a semi-modular synth in PD, with no prior experience, and step 1 is choosing wave shapes (sine, triangle, saw and pulse/rect). I've seen examples where they've used a lookup wavetable for oscillator waveforms, but I'm just using a single [phasor~] and then some simple maths operations to change its shape. I'm not imagining it, but the saw and square sound way louder and harsher than the other two. Is it common practice to reduce their amplitude and/or apply a low pass filter? Or should I be using a wavetable?

Many thanks for any help
Brendan

• Posts 14 | Views 1538
• @brendanmac If I remember correctly from school the power of a signal is the area under the curve.... which is why a compressed signal (then normalized) sounds louder and compression is often used when mastering a recording.
A square wave has a large area under the curve..... it is always at +- 1 ....... and will be 6db louder than a sine wave for the same peak values.
A saw contains all the higher harmonics (like the square wave) but the perceived loudness has more to do with the richness of the timbre than the actual power I think. The square wave of course also has that perceived increase in power from the harmonics.
A saw wave actually has less power than a sine wave, so the effect is purely psychoacoustic.

The harshness comes from the higher harmonics (especially the highest), so you cannot change that. A low pass filter will progressively return the waveform to a sine as the cut off frequency is reduced, because the higher harmonics are being reduced...... and it will introduce a phase shift (a slight lag in the waveform).
A wavetable will produce the same effects as your maths...... it is in the nature of the waveform and there is nothing wrong with your method.
You can use a [lop~] to reduce the effect though if you actually want a less harsh sound.
David.

• saw and square sound louder because they have the most overtones.

square has also actually the most energy.

i would not use different amplitude factors, that is the job of the patch designer.

• Love this detailed and clear answer, and I suspected it was as you describe: If the waveform spends more time per period < or > 0 it is perceptually 'louder', + overtones. Just checking that I'm not mistaken. I'll filter to taste.
Brendan

• @brendanmac it's not really common practice afaik (usually just range -1 to 1), but it could make your product more usable/accessible.
If you want to do that I would at least use RMS, but perceptual loudness can get way more complex

• @brendanmac lets look at it.

from an electronics perspective it looks like a square wave represents a steady DC signal the closest (meaning if you were to flip the 0 to -1 part it would be a straight line) besides at the crossings and the others look filtered.

Its interesting how there's a subtle difference at the peak of a sine vs a triangle, the sine hits red a little. In vintage analog synths a "dirty" triangle wave could be mislabeled on the synth as tho it is a sine but it looks like it has the least energy. Also from vintage synths if you look at the waves in a scope they look different than you would think, especially something like a 303 (filtering out the DC maybe?). A function generator (which this basically is) is more like what you think of these basic waveforms in your head.

the live electronics tutorial included in [else] is top notch btw (as is the audio section in the help browser, thats supplemented with a free online book on miller's website). a saw has all the harmonics, a square odd, triangle even, and they can be separated or combined. a (co)sine wave is the only signal that can travel through electronics without change phase (which can mess up what you are seeing) one reason why its used to probe inside audio electronics

also to note, the oscope~ on the top was just to show that the [phasor~] normally comes out at 0-1 (normalized float which is easy to use as a looping function) so it has to be stretched out to be used like a sawtooth
testWaves.pd

• Thank you @fishcrystals, I must check out that library.

Brendan

• Hallo
sorry to bang on about this - I have done further reading and cannot find a simple solution to antialiasing a square wave oscillator. There is of course the [square~] object in Purr Data - should I just use that?

Many thanks
Brendan

• I went with this - it is subjectively okay

• @brendanmac The Pd help examples contain two ways to address aliasing. J07.oversampling.pd shows how to use oversampling to create a better alias filter--just replace the phasor with your preferred method of generating square waves. J09.bandlimited.pd replaces the jump with a specific kind of squiggle, but for a sawtooth. If you want to do the same for a square wave, I think all you have to do is replace the phasor~ with the equivalent triangle wave. It's called "transition splicing" in Miller Puckette's book https://msp.ucsd.edu/techniques/latest/book-html/node196.html

• @brendanmac there's some vanilla abstractions (meaning they should work in purr data, plug data as well as PD vanilla, theyre just made out of the most basic pure data vanilla objects), copy these to the same folder you are working in and type os.square~ into an object box aka [os.square~] , then right click the help (or just open the help file) os.square~-help.pd os.square~.pd
these and other goodies are in mkmr to get you going quick in most of the flavors of pd because theyre vanilla https://github.com/MikeMorenoDSP/pd-mkmr
some other good links at https://github.com/MikeMorenoDSP/awesome-puredata

• Thank you so much for these, will get stuck in later today.

xx
Brendan

• from Miller's book " In case you were hoping, subtractive filtering can't remove foldover once it is present in an audio signal."

The learning continues. . .

• there is no need to measure the RMS of a known waveform, since you can calculate it offline much more precise. the energy of a wave/halfwave/periodic vibration is the size of the geometric surface: 1 for square, 0.5 for tri and saw, 0.707 for sinus...

Posts 14 | Views 1538
Internal error.

Oops! Looks like something went wrong!