100 Days Of ML Code — Day 078

100 Days Of ML Code — Day 078

Recap From Day 077

Day 077, we looked at another property of sound waves. You can catch up using the link below. 100 Days Of ML Code — Day 077 Recap From Day 076medium.com

Sound Waves Continued.

Phase

Let ’s move on now and look at one more important property of sound which is phase So phase really relates to the offset between two waveforms and how they relate to each other. “Phase is the position of a point in time (an instant) on a waveform cycle. A complete cycle) is defined as the interval required for the waveform to return to its arbitrary initial value.”

The first illustration below shows what happens when we’ve got two channels of a signal in phase. When both channels are in phase, we hear the sound at the same amplitude level at the same time in both ears. These two sine waves in the illustration below are perfectly in phase. And the reason I say that they’re in phase is that every peak lines up with every peak, every trough lines up with every trough and so on and so forth or throughout.

Left and right channels in phase. [Source](https://cdn.hashnode.com/res/hashnode/image/upload/v1632826707760/at-XRuDRN.html)Left and right channels in phase. Source

On the other hand, if one side of the stereo signal is reversed, as shown in the illustration below, the signals will cancel each other out, and we get a process called Phase Cancellation. so, these are perfectly out of phase. And what I mean by that is that all the peaks in the first one line up with all the troughs in the second one. All the troughs in the first one bind up with the peaks of the second one.

Left and right channels out of phase. [Source](https://www.uaudio.com/blog/understanding-audio-phase/)Left and right channels out of phase. Source

In fact, if we were using a pure sine wave, combining both signals out of phase would result in silence, since the sounds would literally cancel each other out. In the real world, we normally don’t listen to pure sine waves. Since most of the music we hear and the instruments we record are a complex combination of multiple waves and harmonics, the results of phase cancellation will be equally complex.

There’s something in between the two which can happen, called beating. Which is when we have two sounds that have slightly different frequencies from each other. When two sound waves of different frequency approach your ear, the alternating constructive and destructive interference causes the sound to be alternatively soft and loud — a phenomenon which is called “beating” or producing beats.

So let’s say we have a 440 Hz and the next one is at 441 Hz, so they are one Hz apart. There are so close in frequency. But over time they because one is slightly faster than the other, their going to go through patterns of being completely in phase with each other. So they're adding up of to make something you know just higher in amplitude. And being fully out of phase with each other, in which case, they’re going to cancel each other out, so at atime, they’re completely out of phase, at another time, they’re completely in phase, completely out of phase, completely in phase, and so on and so forth. And so these patterns are going to generate their own unique sound. We're going to hear a pulse once a second, which is called beating.

And this is actually a phenomenon that musicians often use. When they’re playing real instruments. To help them tune. If they hear that beating they know that they’re a little bit out of tune with each other. And the more that beating slows down so if it’s at one, if it happens once a second, it beats at one hertz they know that they’re one hertz apart from each other. If it’s at five times a second they know they’re five hertz apart from each other and so on and so forth. Then when it disappears entirely they know that they’re completely in tune.

That’s all for day 078. I hope you found this informative. Thank you for taking time out of your schedule and allowing me to be your guide on this journey. And until next time, be legendary.