This function plots dynamically a sliding spectrum along a time wave. This basically corresponds to a short-term Fourier transform.
dynspec(wave, f, channel = 1, wl = 512, wn = "hanning", zp = 0,
ovlp = 0, fftw = FALSE, norm = FALSE, dB = NULL, dBref = NULL, plot = TRUE,
title = TRUE, osc = FALSE,
tlab = "Time (s)", flab = "Frequency (kHz)",
alab = "Amplitude", alim = NULL, flim = c(0, f/2000),
type = "l", from = NULL, to = NULL, envt = NULL,
msmooth = NULL, ksmooth = NULL, colspec = "black",
coltitle = "black", colbg = "white", colline = "black",
colaxis = "black", collab = "black", cexlab = 1,
fontlab = 1, colwave = "black",
coly0 = "lightgrey", colcursor = "red", bty = "l")
an R object.
sampling frequency of wave
(in Hz). Does not need to
be specified if embedded in wave
.
channel of the R object, by default left channel (1).
if at
is not null, length of the window for the analysis
(even number of points, by defaults = 512).
window name, see ftwindow
(by default "hanning"
).
zero-padding (even number of points), see Details
.
overlap between two successive windows (in % ).
if TRUE
calls the function FFT
of the
library fftw
. See Notes of the spectro
.
logical, if TRUE
compute a normalised sliding spectrum.
a character string specifying the type dB to return: "max0" for a maximum dB value at 0, "A", "B", "C", "D", and "ITU" for common dB weights.
a dB reference value when dB
is not NULL
. NULL
by default
but should be set to 2*10e-5 for a 20 microPa reference (SPL).
logical, if TRUE
plots in an ew graphics device the successive
spectra sliding along the time wave (by default TRUE
).
logical, if TRUE
adds a title with the time position of the current
spectrum along the time wave.
logical, if TRUE
plots an oscillogram beneath
the sliding spectrum with a cursor showing the position of the
current spectrum (by default FALSE
).
title of the time axis.
title of the frequency axis.
title of the amplitude axis.
range of frequency axis.
range of amplitude axis.
type of plot that should be drawn for the sliding spectrum.
See plot
for details (by default "l" for lines).
start mark where to compute the sliding spectrum (in s).
end mark where to compute the sliding spectrum (in s).
the type of envelope to be plooted:
either "abs" for absolute amplitude envelope or "hil" for Hilbert amplitude envelope.
See env
.
when env
is not NULL
,
a vector of length 2 to smooth the amplitude envelope with a
mean sliding window. The first component is the window length
(in number of points). The second component is the overlap between
successive windows (in %). See env
.
colour of the sliding spectrum.
if title
is TRUE
, colour of the title.
background colour.
colour of axes line.
colour of the axes.
colour of axes title.
character size for axes title.
font for axes title.
colour of the oscillogram or of the envelope (only when osc
is TRUE
).
colour of the y=0 line (only when osc
is TRUE
).
colour of oscillogram cursor (only when osc
is TRUE
).
the type of box to be drawn around the oscillogram (only
when osc
is TRUE
).
This function returns a list of three items:
a numeric vector corresponding to the time axis.
a numeric vector corresponding to the frequency axis.
a numeric matrix corresponding to the amplitude values.
Each column is a Fourier transform of length wl/2
.
Use the slider panel to move along the time wave.
Use the argument norm
if you wish to have each spectrum normalised, i.e.
with values between 0 and 1 or maximised to 0 dB when dB
is TRUE
.
The function requires the package rpanel that is based on the package tcltk.
spectro
, spectro3D
,
wf
, spec
, dynspectro
,
fft
, oscillo
, env
.
# NOT RUN {
data(sheep)
require(rpanel)
dynspec(sheep,f=8000,wl=1024,ovlp=50,osc=TRUE)
# }
Run the code above in your browser using DataLab