It doesn’t matter for how it sounds, but it DOES matter if you put the signal into a distortion stage. It will distort completely differently, because the peak levels of the phase shifted wave are a LOT higher compared to regular square wave as mentioned near the end of the video. Adding an allpass filter for phase shift is a really good technique for getting some varied sounds out of distortion or saturation later in the chain, try it out!
@@Eugensson Definitely. You can create so many effects with only a couple of allpass filters. It's still one of the last things people learn how to use, when it actually should be one of the first.
Amazing, I’ve been an electrical engineer for years and it never had even occurred to me that phase changes in the harmonics wouldn’t be perceivable in our ears.
I was curious about this back in undergrad so I experimented with phase distortion with synthesizers and was shocked. I'm a little disappointed that he didn't explain why--the cochlea acts more in the frequency domain. I'm not 100% sure this is true, but based on my understanding: there are cells all along the cochlea and due to the structure of the cochlea (hint: it's a tapered resonant waveguide type thing), the location of the cell kinda determines which frequency it is sensitive at. The cells activate when it vibrates, which makes it insensitive to relative phase but sensitive to frequency/pitch.
I'm an EE too and had to take a class in college some years back involving audio processing (essentially turning a time-domain audio signal into a DFT, doing operations on it, and turning it back again). I can tell you that, while getting rid of phase info doesn't make a huge difference for relatively simple waveforms like square/triangle waves that are steady state for hundreds of milliseconds at a time, it absolutely matters once you get into things like a human voice. One easy "robot" voice effect is to just lose all the phase info from your DFT before converting it back to the time domain
@@karnage5888 no, electrical engineer. At the end of the day, audio is just an electrical signal anyways, though, so it still applies. I've done countless hours of work on different audio related projects over the years
@@donit. That's a useful technique in nowadays world of volume normalisation and the loudness penalty imposed by streaming services, however you can still achieve a massive, "full" sound that competes with other tracks nicely. If the waveform of your bass sound has lower amplitude peaks while still delivering a massive chonky fatness, you can make your track really stand out.
@@Savage-en1ms I dont really understand what the difference would be tbh. the bass will sound the same in both cases. maybe the resulting song will be a tiny bit louder , but as long as its over 14lufs that doesnt really matter I'd say. the only difference it could make is when you have something like compression or distortion somewhere in the chain, but in that case the non sideways triangle wave would get more distortion.
2:33 The reason that square waves are not "horizontal" in those videos is because of a DC offset filter. It's effectively just a capacitor and resistor in real life, but what it is doing in software is just removing DC offset. that's why different duty cycles of waveforms shift up and down, as well. DC offset can strain speakers and amplifiers that have no DC offset filters, as well as cause then inevitable popping you hear when you turn a system on/off. We try our best to remove DC offset, since it's really not a good thing, so we have them on basically every audio device nowadays.
@@ltva8781 yeah, exactly. Sometimes the cutoff frequency is even lower so low bass around 20Hz can pass through better, but generally it's between 1 and 10Hz.
@@crackwitz High pass filters don't phase shift the signals going past them when they're literally orders of magnitude higher than the cutoff frequency. Yes, it's 45 degrees at the high pass filter's cut-off frequency, but that is usually between 1 and 10Hz, where it doesn't matter anyways.
@@TeslabladePlaysMC So you can test this in LTSpice. I created a 100 Hz square wave swinging from -0.5V to +0.5V and ran it through a 10u series cap and 2.2k shunt resistor (corner frequency 7.23 Hz). The 100Hz fundamental is only attenuated by 0.022 dB so its amplitude should be 0.99x what it normally is, but there is a slope that drops 100mV on top of the filtered wave (going from above it to below, roughly equal area in the difference). The 3.960 degree phase shift at that fundamental freq is much more likely to explain that. When a square wave starts to be more affected by amplitude response, you see a curved drop on the top of the square wave, not a roughly linear one. The sawtooth-like slope is a result of a high pass that is phase shifting noticeably but not attenuating noticeably.
You realise that you are listening too much to chiptune music when you can tell the difference between the actual square and the sine way that sounds like the square
you do realise your comment is dumb right ? the harmonic content is the same, there's no way you or anyone or anything could differentiate the square square wave and the jumbled up square wave because there IS no difference.
there is something really creative you can do with this concept if you know sound design; while at normal pitch you cannot hear the difference between the waves, going down a lot of octaves *does* let you hear the phase rotation; ive been using this technique to create interesting growls and reeses (im a neuro/dubstep producer), because the usual clicky texture of the square/saw doesnt come through as much anymore
I think this happens when the frequency comes into the range of the temporal resolution your hearing, so that you don't hear an "average" spectrum of a periodic signal anymore, but instead the spectrum variing over time?
@@VintageTechFan yeah, and when you have a normal saw/square, the only thing you would hear would be clicks, since all of the frequencies overlap to make a click; rotating the phase just displaces that and lets out different waveshapes (and the deeper you go the more movement that waveshape has before it repeats) :3
@@Zadamanim well, you can use something like an allpass filter to rotate them, tho you dont get very much control (serum has an allpass, theres also disperser from kilohearts) what i personally do is i use a wavetable synth and go inside of it and rotate the phases manually, it lets you do it custom for each harmonic
This reminds me of doing a square wave in FM. My mind bugged out when I looked at a "square wave" oscilloscope that had a sine wave cut by a bunch of loud spikes.
@@christiantaylor1495 it's a sine wave and another sine wave with the double of the frequency and some saw-like harmonics. I'm not fully sure which one modulates which but you can replicate this on an OPL/AdLib by choosing Alg1, turning up feedback and setting the op1 multiplier to 2 and the op2 multiplier to 1.
How remarkable! Based on my understanding of how audio perception works, it makes perfect sense for phase to not matter, but I never really thought about it.
You can hear a difference. But only for simple cases like 2 squares with different phases for the sub waves. the problem is that it is very insignificant and if you listen to more than just a side by side comparison you don't have a chance to distinguish it.
If you'll lower the frequency of the ''randomized-phase square' to the "bass range" it actually starts to sound different (still "squarish" but more dirty). Another interesting expirience is to shift phases of only certain harmonics (for instance take a sawwave and shift only its evens by 90°). While the thing is barely noticeable at higher freqs, it's a whole new world of subtle (or not so subtle) variations for bass sounds. (Ah, I see a few people already mentioned this in comments above. Anyway.. :))
@@BellXllebMusic It depends on what tools you're more familiar with. Many "additive" (and derivative) VST synths allow one to set an arbitrary phase for each harmonic. Though for more technically accustomed person I guess it's much easier to use some math tool to generate a waveform of interest (for example I do this via Octave script) and then put it to whatever synthesizer for playback.
The harmonic content of the wave is identical. But the transient behavior is slightly different because of the phase warping. Both waves are activating the exact same parts of the cochlea(harmonic content) But the kinetic interplay with the eardrum is different... just because of the phase-warp. So the square wave has just a slighty punchier/pluckier transient. But it would basically be totally unoticable unless you were playing low bass/sub register. But honestly it might be too fast for the brain to even understand lmao
I just did some very rough testing, and determined I could hear a significant difference up until around 750hz. Anything nearing 1k and above sounded very similar to me. The lower I go the easier it is to recognize the various overtones that have been unmasked by the smearing of the phases, which break the transient behavior of the square.
@@jshstuff from my limited reading on the general scientific research, human hearing is far from understood. The mechanical aspect of the ear drum, bones, cochlea can be described but the neurological processing is incredibly complex and difficult to interpret. I've read a few papers on humans who suffered brain injury and animal testing where specific brain regions were impaired. With that you can see how parts of audio processing no longer exist while others remain fully intact. It gets even more complicated where the processing isn't isolated, two (or more) regions feed information between each other before giving an output response. Phase is used to locate where the sound is coming from as the left/right ear receive them at a slightly different time. It becomes more complicated when a sound is say directly overhead and therefore both ears hear the same phase. But sound doesn't reach us just through the ears, our skull transmits sound at a different velocity such that we can differentiate the vertical position. Most animals do not have the cognitive processing to achieve this and will tilt their head such that both ears receive a different phase. Bones act as a low pass filter so high frequency sounds reaching each ear are more difficult to positionally locate. Additionally our brains have a limit on frequency processing. Very high (audible) frequencies are impossible for us to process and interpret phase differences between ears. This is why there has been a push for emergency vehicles to switch from the traditional high frequency sirens to lower frequency white noise-esque sounds. You might have noticed it with large vehicle reversing, instead of shrill beeps you'll here "shshshshshshshsh", "shshshshshshs". Our brains can quickly and accurately use the phase difference to locate the vehicles position. About 15-20 years ago I worked on audio and video encoding. It was absolutely fascinated for how much it revealed about our brains. Lossy audio codecs remove huge amounts of information simply because our brains can't tell the difference. That is done before compression as there is no point encoding signals we are incapable of differentiating. Back in the 2000s there was a company who embedded a user id into the audio that was unnoticeable to humans and more importantly would be left intact after re-encoding such that someone sharing an mp3 (or otherwise) accessed through subscription or purchase could be identified.
interesting funfact about this: A normal square is basically perfect distortion, you cant really distort it more, at least not through Clipping, BUT if you mess up the phases first, you can distort a squarewave further.
as a synth player and computer engineer this was one of the coolest things i've ever seen. The slanted square wave is super noticeable on the minilogue oscilloscope
Wow! I've never thought about rotating all the frequency components by a fixed amount to minimize the crest factor of a signal. I've never seen that in any signals and linear systems textbook.
2 other cases where a difference is meaningful -if it’s at a low enough frequency -if there’s nonlinearities in the system after the square wave (imagine hard clipping the normal square vs. the phase randomized square)
Maybe people can't hear phase when it comes to square waves (or probably any strongly periodic signal), but phase is certainly important for other sounds. I've computed short time fourier transforms for voice clips, and if I keep only the magnitude and discard the phase, then reconstruct the sound with Griffin-Lim, the resulting voice sounds really muffled.
square waves in music are fairly long in duration, so shifting the phase around in a 16th note doesn't affect our perception of it. but for speech the fricatives and plosives as very short duration, and distributing their energy across an entire word is definitely going to muffle it.
In some ways this was an eye opener. For example I'm so used to just taking a triangle wave for granted that it never occurred to me that it could be compressed losslessly like that.
This is a really cool video! Although I mostly know about how sine waves can be stacked to approximate a square wave, I've never though at all about how they could have different phases, and the bit about optimising the triangle was also totally a surprise! I suppose that's why triangle waves sound so quiet then, relative to its gain level...
If not mistaken, square waves are actually every 2nd harmonic from the fundamental of the sinewave. And the craziest thing I've learned is that every sound is actually stacked sinewaves with different phase rotation angles and stacks, so it's madness to think that you can make any sound from sinewaves if you stack the right harmonics with phase rotations and amplitudes 😳🤯
@@kaitlyn__L I do believe it's there where I became extremely convinced about that lol. I mean when designing sounds we don't think about it, but that helped me understand a lot more too lol
@@morpheon_xyz But it's important to not think about it much. And it's actually wrong, because when you use frequency shifting for sound design, you stop the harmonics from being multiples of the fundamental, and get harmonics that can't be drawn in additively.😊
I hear an distinctive difference between those two. They sound almost the same listening on my smartphone speakers, but quite different listening with my headphones
I liked the inclusion of the PCjr SN76489 version of Space Quest. I remember taking my Sega Master System emulator's SN76489 emulator out, and adding it to a DOS emulator, then making a few I/O reads respond differently for Tandy 1000/PCjr, and Space Quest started drawing a linear frame buffer instead of the EGA planer buffer, and it talked to the SN76489 instead of the internal speaker timer chip. Good memories. 😁
Oh shoot, I’ve contemplated the use of the DPCM channel as a fourth waveform in a variety of ways, but never though a square wave would be possible. Now this is something I really want to try out!
Apparently 7 bit PCM is real expensive on the processor though. I didn’t even know it was a possibility until very recently because it seems games hardly used it.
Heh, "meander", nice...... For those interested: the name for square wave (exactly square wave, ie. impulse signal with 50% duty cycle) in some technical groups (including the entirety of Russian/Post-Soviet science) is often substituted with "meander", after a Greek pattern, not a river curve...
The interesting thing is that this isn't just shifting the phase of the individual harmonics by an equal amount, as that wouldn't change the shape of the wave, it would just change the starting phase. To get the shape change one needs to construct the math behind the diagram on the left (two separate Fourier series, one for x(t) and one for y(t), one with cos terms only and one with sin terms only), rotate that (using a matrix), and then rearrange the result back into a new Fourier series (using angle sum and difference identities I suspect?)... My capacity to do the algebra in my head has been exceeded... Tempted to start getting pencil and paper out...
Yup, it’s shifting the phase of each harmonic by a different amount. The math is much easier if you use complex exponentials, since the harmonic-specific phase shifts can be trivially encoded in the complex Fourier coefficients.
@@Polychromophilia The fucking what? Man I need to dig into this kind of maths, never learned fourier transforms and now I feel like I won't be able to produce music to the level I want to produce it at if I don't wrap my head around it
@@TheMrVogue You don't need to know any of that to make music, all you really need to know is that any sound is mathematically equivalent to a bunch of sine waves of different frequencies added together, which you should already intuitively understand if you've ever used an eq. If you want to know more you can read up on things like Fourier transforms, the harmonic series, and Nyquist theorem but they aren't at all necessary to know
@@tristanwh9466 I appreciate the encouragement... I've been making music for a while, but this kind of low level knowledge I think is what separates a master from a novice... At least knowing what you're doing to the mix by using certain waveforms, etc... Maybe you're going for a particular sound, but you're really particular, I think this kind of stuff is what lets you add in that extra sauce to polish things to a mirrored finish.
Thank you for answering a question I didn't even know I had, or at least couldn't figure out how to search. This is very informative, concise, and well-presented!
It's kind of amazing how they sound indistinguishable despite how different they look, but it's important to remember that what we hear are not the waveforms themselves, but the frequencies. When those overlayed frequencies (that normally combine to comprise a square wave) are unchanged, it makes sense that we hear the same thing. It's also yet another testament to how ubiquitous sine waves are to the literal fabric of reality.
And if you think of WHY we hear the timbre of sound but no the phase, it's because phase doesn't carry much useful information. It tends to be jumbled up in the world due to reflections etc. It's like why we don't see the polarization of light, even though it is another dimension that each photon falls somewhere on (ignoring circular polarization).
@@gblargg You can actually see the polarization of light, it's most obvious on a white LCD if tilt your head side to side, you should be able to see a blue-yellow cross shape which rotates along with you
A true mathematically perfect square wave (or sawtooth) would rip a hole in space time, due to the infinte energy needed for the instant discontinuity. Luckily, humans can only hear up to between 15 and 22k (depending on age and other factors), so we don't need to blow up the universe to make chiptunes : )
Man, audio synthesis is just full of mindblowing tidbits that aren't obvious, but are easy enough to digest once it's explained. It weirdly feels impenetrably difficult and stupid-easy at the same time.
Great video! I read a note recently in a small-signal audio design book that made this claim (that phase shift between harmonics in a signal is imperceptible to humans), so it's cool to see that demonstrated.
What's really interesting is that the lower the pitch, the more perceptible the phase shift becomes. And imagine using one of these faux square waves at LFO speeds for modulation!
One quality that’s easy to see in all of these … alternative square waves … is “half-wave symmetry”: If you think of these waves as mathematical functions, the value of that function at any point is _exactly the _*_negative_*_ of its value _*_half a wavelength_*_ away_ . If you look at waveforms from the lower register of a clarinet or bass clarinet, they also have this property (up to a point)! So, its value at zero degrees is exactly the negative of its value at 180 degrees. Its value at 10 degrees is the negative of that at 190 degrees, and so forth. That’s because they’re all constructed only from odd-numbered harmonics. If drawn at zero phase, all odd-numbered harmonics, at 180 degrees, cross the zero line going downward, whereas at the zero-degree point, they cross the zero line going upwards.
That is some revolutionary information for my hippocampus to assimilate Yeah I would really like to see some distortion samples and get a hold of whatever program you used for this now
This was incredible, I love these visualizers and your explanation of things. I have a sneaking suspicion that my video on linear phase band splits and achieving loudness in mastering from a few weeks ago have something to do with the algorithm blessing this video these past few days lol. The second half of my video shows this same effect. Whether true or not, it is well deserved - this video is awesome and explains the phenomenon much better than I could, in a less niche way.
Awesome video. I knew this is how our ears work. The little hairs in our ears only know about the frequencies that are close to their resonant frequency. They don't react to other frequencies so they can't know about them. What I was surprised by is that no one else had made this video before you. I just assumed someone must have made this video to prove a point but no. So thanks for making this little demonstration. The world needed it.
MP3 data reduction and triode tube amplifiers also both cheat the ear by recreating strongly modified waveforms. Triode fans claim to hear more details than in unprocessed music, so its distinct distortion may even act like a kind of hearing aid.
interesting fact: not just the square wave (or any phase shifted version) can be constructed only sine waves, any possible continuous wave can be created from pure sine waves given enough of them.
Is there a name for the concept? Of optimizing the wave for loudness like this, not necessarily the phase shifting Also I think the tilt you see is due to low/high pass filtering by whatever encoding is being done by CZcams or your PC.
Many sound chips will have quite a bit of DC offset, so to avoid clicking noises programs that emulate them will use a high pass filter to eliminate it, including famitracker.
So that explains the slanted square waves I keep seeing in Commodore 64 and NES tunes, that's actually really interesting. Also recognized the two example tracks you used, one I think is from King's Quest(?) but I know I've heard it in an old DOS game before, and the other is from one of the Ultima games, both playing on a Tandy 3-voice card.
And that's why when I learned roughly what sound waves are I was like "does this really mean anything i can decypher?" and the answer is no, you need a machine and that machine is both your ears and computers.
3:14 BRUH THIS IS MINDBLOWING 🤯. That looks like a periodic arcsine! I've been using DAWs for quite a while, but never noticed a similarity between squares and arcsines
It's not quite the same, the rotated square wave has a vertical asymptote at every peak at it's limit (that is, it goes to infinity) while arcsin does not.
Since they try to represent the same waveforms with a lower amplitude resolution, then phase shifting to create as much destructive interference as possible will result in lower peaks, which can be represented using less data. I only dabble in this stuff but that's my understanding do far, it's really ingenious.
You essentially get the modified triangle wave by using a cosine instead of a sine in the harmonic series, and the closed form uses what's called the Lerch transcendent, apparently. It looks like it also just so happens to be the integral of the modified square wave in the same way the triangle wave is the integral of the regular square wave. I guess that makes sense. Integration and phase shift are both linear operations, so you presumably can simply exchange the order of operations to get the same result.
I've always thought that phase would become apparent at bass sounds near the threshold of hearing (say 30 Hz or less). I'd expect high-frequency receptors in the ear would be able to notice the step change at each cycle as a transient, perhaps not individually but as something different, so if one randomizes the phase, the transient would be smeared, changing the perception. If you ever try that, please share!
It doesn’t matter for how it sounds, but it DOES matter if you put the signal into a distortion stage. It will distort completely differently, because the peak levels of the phase shifted wave are a LOT higher compared to regular square wave as mentioned near the end of the video. Adding an allpass filter for phase shift is a really good technique for getting some varied sounds out of distortion or saturation later in the chain, try it out!
HOMESTUCK
I’ll keep this in mind, sick trick ty
Allpass filters (and delay lines) are the biggest thing in digital processing. You can do so many things with them!
@@Eugensson Definitely. You can create so many effects with only a couple of allpass filters. It's still one of the last things people learn how to use, when it actually should be one of the first.
does fl have anything that can do allpass filtering?
Amazing, I’ve been an electrical engineer for years and it never had even occurred to me that phase changes in the harmonics wouldn’t be perceivable in our ears.
I'm in the same boat as a computer engineer. Just never occurred to me
I was curious about this back in undergrad so I experimented with phase distortion with synthesizers and was shocked.
I'm a little disappointed that he didn't explain why--the cochlea acts more in the frequency domain. I'm not 100% sure this is true, but based on my understanding: there are cells all along the cochlea and due to the structure of the cochlea (hint: it's a tapered resonant waveguide type thing), the location of the cell kinda determines which frequency it is sensitive at. The cells activate when it vibrates, which makes it insensitive to relative phase but sensitive to frequency/pitch.
I'm sorry, don't you mean audio engineer?
I'm an EE too and had to take a class in college some years back involving audio processing (essentially turning a time-domain audio signal into a DFT, doing operations on it, and turning it back again). I can tell you that, while getting rid of phase info doesn't make a huge difference for relatively simple waveforms like square/triangle waves that are steady state for hundreds of milliseconds at a time, it absolutely matters once you get into things like a human voice. One easy "robot" voice effect is to just lose all the phase info from your DFT before converting it back to the time domain
@@karnage5888 no, electrical engineer. At the end of the day, audio is just an electrical signal anyways, though, so it still applies. I've done countless hours of work on different audio related projects over the years
that "sideways" triangle wave could mean PHAT basslines without being overcompressed in mastering. psychoacoustics are fascinating.
I mean it wouldnt really be "fatter" it would just be louder
@@donit. Exactly the point, you can pack a giant punch into your drop with the right wavetable selection for your bassline synth.
@@Savage-en1ms I mean you could do that anyway by just turning the other elements down lol
@@donit. That's a useful technique in nowadays world of volume normalisation and the loudness penalty imposed by streaming services, however you can still achieve a massive, "full" sound that competes with other tracks nicely. If the waveform of your bass sound has lower amplitude peaks while still delivering a massive chonky fatness, you can make your track really stand out.
@@Savage-en1ms I dont really understand what the difference would be tbh. the bass will sound the same in both cases. maybe the resulting song will be a tiny bit louder , but as long as its over 14lufs that doesnt really matter I'd say. the only difference it could make is when you have something like compression or distortion somewhere in the chain, but in that case the non sideways triangle wave would get more distortion.
2:33 The reason that square waves are not "horizontal" in those videos is because of a DC offset filter. It's effectively just a capacitor and resistor in real life, but what it is doing in software is just removing DC offset. that's why different duty cycles of waveforms shift up and down, as well. DC offset can strain speakers and amplifiers that have no DC offset filters, as well as cause then inevitable popping you hear when you turn a system on/off. We try our best to remove DC offset, since it's really not a good thing, so we have them on basically every audio device nowadays.
So it's just highpass filter with very low cutoff, around 10 hz
@@ltva8781 yeah, exactly. Sometimes the cutoff frequency is even lower so low bass around 20Hz can pass through better, but generally it's between 1 and 10Hz.
Perhaps both explanations dovetail. Highpass can shift the phase of the signal, which is the rotation he showed.
@@crackwitz High pass filters don't phase shift the signals going past them when they're literally orders of magnitude higher than the cutoff frequency. Yes, it's 45 degrees at the high pass filter's cut-off frequency, but that is usually between 1 and 10Hz, where it doesn't matter anyways.
@@TeslabladePlaysMC So you can test this in LTSpice. I created a 100 Hz square wave swinging from -0.5V to +0.5V and ran it through a 10u series cap and 2.2k shunt resistor (corner frequency 7.23 Hz). The 100Hz fundamental is only attenuated by 0.022 dB so its amplitude should be 0.99x what it normally is, but there is a slope that drops 100mV on top of the filtered wave (going from above it to below, roughly equal area in the difference). The 3.960 degree phase shift at that fundamental freq is much more likely to explain that.
When a square wave starts to be more affected by amplitude response, you see a curved drop on the top of the square wave, not a roughly linear one. The sawtooth-like slope is a result of a high pass that is phase shifting noticeably but not attenuating noticeably.
You realise that you are listening too much to chiptune music when you can tell the difference between the actual square and the sine way that sounds like the square
you do realise your comment is dumb right ? the harmonic content is the same, there's no way you or anyone or anything could differentiate the square square wave and the jumbled up square wave because there IS no difference.
You realize that you *create* too much chiptune when you realize *why* you can tell the difference
@@ghastlyGrenadine true, I have easily 20 projects on fl studio with chiptune
When u purposely lie on the interent 😊
there is no man alive who can hear the difference
there is something really creative you can do with this concept if you know sound design; while at normal pitch you cannot hear the difference between the waves, going down a lot of octaves *does* let you hear the phase rotation; ive been using this technique to create interesting growls and reeses (im a neuro/dubstep producer), because the usual clicky texture of the square/saw doesnt come through as much anymore
i've never thought of this. i'm gonna try it out
I think this happens when the frequency comes into the range of the temporal resolution your hearing, so that you don't hear an "average" spectrum of a periodic signal anymore, but instead the spectrum variing over time?
@@VintageTechFan yeah, and when you have a normal saw/square, the only thing you would hear would be clicks, since all of the frequencies overlap to make a click; rotating the phase just displaces that and lets out different waveshapes (and the deeper you go the more movement that waveshape has before it repeats) :3
What software / VST do you use to rotate the frequencies?
@@Zadamanim well, you can use something like an allpass filter to rotate them, tho you dont get very much control (serum has an allpass, theres also disperser from kilohearts)
what i personally do is i use a wavetable synth and go inside of it and rotate the phases manually, it lets you do it custom for each harmonic
Когда чуть не поперхнулся чаем, услышав "прекрасное далёко" в начале
This reminds me of doing a square wave in FM. My mind bugged out when I looked at a "square wave" oscilloscope that had a sine wave cut by a bunch of loud spikes.
hey reimu!
@@the2323guy ☯️
@@TailRecursive fantasy seal
What happened to the FM square wave? What wave modulated it?
@@christiantaylor1495 it's a sine wave and another sine wave with the double of the frequency and some saw-like harmonics. I'm not fully sure which one modulates which but you can replicate this on an OPL/AdLib by choosing Alg1, turning up feedback and setting the op1 multiplier to 2 and the op2 multiplier to 1.
How remarkable! Based on my understanding of how audio perception works, it makes perfect sense for phase to not matter, but I never really thought about it.
You can hear a difference. But only for simple cases like 2 squares with different phases for the sub waves. the problem is that it is very insignificant and if you listen to more than just a side by side comparison you don't have a chance to distinguish it.
Yep it’s all the same when the Fourier transform is considered.
Can't express how surprised I was when I heard the melody of the first few seconds. Humming that thing all the time for the last 10 years or so.
If you'll lower the frequency of the ''randomized-phase square' to the "bass range" it actually starts to sound different (still "squarish" but more dirty). Another interesting expirience is to shift phases of only certain harmonics (for instance take a sawwave and shift only its evens by 90°). While the thing is barely noticeable at higher freqs, it's a whole new world of subtle (or not so subtle) variations for bass sounds. (Ah, I see a few people already mentioned this in comments above. Anyway.. :))
How do you do experiments like that?
@@BellXllebMusic It depends on what tools you're more familiar with. Many "additive" (and derivative) VST synths allow one to set an arbitrary phase for each harmonic. Though for more technically accustomed person I guess it's much easier to use some math tool to generate a waveform of interest (for example I do this via Octave script) and then put it to whatever synthesizer for playback.
Sawtooth wave became more like rectified sinewave when you shift the harmonics phase, thats why it heard the same..
The harmonic content of the wave is identical.
But the transient behavior is slightly different because of the phase warping.
Both waves are activating the exact same parts of the cochlea(harmonic content) But the kinetic interplay with the eardrum is different... just because of the phase-warp.
So the square wave has just a slighty punchier/pluckier transient.
But it would basically be totally unoticable unless you were playing low bass/sub register.
But honestly it might be too fast for the brain to even understand lmao
I think I could hear the difference
I just did some very rough testing, and determined I could hear a significant difference up until around 750hz. Anything nearing 1k and above sounded very similar to me. The lower I go the easier it is to recognize the various overtones that have been unmasked by the smearing of the phases, which break the transient behavior of the square.
I’d be very interested to see some proper studies of humans abilities to perceive phase differences at varying frequencies.
They also probably interact differently in polyphony. Maybe the "noisier" phase creates different distortion when mixed with other "pulse" shapes.
@@jshstuff from my limited reading on the general scientific research, human hearing is far from understood. The mechanical aspect of the ear drum, bones, cochlea can be described but the neurological processing is incredibly complex and difficult to interpret. I've read a few papers on humans who suffered brain injury and animal testing where specific brain regions were impaired. With that you can see how parts of audio processing no longer exist while others remain fully intact. It gets even more complicated where the processing isn't isolated, two (or more) regions feed information between each other before giving an output response.
Phase is used to locate where the sound is coming from as the left/right ear receive them at a slightly different time. It becomes more complicated when a sound is say directly overhead and therefore both ears hear the same phase. But sound doesn't reach us just through the ears, our skull transmits sound at a different velocity such that we can differentiate the vertical position. Most animals do not have the cognitive processing to achieve this and will tilt their head such that both ears receive a different phase.
Bones act as a low pass filter so high frequency sounds reaching each ear are more difficult to positionally locate. Additionally our brains have a limit on frequency processing. Very high (audible) frequencies are impossible for us to process and interpret phase differences between ears. This is why there has been a push for emergency vehicles to switch from the traditional high frequency sirens to lower frequency white noise-esque sounds. You might have noticed it with large vehicle reversing, instead of shrill beeps you'll here "shshshshshshshsh", "shshshshshshs". Our brains can quickly and accurately use the phase difference to locate the vehicles position.
About 15-20 years ago I worked on audio and video encoding. It was absolutely fascinated for how much it revealed about our brains. Lossy audio codecs remove huge amounts of information simply because our brains can't tell the difference. That is done before compression as there is no point encoding signals we are incapable of differentiating. Back in the 2000s there was a company who embedded a user id into the audio that was unnoticeable to humans and more importantly would be left intact after re-encoding such that someone sharing an mp3 (or otherwise) accessed through subscription or purchase could be identified.
Неожиданное место, чтобы услышать "Прекрасное далеко"
это точно было оно? Я тоже сижу в замешательстве, вроде знакомая с детства мелодия, но все равно не уверен, она ли это...
@@4stringed а вроде последний раз в детстве и услышал
Да уж
Ага, совсем не ожидал
да))
Hearing "Прекрасное далёко" in some random youtube video about square waves felt like derealization
As a Russian, these first notes kinda made me shed a tear of nostalgia
interesting funfact about this: A normal square is basically perfect distortion, you cant really distort it more, at least not through Clipping, BUT if you mess up the phases first, you can distort a squarewave further.
Most (If not, all) fuzz pedals basically just square off the signal of your guitar.
You make music?
@@monsieuryubi75 yee
What happens if you distort it as much as possible this way. Will it become white pink noise?
@@Currywurst4444 yea, if you distort something too much it'll end up as some kind of noise
as a synth player and computer engineer this was one of the coolest things i've ever seen. The slanted square wave is super noticeable on the minilogue oscilloscope
Wow! I've never thought about rotating all the frequency components by a fixed amount to minimize the crest factor of a signal. I've never seen that in any signals and linear systems textbook.
So I guess to our ears, phase is only significant if it cancels or boosts other sounds.
2 other cases where a difference is meaningful
-if it’s at a low enough frequency
-if there’s nonlinearities in the system after the square wave (imagine hard clipping the normal square vs. the phase randomized square)
I thought this was a meme about airline stocks recently
friendship with square wave ended, now weird looking square wave is my best friend
0:51 This song reminds me a lot of the refrain of "Прекрасное далеко" from the Soviet movie called "Guest from the future"
Да, мне это тоже это напомнило
Maybe people can't hear phase when it comes to square waves (or probably any strongly periodic signal), but phase is certainly important for other sounds. I've computed short time fourier transforms for voice clips, and if I keep only the magnitude and discard the phase, then reconstruct the sound with Griffin-Lim, the resulting voice sounds really muffled.
square waves in music are fairly long in duration, so shifting the phase around in a 16th note doesn't affect our perception of it. but for speech the fricatives and plosives as very short duration, and distributing their energy across an entire word is definitely going to muffle it.
This video is awesome, you should make a walkthrough of how this square wave is made so we can make experiments.
0:46 it still kinda has the look of a square wave, but with a different shape.
In some ways this was an eye opener. For example I'm so used to just taking a triangle wave for granted that it never occurred to me that it could be compressed losslessly like that.
at lower frequencies they do tend to sound different, but it is fun to mess with the phases. also! you can do this in the vst Vital
This is a really cool video! Although I mostly know about how sine waves can be stacked to approximate a square wave, I've never though at all about how they could have different phases, and the bit about optimising the triangle was also totally a surprise! I suppose that's why triangle waves sound so quiet then, relative to its gain level...
If not mistaken, square waves are actually every 2nd harmonic from the fundamental of the sinewave. And the craziest thing I've learned is that every sound is actually stacked sinewaves with different phase rotation angles and stacks, so it's madness to think that you can make any sound from sinewaves if you stack the right harmonics with phase rotations and amplitudes 😳🤯
@@morpheon_xyz I hope you’ve watched the Posy video about that ;)
@@kaitlyn__L I do believe it's there where I became extremely convinced about that lol. I mean when designing sounds we don't think about it, but that helped me understand a lot more too lol
@@kaitlyn__L doesn't anybody read manuals? It's literally in the manuals for synths
@@morpheon_xyz But it's important to not think about it much. And it's actually wrong, because when you use frequency shifting for sound design, you stop the harmonics from being multiples of the fundamental, and get harmonics that can't be drawn in additively.😊
I hear an distinctive difference between those two. They sound almost the same listening on my smartphone speakers, but quite different listening with my headphones
This helped me a lot in my uni assignment in maximJs, thanks mate!!
that square wave slant happens when you apply a high pass filter
Which, if I remember well, produces a phase delay that is different for each frequency.
I liked the inclusion of the PCjr SN76489 version of Space Quest. I remember taking my Sega Master System emulator's SN76489 emulator out, and adding it to a DOS emulator, then making a few I/O reads respond differently for Tandy 1000/PCjr, and Space Quest started drawing a linear frame buffer instead of the EGA planer buffer, and it talked to the SN76489 instead of the internal speaker timer chip. Good memories. 😁
The other sqaure wave can be used on the NES on the 1 bgit delta pcm because it doesn't have to jump up and down instantly.
Oh shoot, I’ve contemplated the use of the DPCM channel as a fourth waveform in a variety of ways, but never though a square wave would be possible. Now this is something I really want to try out!
7 bit pcm too!
@@ssg-eggunner I found you hihihihihiee hee heeee
@@bosscrafty You can use 7-bit pcm to sq
Apparently 7 bit PCM is real expensive on the processor though. I didn’t even know it was a possibility until very recently because it seems games hardly used it.
Heh, "meander", nice......
For those interested: the name for square wave (exactly square wave, ie. impulse signal with 50% duty cycle) in some technical groups (including the entirety of Russian/Post-Soviet science) is often substituted with "meander", after a Greek pattern, not a river curve...
I knew that the phase could not be heard... this is a really good visualization.
This is amazing! Thanks for the great video and explanation!
Fantastic little video!! Thanks for sharing!! :D
0:00 Гостья из будущего? :)
The interesting thing is that this isn't just shifting the phase of the individual harmonics by an equal amount, as that wouldn't change the shape of the wave, it would just change the starting phase. To get the shape change one needs to construct the math behind the diagram on the left (two separate Fourier series, one for x(t) and one for y(t), one with cos terms only and one with sin terms only), rotate that (using a matrix), and then rearrange the result back into a new Fourier series (using angle sum and difference identities I suspect?)... My capacity to do the algebra in my head has been exceeded... Tempted to start getting pencil and paper out...
Yup, it’s shifting the phase of each harmonic by a different amount. The math is much easier if you use complex exponentials, since the harmonic-specific phase shifts can be trivially encoded in the complex Fourier coefficients.
@@Polychromophilia The fucking what? Man I need to dig into this kind of maths, never learned fourier transforms and now I feel like I won't be able to produce music to the level I want to produce it at if I don't wrap my head around it
@@TheMrVogue You don't need to know any of that to make music, all you really need to know is that any sound is mathematically equivalent to a bunch of sine waves of different frequencies added together, which you should already intuitively understand if you've ever used an eq. If you want to know more you can read up on things like Fourier transforms, the harmonic series, and Nyquist theorem but they aren't at all necessary to know
@@tristanwh9466 I appreciate the encouragement... I've been making music for a while, but this kind of low level knowledge I think is what separates a master from a novice... At least knowing what you're doing to the mix by using certain waveforms, etc... Maybe you're going for a particular sound, but you're really particular, I think this kind of stuff is what lets you add in that extra sauce to polish things to a mirrored finish.
the phase shifted square wave looks about what I would expect to see when looking at a clock in a high noise environment tbh
I had a sneaking suspicion about this for years but never bothered to find out. Thanks for scratching that age old itch!
Ach, listening to this made my ears start ringing. Thanks a lot...
I didn't expect to see (or rather hear) a ZZT reference today but I'M SO GLAD I DID
1:14 this is the exact tone my radio alarm plays, i thought i had an alarm from it just now
Thank you for answering a question I didn't even know I had, or at least couldn't figure out how to search. This is very informative, concise, and well-presented!
those slanted lines are due to high-pass filtering, a technique used by the NES' synthesizer to cut out low frequencies no one can hear
Those ZZT sounds stirred up some deep feelings.
Nice space quest theme. A great nostalgie trip.
It's kind of amazing how they sound indistinguishable despite how different they look, but it's important to remember that what we hear are not the waveforms themselves, but the frequencies. When those overlayed frequencies (that normally combine to comprise a square wave) are unchanged, it makes sense that we hear the same thing. It's also yet another testament to how ubiquitous sine waves are to the literal fabric of reality.
And if you think of WHY we hear the timbre of sound but no the phase, it's because phase doesn't carry much useful information. It tends to be jumbled up in the world due to reflections etc. It's like why we don't see the polarization of light, even though it is another dimension that each photon falls somewhere on (ignoring circular polarization).
yeah dude! im with you.
we should just look at the waveform of a whole piece of music... not square...
actually we can hear phase pretty easily, when tuning a stringed instrument.
but maybe i don't know what phase means.
@@simonlinser8286 Relative phase of two nearly the same tones playing simultaneously? Yeah.
@@gblargg You can actually see the polarization of light, it's most obvious on a white LCD if tilt your head side to side, you should be able to see a blue-yellow cross shape which rotates along with you
Loved the ultima sample, I can tell you are a true man of culture
This video is incredible, and the subscribe ask at the end was hilarious
3:35 wierd sine wave
This is one of the only ways for me to enjoy music
A true mathematically perfect square wave (or sawtooth) would rip a hole in space time, due to the infinte energy needed for the instant discontinuity. Luckily, humans can only hear up to between 15 and 22k (depending on age and other factors), so we don't need to blow up the universe to make chiptunes : )
Nope, its not a Dirac pulse. The sum of energy stays finite because the amplitude falls with pitch.
Man, audio synthesis is just full of mindblowing tidbits that aren't obvious, but are easy enough to digest once it's explained. It weirdly feels impenetrably difficult and stupid-easy at the same time.
Nooooo! You're telling me my triangle waves could have been optimized this whole time?
Great video! I read a note recently in a small-signal audio design book that made this claim (that phase shift between harmonics in a signal is imperceptible to humans), so it's cool to see that demonstrated.
What's really interesting is that the lower the pitch, the more perceptible the phase shift becomes. And imagine using one of these faux square waves at LFO speeds for modulation!
One quality that’s easy to see in all of these … alternative square waves … is “half-wave symmetry”:
If you think of these waves as mathematical functions, the value of that function at any point is _exactly the _*_negative_*_ of its value _*_half a wavelength_*_ away_ .
If you look at waveforms from the lower register of a clarinet or bass clarinet, they also have this property (up to a point)!
So, its value at zero degrees is exactly the negative of its value at 180 degrees. Its value at 10 degrees is the negative of that at 190 degrees, and so forth.
That’s because they’re all constructed only from odd-numbered harmonics. If drawn at zero phase, all odd-numbered harmonics, at 180 degrees, cross the zero line going downward, whereas at the zero-degree point, they cross the zero line going upwards.
I wanted to hear the sound of the wave as the phase was continuously rotated.
Excellent! I always love hearing those classic game soundtracks, and it's even better when I'm learning as well :)
2:04 is so familiar, but I can't remember the name.
Ultima 6
Wow, several of my previous confusions all answered in a single video.
And now I know what those spiky waveforms in OPL chips actually are.
That is some revolutionary information for my hippocampus to assimilate
Yeah I would really like to see some distortion samples and get a hold of whatever program you used for this now
You have a very nice voice, very pleasent to listen to.
Also, this makes total sense, of course it would sound the same.
0:01 "electronik" music?!
"guest from the future" music, to be more precise :)
@@Formertris это наша музыка!
This was incredible, I love these visualizers and your explanation of things.
I have a sneaking suspicion that my video on linear phase band splits and achieving loudness in mastering from a few weeks ago have something to do with the algorithm blessing this video these past few days lol. The second half of my video shows this same effect. Whether true or not, it is well deserved - this video is awesome and explains the phenomenon much better than I could, in a less niche way.
The song in the beginning brought a smile to my face
Soviet movies are the best
I have been blessed by this video.
This is amazing. I will keep that in the back of my head forever.
Everyone gangsta until the phases start cancel each other out ;)
Awesome video. I knew this is how our ears work. The little hairs in our ears only know about the frequencies that are close to their resonant frequency. They don't react to other frequencies so they can't know about them. What I was surprised by is that no one else had made this video before you. I just assumed someone must have made this video to prove a point but no. So thanks for making this little demonstration. The world needed it.
MP3 data reduction and triode tube amplifiers also both cheat the ear by recreating strongly modified waveforms. Triode fans claim to hear more details than in unprocessed music, so its distinct distortion may even act like a kind of hearing aid.
Wonderful animations, thank you! The visualization of how the wave form is made is quite helpful. Really neat.
interesting fact: not just the square wave (or any phase shifted version) can be constructed only sine waves, any possible continuous wave can be created from pure sine waves given enough of them.
Anyone who finds themselves randomly tearing up when watching this probably grew up in the USSR (if you know, you know)
Omg, you sound so high, I need to play Cypress Hill bits on top of this video
Today i learned that synthesis is about hearing the sound rather than waveforms
The music starting at 1:52 is from Vanguard.
The visuals blew my mind (as musician) so I'd like to learn how it's done. Ty for planting the curiosity.
wait.. the 'fake square' sounds cleaner? 2:15
i just immediately jumped to "harmonics" as soon as the animation popped up
probably youtube audio compression, but i chucked the audio out into my scope and both waveforms looked identical
ZZT!!! That brings back memories.
Is there a name for the concept? Of optimizing the wave for loudness like this, not necessarily the phase shifting
Also I think the tilt you see is due to low/high pass filtering by whatever encoding is being done by CZcams or your PC.
Many sound chips will have quite a bit of DC offset, so to avoid clicking noises programs that emulate them will use a high pass filter to eliminate it, including famitracker.
plot twist: this is a cry for help in morse code
what a lovely experiment and observation! i just think waveforms and their frequency spectrums are so neat
So that explains the slanted square waves I keep seeing in Commodore 64 and NES tunes, that's actually really interesting. Also recognized the two example tracks you used, one I think is from King's Quest(?) but I know I've heard it in an old DOS game before, and the other is from one of the Ultima games, both playing on a Tandy 3-voice card.
space quest actually
i love the dancing waves at 1:52
And that's why when I learned roughly what sound waves are I was like "does this really mean anything i can decypher?" and the answer is no, you need a machine and that machine is both your ears and computers.
I always wondered what happens if you change the phase of every frequency randomly and now I know. Thank you!
This is incredible. I bet there is some bird or other wild animal that can easily discern these "deep fake" square waves.
the loudness war continues
Mom: "we have square waves at home"
This is a really well made video! I'd love to see more like this
I'm very curious to know what software was used to create these visualizations. I would love to mess around with stuff like this.
The Sauce
Okay I legit couldn't tell the difference between those samples 😂 fascinating!
3:14 BRUH THIS IS MINDBLOWING 🤯. That looks like a periodic arcsine! I've been using DAWs for quite a while, but never noticed a similarity between squares and arcsines
It's not quite the same, the rotated square wave has a vertical asymptote at every peak at it's limit (that is, it goes to infinity) while arcsin does not.
@@monster860 Correct! I had the feeling they weren't exactly the same
Mp3 encoding does this, or something similar. (i can see it on an oscilloscope) Maybe it saves space somehow? Absolutely remarkable by the way.
Since they try to represent the same waveforms with a lower amplitude resolution, then phase shifting to create as much destructive interference as possible will result in lower peaks, which can be represented using less data.
I only dabble in this stuff but that's my understanding do far, it's really ingenious.
I literally thought you were about to go "ahhh~~, the goo lagoon" or something.
You essentially get the modified triangle wave by using a cosine instead of a sine in the harmonic series, and the closed form uses what's called the Lerch transcendent, apparently.
It looks like it also just so happens to be the integral of the modified square wave in the same way the triangle wave is the integral of the regular square wave. I guess that makes sense. Integration and phase shift are both linear operations, so you presumably can simply exchange the order of operations to get the same result.
I've always thought that phase would become apparent at bass sounds near the threshold of hearing (say 30 Hz or less). I'd expect high-frequency receptors in the ear would be able to notice the step change at each cycle as a transient, perhaps not individually but as something different, so if one randomizes the phase, the transient would be smeared, changing the perception. If you ever try that, please share!