Signals in the frequency domain (audiotoolbox.FrequencyDomainSignal)
The FrequencyDomainSignal class also inherits from numpy.ndarray via the audiotoolbox.BaseSignal class:
digraph inheritance9d180532fc { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "audiotoolbox.oaudio.base_signal.BaseSignal" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="Basic Signal class inherited by all Signal representations"]; "numpy.ndarray" -> "audiotoolbox.oaudio.base_signal.BaseSignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; "audiotoolbox.oaudio.freqdomain_signal.FrequencyDomainSignal" [URL="#audiotoolbox.FrequencyDomainSignal",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for signals in the frequency domain."]; "audiotoolbox.oaudio.base_signal.BaseSignal" -> "audiotoolbox.oaudio.freqdomain_signal.FrequencyDomainSignal" [arrowsize=0.5,style="setlinewidth(0.5)"]; "numpy.ndarray" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",tooltip="ndarray(shape, dtype=float, buffer=None, offset=0,"]; }- class audiotoolbox.FrequencyDomainSignal(n_channels: int | tuple | list, duration: float, fs: int, dtype=<class 'complex'>)
Base class for signals in the frequency domain.
- Parameters:
n_channels (int or tuple) – Number of channels to be used, can be N-dimensional
duration (float) – Stimulus duration in seconds
fs (int) – Sampling rate in Hz
dtype (complex, optional) – Datatype of the array (default is float)
- Returns:
Signal
- Return type:
The new object.
- abs()
Absolute value
Calculates the absolute value or modulus of all values of the signal
- add(x)
In-place summation
This function allowes for in-place summation.
- Parameters:
x (scalar or ndarray) – The value or array to add to the signal
- Return type:
Returns itself
Examples
>>> sig = audiotoolbox.Signal(1, 1, 48000).add_tone(500).add(2) >>> print(sig.mean()) 2.0
- property ch
Direct channel indexer
Returns an indexer class which enables direct indexing and slicing of the channels indipendent of samples.
Examples
>>> sig = audiotoolbox.Signal((2, 3), 1, 48000).add_noise() >>> print(np.all(sig.ch[1, 2] is sig[:, 1, 2])) True
- concatenate(signal)
Concatenate another signal or array
This method appends another signal to the end of the current signal.
- Parameters:
signal (signal or ndarray) – The signal to append
- Return type:
Returns itself
- property duration
Duration of the signal in seconds
- property freq
Return the frequency axis
- Returns:
The frequency axis in Hz
- Return type:
numpy.ndarray
- property fs
Sampling rate of the signal in Hz
- property mag
Returns the magnitudes of the frequency components
equivalent to
audiotoolbox.FrequencyDomainSignal.abs()
- Returns:
The magnitudes
- Return type:
numpy.ndarray
- multiply(x)
In-place multiplication
This function allowes for in-place multiplication
- Parameters:
x (scalar or ndarray) – The value or array to muliply with the signal
- Return type:
Returns itself
Examples
>>> sig = audiotoolbox.Signal(1, 1, 48000).add_tone(500).multiply(2) >>> print(sig.max()) 2.0
- property n_channels
Number of channels in the signal
- property n_samples
Number of samples in the signal
- property phase
The Argument of the frequency components
- Returns:
The arguments in radiants
- Return type:
numpy.ndarray
- phase_shift(phase)
Apply a phase shift
Phase shift the spectrum by multiplying all frequency components with:
\[H(\omega) = e^{-j\psi}\]where \(j\) is the complex unit and \(\psi\) is the desired phaseshift.
- Parameters:
phase (scalar) – The phaseshift
- Returns:
Returns itself (FrequencyDomainSignal)
Also See
——–
audiotoolbox.Signal.phase_shift
- time_shift(time)
Apply a time shift
Time shift the signal by a linear phase shift by multiplying all frequency components with:
\[H(\omega) = e^{-j\omega\Delta t}\]where \(j\) is the complex unit, \(omega\) the circular frequency and \(\Delta t\) the timeshift.
- Parameters:
time (scalar) – The time by which the signal should be shifted
- Returns:
Returns itself (FrequencyDomainSignal)
Also See
——–
audiotoolbox.Signal.delay