# What kind of effect is this and what is it caused by?

In the screenshot below I have two audio signals. The upper one is the audio signal that is created with python and then played, whilst the lower one is the "same" signal but recorded via microphone on an android device. Tried my best at aligning them in audacity but I am unsure where the "fade-in" comes from. The same thing happens on the other end of the signal, but in reverse of course.

Also, there is no other noise in the recording, as I am recording from the audio output relayed to the input and not directly from the speakers (so no background noise).

Don't know which terms to search for. Any help would be much appreciated.

Looks like pre-ringing. That happens whenever you apply a linear phase filter to a signal. In your case that could be the sigma-delta converters or any type of sample rate conversion or other unknown processing that the operating system or the drivers doo.

Since your signal seems to be periodic (at least in the excerpt we see), we can't really tell, but my guess:

You've already solved the mystery of what that is: it's a fade-in. It might be intentional (sounds a lot like Android), so that recordings with sudden high amplitudes on the first samples don't lead to "cracks" from the speaker, or it might be a processing artifact.

Either way, I'd assume your signals would actually be aligned if you shifted the android version so that the "onset" of small oscillation aligns with your first oscillation.

Using a strongly periodic signal like this for alignment is problematic - you can never ever know whether you're aligned, or off by a multiple of a period!

The term you're looking for is cross- and autocorrelation and it becomes relatively easy to use when you don't generate a sine, but maybe white noise, or a up/downchirp. You'll have heard of the Heisenberg uncertainty: two signals linked through the Fourier transform can only be "sharp" in either. In your case, the sine is very sharp in Fourier domain (frequency), because it's literally a single line in spectrum, but it means it's very uncertain in time. White noise, on the other hand, is very wide in spectrum, but has nice autocorrelation that reduces it to a single point in time.