({{, (RefLink[Spectrogram, paclet:ref/Spectrogram])[list] 
plots the spectrogram of list.}, {, (RefLink[Spectrogram, paclet:ref/Spectrogram])[list,n]
uses partitions of length n.}, {, (RefLink[Spectrogram, paclet:ref/Spectrogram])[list,n,d]
uses partitions with offset d.}, {, (RefLink[Spectrogram, paclet:ref/Spectrogram])[list,n,d,wfun]
applies a smoothing window wfun to each partition.}, {, (RefLink[Spectrogram, paclet:ref/Spectrogram])[list,n,d,wfun,m]
pads partitions with zeros to length m prior to the computation of the transform.}, {, (RefLink[Spectrogram, paclet:ref/Spectrogram])[audio,…]
plots the spectrogram of audio.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[Spectrogram, paclet:ref/Spectrogram])[list] plots the magnitude of the short-time Fourier transform (STFT), computed as discrete Fourier transform (DFT) of partitions of list.

Compute the short-time Fourier transform of list using (RefLink[ShortTimeFourier, paclet:ref/ShortTimeFourier]).

(RefLink[Spectrogram, paclet:ref/Spectrogram])[list] uses partitions of length n=2^Round[(Subscript[log, 2])((Sqrt[m]))+1] and offset d=Round[n/3], where m is (RefLink[Length, paclet:ref/Length])[list].

The partition length n and offset d can be expressed as an integer number (interpreted as number of samples) or as time or sample quantities.

If necessary, fixed padding is used on the right to make all the partitions the same size.

(RefLink[Spectrogram, paclet:ref/Spectrogram]) displays only the first half of the magnitude of the discrete Fourier transform due to the symmetry property of the transform.

In (RefLink[Spectrogram, paclet:ref/Spectrogram])[list,n,d,wfun], the smoothing window wfun can be specified using a window function that will be sampled between -1/2 and 1/2 or a list of length n. The default window is (RefLink[DirichletWindow, paclet:ref/DirichletWindow]), which effectively does no smoothing.

(RefLink[Spectrogram, paclet:ref/Spectrogram]) works with numeric lists as well as (RefLink[Audio, paclet:ref/Audio]) and (RefLink[Sound, paclet:ref/Sound]) objects.

For multichannel sound objects, the spectrogram is computed over the sum of all channels.

(RefLink[Spectrogram, paclet:ref/Spectrogram]) accepts all (RefLink[ArrayPlot, paclet:ref/ArrayPlot]) options with the following additions and changes:

Possible settings for (RefLink[Method, paclet:ref/Method]) include:

Use (RefLink[Method, paclet:ref/Method])->{"MelFrequency",n,(Subscript[f, min]),(Subscript[f, max])} to specify the number of bins n as well as the minimum and maximum frequencies.

Specific settings for (RefLink[PlotRange, paclet:ref/PlotRange]) can be used to control the maximum frequency:

For the setting (RefLink[SampleRate, paclet:ref/SampleRate])->r and a list of length m, time is ranged from 0 to m/r, and the frequencies are in the range 0 to r/2.

OpenersPrimaryExamplesSection(Spacer1)Examples  (16)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Spectrogram of a chirp signal:

Spectrogram[Table[Cos[(( i)/4)+((((i/20)))^2)],{i,2000}]]

Spectrogram of an audio signal:

Spectrogram[]

OpenersExampleSection1(Spacer1)Scope  (1)

Use a specific window size and offset:

a=AudioGenerator[Sin[2π 1633 #]+Sin[2π 1209 #]&,SampleRate->8000]

By default, a suitable window size and offset is chosen:

Spectrogram[a]

Use smaller window size to reduce the frequency resolution:

Spectrogram[a,32,4]

Use larger window size to improve the frequency resolution:

Spectrogram[a,512,64]

Specify the smoothing window function:

Spectrogram[a,512,64,HammingWindow]

No smoothing:

Spectrogram[a,512,64,None]

OpenersExampleSection2(Spacer1)Options  (8)

OpenersExampleSubsection0(Spacer1)AspectRatio  (1)

By default, an aspect ratio of 1/3 is used:

data=Table[Cos[(( i)/4)+((((i/20)))^2)],{i,2000}];

Spectrogram[data]

Change the aspect ratio of the spectrogram:

Spectrogram[data,AspectRatio->1/5]

OpenersExampleSubsection1(Spacer1)ColorFunction  (1)

Use a built-in color gradient as the color function:

data=Table[Cos[(( i)/4)+((((i/20)))^2)],{i,2000}];

Spectrogram[data,ColorFunction->"Aquamarine"]

Use an arbitrary color function:

Spectrogram[data,ColorFunction->(Blend[{White,Orange,Red,Black},#]&)]

OpenersExampleSubsection2(Spacer1)PlotRange  (4)

(RefLink[PlotRange, paclet:ref/PlotRange])->(RefLink[Automatic, paclet:ref/Automatic]) automatically computes the frequency range to display:

Spectrogram[ExampleData[{"Audio","Apollo11SmallStep"}]]

This is equivalent to (RefLink[PlotRange, paclet:ref/PlotRange])->{(RefLink[All, paclet:ref/All]),(RefLink[Automatic, paclet:ref/Automatic]),(RefLink[All, paclet:ref/All])}:

Spectrogram[ExampleData[{"Audio","Apollo11SmallStep"}],PlotRange->{All,Automatic,All}]

Show the full spectrogram:

Spectrogram[ExampleData[{"Audio","Apollo11SmallStep"}],PlotRange->All]

Zoom into a specific part of the spectrogram:

Spectrogram[ExampleData[{"Audio","Apollo11SmallStep"}],PlotRange->{{1,3},Automatic}]

Use (RefLink[PlotRange, paclet:ref/PlotRange])->{min,max} to control the frequency range of the spectrogram:

Spectrogram[ExampleData[{"Audio","Apollo11SmallStep"}]]

Specify range of frequencies:

Spectrogram[ExampleData[{"Audio","Apollo11SmallStep"}],PlotRange->{1000,2000}]

Specify maximum frequency:

Spectrogram[ExampleData[{"Audio","Apollo11SmallStep"}],PlotRange->3000]

OpenersExampleSubsection3(Spacer1)Method  (1)

By default, frequency is shown using linear scaling:

a=ExampleData[{"Audio","MaleVoice"},"Audio"]

Spectrogram[a]

Use mel frequency scaling:

Spectrogram[a,Method->"MelFrequency"]

OpenersExampleSubsection4(Spacer1)SampleRate  (1)

Specify the sampling rate of the data:

chirp=Table[Cos[800. π t+2800. π t^2],{t,0.,1.6,1/8000.}];
Spectrogram[chirp,SampleRate->8000]

OpenersExampleSection3(Spacer1)Applications  (3)

Spectrogram of a sound signal:

Spectrogram[ExampleData[{"Sound","Apollo13Problem"}]]

Spectrogram of an impulsive sound:

Spectrogram[ExampleData[{"Audio","IRStMarysChurch"}]]

Spectrogram of an image:

i=;

Spectrogram[Flatten[ImageData[i]],Frame->False]

OpenersExampleSection4(Spacer1)Properties & Relations  (1)

Create a spectrogram from the (RefLink[SpectrogramArray, paclet:ref/SpectrogramArray]):

chirp=Table[Cos[800. π t+2800. π t^2],{t,0.,1.6,1/8000.}];
sa=SpectrogramArray[chirp];

ListDensityPlot[Transpose[Abs[sa]][[;;128]],Frame->None,AspectRatio->1/3]

Comparison with the default (RefLink[Spectrogram, paclet:ref/Spectrogram]) output:

Spectrogram[chirp,Frame->False]

OpenersExampleSection5(Spacer1)Neat Examples  (1)

Sound and spectrogram of dual-tone for Wolfram Research customer service number:

frequencies={0->{941,1336},1->{697,1209},2->{697,1336},3->{697,1477},4->{770,1209},5->{770,1336},6->{770,1477},7->{852,1209},8->{852,1336},9->{852,1477}};

number=18009653726;
a=Audio[Join@@(ArrayPad[Table[Sin[2 Pi #[[1]] t]+Sin[2 Pi #[[2]] t],{t,0,0.2,1/8000.}],100,0.]&/@(IntegerDigits[number]/.frequencies)),SampleRate->8000]

Spectrogram[a]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ShortTimeFourier, paclet:ref/ShortTimeFourier])  ▪  (RefLink[InverseSpectrogram, paclet:ref/InverseSpectrogram])  ▪  (RefLink[SpectrogramArray, paclet:ref/SpectrogramArray])  ▪  (RefLink[Fourier, paclet:ref/Fourier])  ▪  (RefLink[Periodogram, paclet:ref/Periodogram])  ▪  (RefLink[Cepstrogram, paclet:ref/Cepstrogram])  ▪  (RefLink[AudioSpectralTransformation, paclet:ref/AudioSpectralTransformation])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Fourier Analysis, paclet:guide/FourierAnalysis])}, {▪(RefLinkPlain[Signal Processing, paclet:guide/SignalProcessing])}, {▪(RefLinkPlain[Sound and Sonification, paclet:guide/SoundAndSonification])}, {▪(RefLinkPlain[Summation Transforms, paclet:guide/SummationTransforms])}, {▪(RefLinkPlain[Audio Representation, paclet:guide/AudioRepresentation])}, {▪(RefLinkPlain[Audio Processing, paclet:guide/AudioProcessing])}})}})