Usage
spectrogram (sound, fs = 22050, windowlength = 5, freqres, timestep = -400,
preemphasisf = 50, maxfreq = 5000, colors = TRUE, dynamicrange = 50,
nlevels = dynamicrange, maintitle = "", show = TRUE, output = FALSE,
window = 'kaiser', windowparameter = 3, pause = FALSE)Arguments
sound
Either a numeric vector representing a sequence of samples taken from a sound wave or a sound object created with the loadsound() or makesound() functions.
fs
The sampling frequency in Hz. If a sound object is passed this does not need to be specificed.
windowlength
The desired analysis windowlength in milliseconds.
freqres
The desired frequency resolution. By default this is set to 1/4 the analysis bandwidth as determined by the actual (not effective) analysis window length.
timestep
If a negative value is given, this many equally-spaced time steps are calculated. If a positive number is given, this determines how far the window will be moved for each adjacent analysis, in milliseconds.
preemphasisf
Preemphasis of 6 dB per octave is added to frequencies above the specified frequency. For no preemphasis, set to a frequency higher than the sampling frequency.
maxfreq
the maximum frequency to be displayed for the spectrogram up to a maximum of fs/2. This is set to 5000 Hz by default.
colors
If TRUE, a color spectrogram will be displayed. If FALSE, greyscale is used. If a vector of colors is provided, these colors are used to create the spectrogram.
dynamicrange
Values greater than this many dB below the maximum will be displayed in the same color.
nlevels
The number of divisions to be used for the z-axis of the spectrogram. By default it is set equal to the dynamic range, meaning that a single color represents 1 dB on the z-axis.
maintitle
A string indicating the spectrogram title if one is desired.
show
If FALSE, no spectrogram is plotted. This is useful if the user would like to perform an action on an existing spectrogram plot without having to redraw it.
output
If this is TRUE, a spectrogram object is returned containing information regarding the created spectrogram. This can then be used to re-plot the spectrogram with plot().
window
the window to be applied to the signal, applied by the windowfunc function in this package.
windowparameter
the parameter for the window to be applied to the signal, if appropriate.
pause
If TRUE, the console waits until enter is hit before plotting the spectrogram so that the dimensions can be determined. Resizing spectograms that have already been plotted can be slow, especially with R-Studio.