9
$\begingroup$

I stumbled upon Hilbert transform when researching single sideband modulation. Apparently when the demodulator frequency is bit off by $\Delta f$, the signal after demodulation and low-pass filtering is not $m(t)$ where $m(t)$ is the original signal, but rather:

$$m(t)\cos(2 \pi \,\Delta f \,t) + \hat{m}(t)\sin(2 \pi \,\Delta f \,t)$$

...where $\hat{m}(t)$ is the Hilbert transform of the original signal. So the inaccurately demodulated signal oscillates between the original signal and its Hilbert transform.

I tried the equation for real music. I noticed that if $\Delta f$ is 100 Hz, frequencies are markedly distorted, but music at $\Delta f$ of 10 Hz sounds acceptable (but for someone with good musical ear it might be possible that 10 Hz shift wouldn't be acceptable).

So, I became interested of whether a human could hear raw Hilbert-transformed signal -- then $\Delta f$ would be 0 Hz but there would be constant phase shift in the SSB demodulation equation. It can occur in single-sideband modulation for example if the demodulator has exactly the same frequency as the modulator, but its phase is 90° off.

I can't notice any difference in the original signal (music) and Hilbert-transformed signal that I created.

I researched a bit whether there's any theoretical justification on this, and found this answer.

A Hilbert transform introduces a fixed 90° phase shift for all frequencies. Practical Hilbert transformers can only do this over a range of frequencies. Clearly a 90° phase shift represents a longer delay at low frequencies (one fourth of the period) than at higher frequencies where the period is shorter

[snip]

So a Hilbert transform filter passes high frequencies quickly while introducing progressively longer time delays for lower frequencies. In the limit where the frequency approaches zero, the time delay approaches infinity.

[snip]

However, a typical audio signal spanning a number of octaves will be distorted due to high frequencies arriving sooner than low frequencies.

Can this really be the case? I didn't notice any error in the timing of different frequencies.

I think the Quora answer might be erroneous, because Hilbert transform adds delay to the individual sine/cosine wave components of the original signal, with each component delayed by 90°. So for example a sine wave that has always been on, and will always be on, is delayed by 90° (so low frequencies are delayed more than high frequencies). But there should be no way of hearing this, right?

However, what you generally are interested is for example a sine wave that is instantly turned on, for example at the moment $t=0$. Then you no longer have $\sin(2 \pi f t)$, but $u(t) \sin(2 \pi f t)$, where $u(t)$ is the (Heaviside) unit step function that adds lots of high frequencies to the signal, so the signal is no longer a simple sine wave, and the high-frequency envelope, being high in frequencies, shouldn't be delayed as much as the low-frequency sine wave (whose delay / phase we can't hear).

Is my reasoning correct? Or could it be possible that Hilbert transform can be heard in audio by different delay for different frequencies?

$\endgroup$
4
  • $\begingroup$ This will mostly be about the perennial question about if phase shifting (and not linear phase shifting, which is just delay) can be audible or not. I would doubt that a Hilbert transformer that was pretty flat from 5 Hz to 15 kHz, is audible. People would have to be able to compare the original and the phase-shifted version side-by-side (not simultaneous). --- On another note, I might suggest that all of the math displayed in the question be converted to $\LaTeX$. It's not hard to learn, $\endgroup$ Nov 5, 2022 at 23:36
  • $\begingroup$ Another thing is that your question is really about frequency shifting. We can definitely hear that if the shift is sufficient. That is because harmonics become non-harmonic if the are all shifted in frequency by a constant amount. This is the sorta "duck" sound from single-sideband that happens when the receiver demodulation oscillator is not tuned to exactly the same frequency of the transmitter. It's a common sound that ham radio operators are well familiar with. $\endgroup$ Nov 5, 2022 at 23:44
  • $\begingroup$ Well actually the question is about the Hilbert transform. I did observe that frequency shifting can be heard, but I am unsure if phase shifting (Hilbert transform) can be heard. $\endgroup$
    – juhist
    Nov 6, 2022 at 7:29
  • $\begingroup$ The title of the question is about the audible effect of the Hilbert Transform, but the body of the question is about shifting all of the frequencies in $m(t)$ down by a frequency differential of $\Delta f$. When harmonic tones are shifted in frequency and all harmonics are shifted by the same $\Delta f$, the resulting tone will not be harmonic nor periodic. This is what creates the sorta "duck" or "quacking" sound of human voice received in single-sideband where the receiver and transmitter are at slightly mismatched frequencies. We tune it by ear until the voice sounds natural. $\endgroup$ Nov 6, 2022 at 8:49

3 Answers 3

12
$\begingroup$

Can humans hear Hilbert transform in audio?

Generally no.

The human auditory system is fairly insensitive to monaural phase shifts. "Monaural" means "same phase shift for both ears". That's very different from "interaural phase differences" which the ear is very sensitive to and even very small shifts are easily detectible.

One can consider the Hilbert Transform some sort of an allpass filter in the sense that $|H(\omega)| = 1$. Most (but not all) monaural allpass filters are indeed inaudible. What you can hear are large differences and/or gradients of the group delay over frequency.

The Hilbert transform is a bit of an odd-ball. The impulse response is infinite in both time directions and hence it's infinitely non-causal. The group delay is actually 0 except for DC and Nyquist where it's infinite. You can't implement anything like this, so any real world implementation can only approximate an ideal Hilbert Transformer.

Any implementation will have

  • Causality bulk delay
  • Pre-ringing
  • Some "anomalies" in either group delay, amplitude or both at very high and very low frequencies

Pre-ringing can smear out transient signals and low-frequency group delay can make the bass less "punchy" and compact. To what extent this is audible depends (a lot) on the specific signals and the details of the approximation. In most case a well designed Hilbert Transformer will have little or no audible difference, unless very low latency is required.

The Hilbert Transform and other allpass filters are actually a well known "tricks" to create a second audio signal that sounds essentially the same but is largely uncorrelated to the original signal. This can be used to create a diffuse stereo signal from a mono signal (stereo reverb, surround sound).

$\endgroup$
4
  • $\begingroup$ Indeed, I implemented my tests using Fast Fourier Transform + inverse FFT for the entire signal. That's probably non-causal. It will require the entire signal to be present, so it can't be performed on the fly. $\endgroup$
    – juhist
    Nov 6, 2022 at 12:44
  • 1
    $\begingroup$ Any chance you could include a demonstration so we can hear (or fail to hear) the effect on full-range music for ourselves? I think that would really make this answer complete $\endgroup$
    – Edward
    Nov 6, 2022 at 17:11
  • $\begingroup$ I'd have to find a piece of music that's well recorded but not copyright protected. Almost all eval tracks that I use can't be posted publicly. Let me see what I can find. $\endgroup$
    – Hilmar
    Nov 6, 2022 at 18:09
  • $\begingroup$ I also have the code I used for my tests, but the test audio was recorded from a radio so most likely copyright protected. I could share the code, though. $\endgroup$
    – juhist
    Nov 6, 2022 at 18:15
4
$\begingroup$

Here's my GNU Octave code I used to create Hilbert transform of the music:

[y,fs] = audioread('wavsample.wav');
y = y(:,1);

function z = analytic_signal(x)
        x = x(:);
        N = length(x);
        X = fft(x, N);
        z = ifft([X(1); 2*X(2:N/2); X(N/2+1); zeros(N/2-1,1)], N);
end

z = analytic_signal(y);

d = real(z);
audiowrite('wavsampleM.wav', d, fs);

d = imag(z);
audiowrite('wavsampleH.wav', d, fs);

It reads a stereo file from wavsample.wav, stores it in mono into wavsampleM.wav and its Hilbert transform into wavsampleH.wav. Most recorded audio is stereo, and comparing mono with stereo would be unfair, so I had to convert it to mono so that I can do the Hilbert transform on the only channel. Of course it might be possible to perform it on both channels simultaneously.

With wavsample.wav containing music, I was unable to distinguish wavsampleM.wav from wavsampleH.wav. This supports the other answer that Hilbert transform can't be heard.

However, what you can hear is single-sideband modulated signal with frequency error in demodulation:

x = ((1:length(y))/fs)';
e = 2*pi*100; % 100 Hz error
d = real(z .* exp(-j*e*x));
audiowrite('wavsamplessbdemod.wav', d, fs);
$\endgroup$
2
  • 1
    $\begingroup$ You may want to apply it separately to the average of the two channels and the difference between the two channels, then apply the transformed difference to the transformed average to get back stereo. $\endgroup$ Nov 7, 2022 at 13:29
  • 1
    $\begingroup$ I don't think that makes a difference. Hilbert transform is a linear operator, so transforming channels separately is equivalent to transforming difference and average, and converting back to stereo. Of course, there could be rounding differences but I don't believe humans would hear that. $\endgroup$
    – juhist
    Dec 2, 2022 at 17:20
1
$\begingroup$

One good technique for comparison is to process one mono audio stream, and play back in headphones with one channel/ear carrying the original signal, and the other the processed one. Your brain will spot differences. Put in necessary delay to adjust for processing latency, or shift one stream relative to the other in a DAW. If the sound is very close, the perception will be a single source of music/sound in center stage. And artifacts will sound like they're off-stage.

Phase shifts will distort the spatial soundscape in stereo, losing the position of instruments.

$\endgroup$

Your Answer

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

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