12
$\begingroup$

I am trying to understand how a SIM7600G 4G modem degrades the audio when configured for 8 kHz sampling rate. I created a reference audio using librosa.chirp to slowly sine sweep from 30 Hz to 3400 Hz. I saved the raw audio using 8 kHz sampling rate.

reference audio

Then I called the modem from a high quality digital land line and recorded the call. The modem answered the call and played the audio. This is the result:

degraded audio

The vertical lines intercept the original sine sweep at 1350Hz, 800Hz, 560Hz, and 440Hz.

Question #1: Do you see an obvious pattern here?

I find it confusing that the sine-sweep went trough, but something added all these artifacts that I guess are aliasing artifacts.

Question #2: Do you know what is going on here?

My only guess is that there is a somewhat-dumb noise canceling algorithm trying to remove specific frequencies from the audio, completely blind to the fact the I am playing a sweep. But I do not know yet what is going on.

$\endgroup$
7
  • 3
    $\begingroup$ First and foremost I'd check that the sampling rate was specified properly, and matches the device's expectation. Note we can only sweep up to half the sampling rate. Your plots show a ridiculous amount of aliasing (and not just aliasing), not explained by a factor of 2 mismatch. I'd also try pure tones of various frequencies. $\endgroup$ Feb 14, 2023 at 13:28
  • 6
    $\begingroup$ Try reducing the transmission volume -- the received signal may be clipped. Also, are you sure the modem records the audio without processing? It may be trying to do gain control or equalization or something else. $\endgroup$
    – MBaz
    Feb 14, 2023 at 13:59
  • 7
    $\begingroup$ Interesting, stft(np.clip(echirp(8192), -.4, .4)), didn't know that's the effect @MBaz $\endgroup$ Feb 14, 2023 at 14:56
  • 8
    $\begingroup$ @OverLordGoldDragon Experience has taught me that unexpected harmonics implies clipping at least 80% of the time :-) $\endgroup$
    – MBaz
    Feb 14, 2023 at 15:00
  • 4
    $\begingroup$ @MBaz spot on! Reducing the volume to 40% of the original removed all the artifacts I was complaining about. degraded audio with lower volume. $\endgroup$
    – Peter
    Feb 14, 2023 at 16:29

2 Answers 2

11
$\begingroup$

This behavior is likely caused by clipping (as nicely illustrated by @OverLordGoldDragon in the comments). Where exactly clipping is occuring is harder to tell, but a simple remedy is to lower the level of the transmitted signal, and/or the gain in the receiver, to make sure all devices involved see a signal that is within their dynamic range.

$\endgroup$
1
  • 4
    $\begingroup$ let there be spaghetti plt.imshow(np.abs(librosa.stft(np.clip(librosa.chirp(fmin=100, fmax=4096, sr=8192, duration=1), -.4, .4), hop_length=1, n_fft=512))[::-1], cmap='turbo', aspect='auto') $\endgroup$ Feb 14, 2023 at 16:53
15
$\begingroup$

To perhaps help future readers, here is a graphical explanation of the two behaviors seen: harmonic distortion and aliasing / frequency fold-over:

Original diagram with added text, showing increasing frequency that wraps back at top of graph.

Harmonic distortion can result from any kind of non-linearity in the signal chain. In this case it was clipping due to excessive volume, but similar errors can be caused by quantization, rounding errors or endianess errors.

Harmonics occur at evenly spaced intervals, at 2x, 3x, 4x, 5x, ... the original signal frequency. Sometimes only even or only odd harmonics may be visible. In this graph the odd harmonics are much stronger than the even harmonics.

Aliasing occurs when the frequency of the signal or (in this case) its harmonics exceeds half of the samplerate. In a sweep it is recognizable by the direction of frequency sweep changing at the Nyquist frequency. Aliasing is caused by a samplerate that is lower than twice the largest frequency in the signal, and the remedies are either to increase samplerate or remove the higher frequencies.

$\endgroup$
2
  • 1
    $\begingroup$ “In this graph the odd harmonics are much stronger” — and since odd harmonics characterise a square wave, I'm guessing that's a strong indication of clipping? $\endgroup$
    – gidds
    Feb 16, 2023 at 23:29
  • $\begingroup$ @gidds yes, the issue was indeed clipping. Reducing the volume to 40% of the original removed the artifacts I was complaining about. degraded audio using reference with lower volume $\endgroup$
    – Peter
    Feb 17, 2023 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.