clarity.utils.signal_processing module¶
Signal processing utilities.
- clarity.utils.signal_processing.clip_signal(signal: ndarray, soft_clip: bool = False) tuple[ndarray, int] [source]¶
Clip the signal.
- Parameters:
signal (np.ndarray) – Signal to be clipped and saved.
soft_clip (bool) – Whether to use soft clipping.
- Returns:
Clipped signal. n_clipped (int): Number of samples clipped.
- Return type:
signal (np.ndarray)
- clarity.utils.signal_processing.compute_rms(signal: ndarray) float [source]¶
Compute RMS of signal
- Parameters:
signal – Signal to compute RMS of.
- Returns:
RMS of the signal.
- Return type:
float
- clarity.utils.signal_processing.denormalize_signals(sources: ndarray, ref: ndarray) ndarray [source]¶
Scale signals back to the original scale.
- Parameters:
sources (ndarray) – Source to be scaled.
ref (ndarray) – Original sources to be used for reverting scaling.
- Returns:
Signal rescaled back to its original.
- Return type:
ndarray
- clarity.utils.signal_processing.normalize_signal(signal: ndarray) tuple[ndarray, ndarray] [source]¶
Standardize the signal to have zero mean and unit variance.
- Parameters:
signal – The signal to be standardized.
- Returns:
The standardized signal and the reference signal.
- clarity.utils.signal_processing.resample(signal: ndarray, sample_rate: float, new_sample_rate: float, method: str = 'soxr') ndarray [source]¶
Resample a signal to a new sample rate.
This is a simple wrapper around soxr and scipy.signal.resample with the resampling expressed in terms of input and output sampling rates.
It also ensures that for multichannel signals, resampling is in the time domain, i.e. down the columns.
- Parameters:
signal – The signal to be resampled.
sample_rate – The original sample rate.
new_sample_rate – The new sample rate.
method – determine the approach use.
- Returns:
The resampled signal.