RealCepstrum - Maple Help

SignalProcessing

 RealCepstrum
 compute the real cepstrum of the signal

 Calling Sequence RealCepstrum(A)

Parameters

 A - Array of real numeric values; the signal

Description

 • The RealCepstrum(A) command computes the real logarithm of the magnitude of the Fourier transform of a sequence.
 • A must be a one-dimensional Array and must contain real numbers only.

Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$

We will artificially pollute a signal with an echo. The Cepstrum command will then be used to identify the location of the echo.

 > $\mathrm{Fs}≔100:$
 > $\mathrm{tStart}≔0:$
 > $\mathrm{tEnd}≔15:$
 > $\mathrm{tEcho}≔4.5:$
 > $N≔\left(\mathrm{tEnd}-\mathrm{tStart}\right)\mathrm{Fs}+1:$

Define a clean, unpolluted signal:

 > $t≔\mathrm{Vector}\left(\left[\mathrm{seq}\left(i,i=\mathrm{tStart}..\mathrm{tEnd},\frac{1.0}{\mathrm{Fs}}\right)\right]\right):$
 > $\mathrm{cleanSignal}≔\mathrm{~}\left[\mathrm{/}\right]\left(\mathrm{~}\left[\mathrm{sin}\right]\left(2\mathrm{\pi }\cdot 1.3t\right),\mathrm{ },\mathrm{~}\left[\mathrm{+}\right]\left(t,\mathrm{ },10\right)\right)+\mathrm{~}\left[\mathrm{/}\right]\left(\mathrm{~}\left[\mathrm{cos}\right]\left(2\mathrm{\pi }\cdot 2.4t\right),\mathrm{ },\mathrm{~}\left[\mathrm{+}\right]\left(t,\mathrm{ },10\right)\right):$
 > $\mathrm{cleanSignalPlot}≔\mathrm{plot}\left(t,\mathrm{cleanSignal},\mathrm{legend}="Clean Signal"\right)$

The echo is the original signal, delayed by tEcho.

 > $\mathrm{echoSignal}≔\mathrm{Vector}\left(\left[\mathrm{}\left(0,\mathrm{floor}\left(\mathrm{Fs}\mathrm{tEcho}+1\right)\right),\mathrm{cleanSignal}\left[1..N-\mathrm{floor}\left(\mathrm{Fs}\mathrm{tEcho}+1\right)\right]\right]\right):$

The dirty signal is the clean signal plus the echo multiplied by a small factor:

 > $\mathrm{dirtySignal}≔\mathrm{cleanSignal}+0.3\mathrm{echoSignal}:$
 > $\mathrm{dirtySignalPlot}≔\mathrm{plot}\left(t,\mathrm{dirtySignal},\mathrm{color}=\mathrm{blue},\mathrm{legend}="Signal with Echo"\right)$
 > $r≔\mathrm{RealCepstrum}\left(\mathrm{dirtySignal}\right):$
 > $\mathrm{plot}\left(t,r,\mathrm{view}=\left[\mathrm{tStart}..\mathrm{tEnd},-1.5..1\right]\right)$

The peak in the cepstrum plot shows the location of the echo. Find the sample at which the echo occurs.

 > $\mathrm{threshold}≔\mathrm{map}\left(x↦\mathrm{piecewise}\left(x<0.2,0,1\right),r\right):$
 > $\mathrm{ind}≔\mathrm{ArrayTools}:-\mathrm{SearchArray}\left(\mathrm{threshold},5\right):$

The echo starts at sample 452 and a time of t[452]

 > $t\left[452\right]$
 ${4.510000000}$ (1)

Now use this information to generate an IIR filter to remove the echo.

 > $\mathrm{filteredSignal}≔\mathrm{SignalProcessing}:-\mathrm{Filter}\left(\mathrm{dirtySignal},\mathrm{Array}\left(\left[1,\mathrm{}\left(0,450\right),0.35\right]\right),\mathrm{Array}\left(\left[1\right]\right)\right):$
 > $\mathrm{filteredSignalPlot}≔\mathrm{plot}\left(t,\mathrm{filteredSignal},\mathrm{color}=\mathrm{black},\mathrm{legend}="Filtered Signal"\right)$
 > $\mathrm{plots}:-\mathrm{display}\left(\mathrm{dirtySignalPlot},\mathrm{filteredSignalPlot}\right)$
 > $\mathrm{plots}:-\mathrm{display}\left(\mathrm{cleanSignalPlot},\mathrm{filteredSignalPlot}\right)$
 > 

Compatibility

 • The SignalProcessing[RealCepstrum] command was introduced in Maple 2019.