({{, (RefLink[CepstrumArray, paclet:ref/CepstrumArray])[data] 
computes the power cepstrum of data.}, {, (RefLink[CepstrumArray, paclet:ref/CepstrumArray])[data,type] 
computes the specified type of cepstrum of data.}})

OpenersNotesSection(Spacer1)Details and Options

Cepstral analysis has been used for characterization of echoes, separation of convolved signals and pitch detection application in signal processing.

Real cepstrum is computed as the inverse Fourier transform of the log-magnitude Fourier spectrum.

The data can be any of the following:

The type specification can be either of the following:

For multichannel images and audio signals, (RefLink[CepstrumArray, paclet:ref/CepstrumArray]) is returned separately on each channel.

(RefLink[CepstrumArray, paclet:ref/CepstrumArray]) accepts the (RefLink[FourierParameters, paclet:ref/FourierParameters]) option. The default setting is (RefLink[FourierParameters, paclet:ref/FourierParameters])->{1,-1}.

OpenersPrimaryExamplesSection(Spacer1)Examples  (11)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Cepstrum of a list:

CepstrumArray[{1,1,2,2,1,1,0,0}]

Cepstrum of an (RefLink[Audio, paclet:ref/Audio]) object:

a=Import["ExampleData/rule30.wav"];

CepstrumArray[a]

Plot of the power cepstrum:

ListLinePlot[Take[%,{20,500}]]

OpenersExampleSection1(Spacer1)Scope  (6)

Real cepstrum of a list:

CepstrumArray[{1,1,2,2,1,1,0,0},"Real"]

Cepstrum of a 2D list:

a=RandomComplex[1+I,{3,3}];
a//MatrixForm

CepstrumArray[a]//MatrixForm

Compute the cepstrum of a (RefLink[Sound, paclet:ref/Sound]):

a=ExampleData[{"Sound","Apollo11ReturnSafely"}]

CepstrumArray[a]

ListLinePlot[Take[%,{20,500}],PlotRange->All]

Cepstrum of a multichannel (RefLink[Audio, paclet:ref/Audio]) object:

a=ExampleData[{"Audio","Bee"}];

CepstrumArray[a,"Real"]

The cepstrum is computed separately on each channel:

ListLinePlot[Take[%,All,{20,500}],PlotRange->All]

Cepstrum of an (RefLink[Image, paclet:ref/Image]) object:

a=;

CepstrumArray[a]

Plot of the power cepstrum:

MatrixPlot[RotateLeft[Log@%,{200,200}],PlotTheme->"Minimal"]

Cepstrum of a multichannel image:

a=;

c=CepstrumArray[a];

The cepstrum is computed separately on each channel:

Dimensions@c

Table[MatrixPlot[RotateLeft[Log[cc],Round[Dimensions[cc]/2]],PlotTheme->"Minimal"],{cc,c}]

OpenersExampleSection3(Spacer1)Applications  (3)

Detect the effect of a comb filer on a signal:

data=Table[2 Sin[0.05π n ]+Sin[0.154 π n]+RandomReal[{-1,1}]/10.,{n,0,1023}];

The signal only has two sinusoidal components.

dtf=TransferFunctionModel[(1/(1-0.8 (z^(-31)))),z,SamplingPeriod->1]

A comb filter with delay of 31 samples is applied:

y=RecurrenceFilter[dtf,data];

It is not easy to identify the periodicity of the comb filter by using conventional spectral analysis:

Periodogram[{data,y}]

Since the cepstrum of a convolution is the sum of the cepstra of the two components, it is easier to identify the peak caused by the comb filter:

ListLinePlot[{CepstrumArray[data][[;;100]],CepstrumArray[y][[;;100]]},PlotRange->.2]

Measure the time constant of an echo:

a=AudioDelay[Import["ExampleData/rule30.wav"],(Quantity[0.6, "s", seconds, "Seconds"]),.6,PaddingSize->4]

Compute the logarithm of the cepstrum, and discard the second half (the real cepstrum is symmetric):

cepstrum=CepstrumArray[a];
cepstrum=Log[cepstrum[[;;Length[cepstrum]/2]]];

Find the peaks:

peaks=FindPeaks[cepstrum,1,2,-2]

Plot the result:

ListLinePlot[cepstrum,PlotRange->All,Epilog->{Red,Point[peaks]}]

Select the position of the biggest peak:

quefrency=MaximalBy[peaks,Last][[1,1]]-1

Compute the period by dividing the quefrency by the sample rate:

UnitConvert[N@quefrency/AudioSampleRate[a],"s"]

Detect the pitch of a recording:

a=ExampleData[{"Sound","Oboe"},"Audio"]

In harmonic sounds, the pitch does not correspond to the biggest peak in the spectrum:

Periodogram[a,4000]

Compute the cepstrum and discard the symmetric part:

cepstrum=CepstrumArray[a];
cepstrum=cepstrum[[;;Length[cepstrum]/2]];

Find the peaks and display the result:

peaks=FindPeaks[cepstrum,1,.1]

ListLinePlot[cepstrum[[;;1000]],PlotRange->{0,1},Epilog->{Red,Point[peaks]}]

The peak corresponding to zero quefrency is discarded, and the biggest peak is selected:

quefrency=MaximalBy[Select[peaks,#[[1]]>1&],Last][[1,1]]-1

Compute the fundamental frequency by dividing the sample rate by the quefrency:

ff=AudioSampleRate[a]/quefrency

Check the result:

AudioGenerator[{"Sin",ff}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Fourier, paclet:ref/Fourier])  ▪  (RefLink[PeriodogramArray, paclet:ref/PeriodogramArray])  ▪  (RefLink[Periodogram, paclet:ref/Periodogram])  ▪  (RefLink[CepstrogramArray, paclet:ref/CepstrogramArray])  ▪  (RefLink[Cepstrogram, paclet:ref/Cepstrogram])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Signal Processing, paclet:guide/SignalProcessing])}, {▪(RefLinkPlain[Fourier Analysis, paclet:guide/FourierAnalysis])}, {▪(RefLinkPlain[Audio Representation, paclet:guide/AudioRepresentation])}})}})