# ifreq: Instantaneous frequency In seewave: Sound Analysis and Synthesis

## Description

This function returns the instantaneous frequency (and/or phase) of a time wave through the computation of the analytic signal (Hilbert transform).

## Usage

 ```1 2 3``` ```ifreq(wave, f, phase = FALSE, threshold = NULL, plot = TRUE, xlab = "Time (s)", ylab = NULL, ylim = NULL, type = "l", ...) ```

## Arguments

 `wave` an R object. `f` sampling frequency of `wave` (in Hz). Does not need to be specified if embedded in `wave`. `phase` if `TRUE` and `plot` is also `TRUE` plots the instantaneous phase instead of the instantaneous frequency. `threshold` amplitude threshold for signal detection (in % ). `plot` logical, if `TRUE` plots the instantaneous frequency or phase against time (by default `TRUE`). `xlab` title of the x axis. `ylab` title of the y axis. `ylim` the range of y values. `type` if `plot` is `TRUE`, type of plot that should be drawn. See `plot` for details (by default "l" for lines). `...` other `plot` graphical parameters.

## Details

The instantaneous phase is the argument of the analytic signal obtained throught the Hilbert transform.
The instantaneous phase is then unwrapped and derived against time to get the instantaneous frequency.
There may be some edge effects at both start and end of the time wave.

## Value

If `plot` is `FALSE`, `ifreq` returns a list of two components:

 `f` a two-column matrix, the first column corresponding to time in seconds (x-axis) and the second column corresponding to instantaneous frequency in kHz (y-axis). `p` a two-column matrix, the first column corresponding to time in seconds (x-axis) and the second column corresponding to wrapped instantaneous phase in radians (y-axis).

## Note

This function is based on the analytic signal obtained with the Hilbert transform (see `hilbert`).
The function requires the package signal.
The matrix describing the instantaneous phase has one more row than the one describing the instantaneous frequency.

## Author(s)

Jerome Sueur [email protected]

## References

Mbu Nyamsi, R. G., Aubin, T. & Bremond, J. C. 1994 On the extraction of some time dependent parameters of an acoustic signal by means of the analytic signal concept. Its application to animal sound study. Bioacoustics, 5: 187-203.

`hilbert`, `zc`
 ```1 2 3 4 5 6 7``` ```# generate a sound with sine and linear frequency modulations a<-synth(d=1, f=8000, cf=1500, fm=c(200,10,1000)) # plot on a single graphical device the instantaneous frequency and phase op<-par(mfrow=c(2,1)) ifreq(a,f=8000,main="Instantaneous frequency") ifreq(a,f=8000,phase=TRUE,main="Instantaneous phase") par(op) ```