SignalBase.jl

Signal Inspection API

SignalBase.sampletypeFunction
sampletype(x)

Returns the element type of an individual channel of a signal (e.g. Float64).

Note

The result of sampletype and eltype (when defined) are often the same. They are distinct so that these two can diverge when appropriate.

source
SignalBase.framerateFunction
framerate(x)

Returns the frame rate of the signal (in Hertz). May return missing if the frame rate is unknown.

source
SignalBase.nframesFunction
nframes(x)

Returns the number of frames in the signal, if known. May return missing (e.g. for a file stream).

source
SignalBase.durationFunction
duration(x)

Return the duration of the signal in seconds, if known. May return missing (e.g. for a stream).

Note

A fallback implementation of duration uses nframes(x) / framerate(x). However, if one or both of these is missing and you want duartion to return a non-missing value, you can define a custom method of duration.

source

Unit Utility Functions

SignalBase.inframesFunction
inframes([Type,]quantity[, rate])

Translate the given quantity to a (unitless) number of time frames, given a particular framerate. Note that this isn't quantized to integer numbers of frames. If given a Type, the result will first be coerced to the given type.

If the given quantity is Unitful, we use the given units. If it is not we assume it is already a value in frames.

For some units (e.g. frames) you will need to specify a frame rate. If not specified the rate is missing.

Example

julia> inframes(0.5s, 44100Hz)
22050.0

julia> inframes(Int,10.5frames)
10
source
SignalBase.inradiansFunction
inradians([Type],x)

Given an angle value, convert to a value of Type (defaults to Float64) in radians. Unitless numbers are assumed to be in radians and are silently passed through.

Examples

julia> inradians(180°)
3.141592653589793

julia> inradians(2π)
6.283185307179586

julia> inradians(0.5π*rad)
1.5707963267948966
source
SignalBase.insecondsFunction
inseconds(quantity[, rate])

Translate a particular quantity (usually a time) to a (unitless) value in seconds.

If the given quantity is Unitful, we use the given units. If it is not we assume it is already a value in seconds.

For some units (e.g. frames) you will need to specify a frame rate. If not specified the rate is missing.

Examples

julia> inseconds(50.0ms)
0.05

julia> inseconds(441frames, 44100Hz)
0.01
source
SignalBase.inHzFunction
inHz(quantity)

Translate a particular quantity (usually a frequency) to a (unitless) value in Hz.

If the given quantity is Unitful, we use the given units. If it is not we assume it is already a value in Hz.

Examples

julia> inHz(1.0kHz)
1000.0
source