SignalBase.jl
Signal Inspection API
SignalBase.sampletype — Functionsampletype(x)Returns the element type of an individual channel of a signal (e.g. Float64).
The result of sampletype and eltype (when defined) are often the same. They are distinct so that these two can diverge when appropriate.
SignalBase.nchannels — Functionnchannels(x)Returns the number of channels in the signal.
SignalBase.framerate — Functionframerate(x)Returns the frame rate of the signal (in Hertz). May return missing if the frame rate is unknown.
SignalBase.nframes — Functionnframes(x)Returns the number of frames in the signal, if known. May return missing (e.g. for a file stream).
SignalBase.duration — Functionduration(x)Return the duration of the signal in seconds, if known. May return missing (e.g. for a stream).
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.
Unit Utility Functions
SignalBase.inframes — Functioninframes([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)
10SignalBase.inradians — Functioninradians([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.5707963267948966SignalBase.inseconds — Functioninseconds(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.01SignalBase.inHz — FunctioninHz(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