# What do I hear when listening to a computer-generated sine wave?

When I use a sine-wave generator (such as this one), I give credit to the software and my hardware that a pure sine wave is produced (as close as is technologically possible) — that is, no harmonics. However, once the signal reaches my speakers and/or the air between the speakers and my ears, are harmonics automatically created within that medium?

Assuming a pure signal (no harmonics), does the vibrating medium naturally introduce harmonics?

• Not sure the medium affects... but remember that a pure sine wave is meant to be infinite. If your pulse is not infinite (which is true), there will be harmonics, for the sole reason of being finite. Feb 15, 2023 at 21:29
• @FGSUZ Why does a finite wave imply harmonics? (I imagine that's been asked here? Perhaps you can help me find it....) Feb 15, 2023 at 21:31
• If you can model the media through which the sound is transmitted as linear (i.e., described well using linear response theory), then the frequency doesn't change. However, real physical media will have some (potentially small) non linear response that can end up producing other frequencies. It is difficult to give an exact answer since it depends on the medium, but someone may be able to provide an answer based on some reasonable assumptions to fill in the gaps.
– hft
Feb 15, 2023 at 21:48
• @FGUZ A windowed sine wave has sidebands, but not harmonics. Feb 15, 2023 at 21:53
• A finite wave implies more harmonics, in a sense. It depends on how you define harmonics, but what I meant was that more frequencies do appear. To be precise, a continuoum of frequencies, as pointed by @JohnDoty Why? It's in any basic course. In short, because a sine function is infinite itself. Making it finite entails building a function which is "0" in some parts and "sine" in other parts". That can be done adding up infintie sine waves, so those are the infinite frequencies you get. Feb 16, 2023 at 21:58

To generate harmonics, you need a nonlinear element. Loudspeakers are not perfectly linear, so yes, they generate weak harmonics. Air is generally very close to a linear medium for sound unless the intensity approaches shockwave levels, so it doesn't normally generate significant harmonics.

Of course, the other things in the chain aren't perfectly linear either: digital to analog converters, amplifiers, eardrums...

• So would it be fair to say that when I play sound from a sine wave generator on my laptop, what I'm hearing is a reasonably "pure" sound — at least in comparison, say, to playing the same tone on an acoustic musical instrument? Feb 15, 2023 at 23:07
• @Aaron, you can't really play "pure" tones [(co)sinewaves] with instruments (except if they are digital). Musical instruments create complex waveforms consisting of many tones (they too have some bandwidth and are not monochromatic) and most often there's some noise-like characteristics at the spectrum. Those, as well as the finite-bandwidth of the "harmonics" are results of the finite duration and the amplitude envelope of the generated sound. These are fundamental concepts to Fourier Series/Transform, Sound/Acoustics and Signal Processing. Feb 15, 2023 at 23:58

## TL;DR

As a pure answer to your question, I would say yes, the medium does introduce harmonics, but they are of negligible energy compared to the distortion induced by other pieces of the chain.

You've already got a good answer but I'd like to add a bit of details here.

## Digital domain

First of all, let's clarify the fact that your software and, up to a certain point, your hardware do not generate a sinewave. They do generate, store and transmit the digital (discrete time and amplitude) representation of a sinewave with some specific coding scheme (there's quite some of them). So, until the "sinewave" reaches the Digital-to-Analogue converter it does not constitute a sinewave and to this extend, it characteristics ([central] frequency, bandwidth, envelope/temporal evolution) are described solely by the sample values in the digital domain.

Just to provide some insight, the bandwidth is constrained by the duration of the envelope, the central frequency by the sampling rate/clock and more (please note that these are not the only factors affecting the aforementioned parameters).

## Analogue domain

Once the digital signal reaches the Digital-to-Analogue converter it will "become" an analogue signal (most probably voltage) to be transmitted to the amplifier that will "feed" the loudspeaker the current necessary to move the cone (please note again the simplification of the whole process).

The digital signal does possess all the information needed for the analogue signal to be an exact representation of the "intended" signal. Alas, in order to create an exact analogue representation of the signal described in the digital domain you'd need to use a brick-wall reconstruction filter (see Wikipedia page for more information on reconstruction filters). This filter has an infinite impulse response both in the positive and negative direction in time (non-causal), making it non-realisable. Thus, we have to resort to other solutions, with two common ones being a step reconstruction converter (zeroth-order reconstruction) or Pulse Code Demodulation (PDM) techniques. Although their imperfect frequency response is somewhat compensated before this stage is reached (their transfer function is known during the design process and is inverted), they do exhibit non-linearities both in the software/firmware and hardware components.

The results here are, distortion (add spectral components, not necessarily harmonics) due to non-linearities, noise due to finite word precision in the digital representation which translates to (hopefully "nicely" distributed) noise and the probability of allowing aliased frequencies in the resulting spectrum (depends highly on the spectral content of the digital signal and is most often of no significant margin - if it exists).

## On the road to sound

The next step is amplification to give it to the loudspeaker cone for "further transmission". To my (limited) knowledge, there's no completely linear amplifier today. There's very well designed amplifiers, (class A, AB, H and even D is getting better nowadays) but still none of them is completely linear. Thus, in this stage the signal will get distorted and the "level" (I do not refer to the audio level) of distortion depends highly on the hardware (design, topology, etc.) and the signal (if it clips your in bad luck).

Next step is the notorious loudspeaker! This, most probably is the most non-linear piece of the signal chain. There's a whole bunch of non-linearities here, in the magnetic induction (not the entire length of the voice-coil is in the magnetic field all the time), there's highly non-linear behavior in the mechanical, moving parts of the assembly very prominent in the high-level/excursion regimes. Lately, the use of "exotic" materials (or meta-materials) has complicated things a bit more (sometimes their use improves some things while in other cases it does not). Like this was not enough, there's drifting behavior to the materials due to excessive heat (the temperature of the voice coil can reach $$200 ^{o}C$$ to $$300 ^{o}C$$ and its impedance can exhibit significant changes), which causes even more complex, non-linear behavior that changes with time

## Sound at last

The final step is for the signal to be transformed to movement of air particles and pressure variations. Now, air is generally treated as a linear medium, which means the spectral content of the signals travelling in the medium cannot change. Of course, no linear material/medium exists. For example, consider the particle velocity representation of a travelling monochromatic plane wave. The particles on the positive half-period will have higher speed than the rest and the pressure would be accumulated on this positive part, steepening the positive part of the wave, leading to a discontinuity in the medium (please note that this is oversimplified here just to make my point). This phenomenon, although true, has negligible effect on the resulting wave, as its effects are countered by other dissipative mechanisms.

All in all, the air does not have a significant effect on the spectral content of a signal, except maybe for the frequency dependent attenuation, which is apparent for rather large distances (in the order of $$100 ~ m$$).

## Summary

From all the pieces in the signal's chain, air is not the one that has the most detrimental effects. The Digital-to-Analogue conversion, the amplification and the loudspeaker are the parts that affect the signal the most. If I had to pick one of those it would be the electro-mechano-acoustical transduction of the loudspeaker with closed eyes (you see that there's two transductions taking place traversing three different domains - electrical, mechanical and acoustical - resulting in distorted signals).

As a pure answer to your question, I would say yes, the medium does introduce harmonics, but they are of negligible energy compared to the distortion induced by other pieces of the chain.

• This is very helpful. The origin of the question was to wonder that, since (acoustic) musical instruments have natural harmonics, does the same thing happen in attempt to hear a "pure" sine wave. Based on both answers it sounds like any "natural" harmonics in a "sine-wave approximator" that might emerge would be negligable, but there would be plenty of "imperfections". Fair? Feb 16, 2023 at 0:51
• Yes, absolutely... Technical advancements in many fields such as electronics, materials, electro-acoustics and signal processing have led to very good designs of all the pieces in the signal chain (from DSPs and DACs to great loudspeaker systems). As you may have already understood, this is not an easy task and, in my opinion, all people involved deserve credits. Regarding the harmonics of sine waves, I believe you can safely assume that the fundamental (sinewave) to harmonics energy ration will be rather high for decent (not very high) levels of reproduction. Feb 16, 2023 at 8:57