spaudiopy.sig
Signal class. Avoid code duplications (and errors) by defining a few custom classes here.
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams['axes.grid'] = True
import spaudiopy as spa
Functions
|
Trim copy of MultiSignal audio to start and stop in seconds. |
Classes
|
Signal class for first order Ambisonics B-format signals. |
|
Signal class for head-related impulse responses. |
|
Signal class for a MONO channel audio signal. |
|
Signal class for a MULTI channel audio signal. |
- class spaudiopy.sig.MonoSignal(signal, fs)[source]
Bases:
object
Signal class for a MONO channel audio signal.
- class spaudiopy.sig.MultiSignal(signals, fs=None)[source]
Bases:
MonoSignal
Signal class for a MULTI channel audio signal.
- classmethod from_file(filename, fs=None)[source]
Alternative constructor, load signal from filename.
- apply(func, *args, **kwargs)[source]
Apply function ‘func’ to all signals, arguments are forwarded.
- copy()
Return an independent (deep) copy of the instance.
- save(filename, subtype='FLOAT')
Save to file.
- class spaudiopy.sig.AmbiBSignal(signals, fs=None)[source]
Bases:
MultiSignal
Signal class for first order Ambisonics B-format signals.
- classmethod from_file(filename, fs=None)[source]
Alternative constructor, load signal from filename.
- classmethod sh_to_b(multisig)[source]
Alternative constructor, convert from sig.Multisignal.
Assumes ACN channel order.
- apply(func, *args, **kwargs)
Apply function ‘func’ to all signals, arguments are forwarded.
- conv(irs, **kwargs)
Convolve signal, kwargs are forwarded to signal.convolve.
- copy()
Return an independent (deep) copy of the instance.
- get_signals()
Return ndarray of signals, stacked along rows (nCH, nSmps).
- play(gain=1, wait=True)
Play sound signal. Adjust gain and wait until finished.
- resample(fs_new)
Resample signal to new sampling rate fs_new.
- save(filename, subtype='FLOAT')
Save to file.
- trim(start, stop)
Trim all channels to start and stop in seconds.
- class spaudiopy.sig.HRIRs(left, right, azi, zen, fs)[source]
Bases:
object
Signal class for head-related impulse responses.
- __init__(left, right, azi, zen, fs)[source]
Constructor.
- Parameters:
left ((numDirs, numTaps) ndarray) – Left ear HRIRs.
right ((numDirs, numTaps) ndarray) – Right ear HRIRs.
azi ((numDirs,) array_like, in rad)
fs (int)
- update_hrirs(left, right)[source]
Update and replace HRIRs in place.
- Parameters:
left ((numDirs, numTaps) ndarray) – Left ear HRIRs.
right (numDirs, numTaps ndarray) – Right ear HRIRs.
- Returns:
None.
- nearest_hrirs(azi, zen)[source]
For a point on the sphere, select closest HRIR defined on grid.
Based on the haversine distance.
- Parameters:
azi (float) – Azimuth.
zen (float) – Zenith / Colatitude.
- Returns:
h_l ((n,) array_like) – h(t) closest to [phi, theta].
h_r ((n,) array_like) – h(t) closest to [phi, theta].