Previous Up Next

21.4.9  Hilbert-Huang transform

The hht command finds Hilbert spectra by applying the Hilbert-Huang transform (HHT) which obtains instantaneous frequency data from intrinsic mode functions (IMFs) extracted from nonstationary and/or nonlinear signal data. The Hilbert spectrum of a signal reveals its time-dependent features.

Examples

Synthetic signal.

To see the spectrum of the synth signal defined in Section 21.4.8 with the FLTK grayscale ramp, enter:

hht(synth,color=false,frequencies=0.1..2.0,output=plot)

You may also pass the list of already computed IMFs as the first argument.

Whale song.

The file nepblue24s10x.wav downloaded from here contains sounds produced by a blue whale in the northeast Pacific. Since the frequency of moans is very low (below 20 Hz, which is inaudible for humans), the file is played back at 10x speed. To load and show the audio, enter:

whale:=readwav("/home/luka/Downloads/nepblue24s10x.wav"):; plotwav(whale)

You can hear the whale song by entering (see Section 28.2.14):

playsnd(whale)

To perform the empirical mode decomposition (see Section 21.4.8), enter:

imf:=emd(channel_data(whale),residue=false):;

Evaluation time: 10.01

(Note that the residue is discarded since it is not relevant for the spectrum.) To display the Hilbert spectrum of the whale song, enter:

sr:=samplerate(whale):; hht(imf,frequencies=10..500,samplerate=sr,color=colormap("viridis"))

Whale moans occur at about 5, 10, 15 and 20 seconds from the beginning of the recording (in reality, these intervals are ten times larger). Also, the spectrum reveals that moans have the same frequency, about 160 Hz in the recording and 16 Hz in reality. The magnitude of the first moan is smaller, as suggested by both the waveform and spectrum.

To obtain the Hilbert spectrum as a matrix, enter:

hs:=hht(imf,frequencies=10..500,samplerate=sr,output=matrix):;

To plot the energy of the whale song, sum the columns of the Hilbert spectrum matrix in which every element is squared. Energy data can be smoothed out by applying a moving-average filter.

y:=moving_average(sum(hs.^2),4000):; x:=linspace(0,duration(whale),length(y)):; labels=["time [sec]","energy"]; listplot(tran([x,y]))
Spectral analysis of music.

With the file CantinaBand3.wav downloaded from here:

music:=readwav("/home/luka/Downloads/CantinaBand3.wav")
     
a sound clip with 66150 samples at 22050 Hz (16 bit, mono)           

To obtain instrinsic mode functions, enter (residue is discarded):

imf:=emd(channel_data(music),residue=false):;

To display the Hilbert spectrum of music, enter:

hht(imf,samplerate=22050,log,color=colormap("spectral"),tran=false)

In the upper part of the spectrum you can see individual beats of the song, and in the lower part you can see six bass notes appearing every 2 beats. The first and fifth notes are stressed more than the others, suggesting the 4/4 time signature. The percussive pickup measure is also clearly visible. The first beat of the first measure starts after about 0.65 seconds. In the example in Section 21.4.5 it is explained how to extract the rhythmic section by cutting out the middle band of the spectrum.

As another example, download the files violin-C4.wav and flute-G6.wav from here and load them:

violin:=readwav("/home/luka/Downloads/violin-C4.wav"); flute:=readwav("/home/luka/Downloads/flute-G6.wav")
     
 a sound clip with 38500 samples at 11025 Hz (16 bit, mono),         
 a sound clip with 40250 samples at 11025 Hz (16 bit, mono)          

Mix the two audio clips with one-second delay for the flute (see Section 28.2.18):

snd:=mixdown(violin,[],flute,[1.0])
     
a sound clip with 51275 samples at 11025 Hz (16 bit, mono)           

You can hear the result by using the playsnd command (see Section 28.2.14). To display the Hilbert spectrum, enter (in this case, EMD is computed automatically by hht):

data,sr:=channel_data(snd),samplerate(snd):; hht(data,log,samplerate=sr,color=colormap("jet",inv,reverse));

The specified colormap helps you to see two individual tones at 60 resp. 91 semitones from the MIDI note 0, corresponding to C4 resp. G6, as expected. The flute part of the spectrum (yellow-reddish) is much more concentrated than the violin part due to the inherent sinusoidal quality of the flute sound.


Previous Up Next