Plotting Spectra

The function for plotting spectra is fplot. This function takes a single obligatory argument, the spectral values that are output from muspec with dbspec=T (the default). In this example, [T] and [S] segments are extracted from the demo database, the spectra (centered at the midpoint) are calculated using the muspec function, and then all the spectra are plotted; the default Hz range is always 0 Hz to half the sampling frequency:


segs <- emu.track("demo", "*", "Phonetic=T|S")
mvals <- muspec(segs, centering=T, offset=0.5) *** NEED TO UPDATE ***
fplot(mvals$spec)

In order to code the spectra (in colour, or by linetype) according to the type of segment, extract the labels using the label function, and pass this as the second argument to fplot:


labs <- label(segs)
table(labs)
  S T 
 15 6
fplot(mvals$spec, labs)

One of the label-types can be selected for plotting using the which argument:


fplot(mvals$spec, labs, which="S")

The average argument computes average spectra for each different type of label (therefore, in the present example, there will be two average spectra, one for [S], one for [T]).


fplot(mvals$spec, labs, average=T)

The arguments low and high can be used to specify a frequency range. For example, to plot the averaged spectra in the 1-4 kHz range:


fplot(mvals$spec, labs, average=T, low=1000, high=4000)

The smoothing argument computes cepstrally smoothed spectra (defaults to 20 cepstral coefficients), and then causes the corresponding smoothed spectra (i.e. cepstrally smoothed spectra) to be plotted:


fplot(mvals$spec, labs, smoothing=T)

The following instruction is the same as the one before, but in this case the cepstrally smoothed spectra are averaged for each different segment type:


fplot(mvals$spec, labs, smoothing=T, average=T)

It is possible to superimpose cepstrally smoothed spectra on the dB-spectra using the super argument. The following instruction superimposes a cepstrally smoothed spectrum on the spectrum corresponding to the first segment in segs:


fplot(mvals$spec[1,], smoothing=T, super=T)

As a final example, averaged spectra are computed for the two segment types, and these averaged spectra are cepstrally smoothed (cepstrally smoothed averaged spectra). The dB-averaged spectra, and the cepstrally-smoothed averaged spectra, are superimposed on the same plot, and colour-coded according to the type of segment:


fplot(mvals$spec, labs, average=T, smoothing=T, super=T)

Figure 12.1. An example of fplot showing averaged spectra superimposed on cepstrally smoothed spectra for [S] and [T] segments.

An example of fplot showing averaged spectra superimposed on cepstrally smoothed spectra for [S] and [T] segments.