Utils

Utilities for visualisation and filtering.


next_root

 next_root (x)

safe_log

 safe_log (x, eps=1e-10)

to_db

 to_db (x)

impulse_response

 impulse_response (b:jax.Array, a:jax.Array, n=4410)

Compute the impulse response of a discrete time system

Type Default Details
b Array numerators of the discrete transfer function
a Array denominators of the discrete transfer function
n int 4410
Returns jnp.ndarray The impulse response of the system, with shape (n_modes, n)
/home/diaz/projects/jaxdiffmodal_clean/.venv/lib/python3.11/site-packages/fastcore/docscrape.py:230: UserWarning: Unknown section Parameters:
  else: warn(msg)
/home/diaz/projects/jaxdiffmodal_clean/.venv/lib/python3.11/site-packages/fastcore/docscrape.py:230: UserWarning: Unknown section Returns:
  else: warn(msg)

iir_filter_parallel

 iir_filter_parallel (b, a, x)

Efficient parallel IIR filter implementation using JAX.

Details
b shape (n_modes, 3)
a shape (n_modes, 3)
x shape (n_samples,)

plot_poles_zeros

 plot_poles_zeros (p:numpy.ndarray, ax=None, xlim=(-1.1, 1.1), ylim=(-1.1,
                   1.1), show_unit_circle=True, save_path=None, **kwargs)

*Plot poles and zeros on a 2D complex plane with customizable axis limits.

Args: p (np.ndarray): Array of complex poles/zeros, will be flattened. ax (matplotlib.axes._subplots.AxesSubplot, optional): Pre-existing axis to plot on. xlim (tuple, optional): Limits for the x-axis (real part). ylim (tuple, optional): Limits for the y-axis (imaginary part). show_unit_circle (bool, optional): Whether to show the unit circle. save_path (str, optional): File path to save the plot. **kwargs: Additional keyword arguments passed to scatter plot.*

Type Default Details
p ndarray Array of zeros or poles (any shape)
ax NoneType None
xlim tuple (-1.1, 1.1) Default x-axis limits
ylim tuple (-1.1, 1.1) Default y-axis limits
show_unit_circle bool True Option to show the unit circle
save_path NoneType None Optional file path to save the plot
kwargs VAR_KEYWORD

hz2bark

 hz2bark (f)

bark2hz

 bark2hz (b)

hz2mel

 hz2mel (h)

mel2hz

 mel2hz (m)

tf_freqs

 tf_freqs (b:jax.Array, a:jax.Array, s:jax.Array)

Sample the frequency response of a transfer functions.

Type Details
b Array numerator (n_modes, 3)
a Array denominator (n_modes, 3)
s Array frequency (n_freqs,)
Returns Array The frequency response of the transfer function.

tf_freqz

 tf_freqz (b:jax.Array, a:jax.Array, worN:jax.Array, sample_rate:int)

Sample the frequency response of the transfer functions.

Type Details
b Array numerator (n_modes, 3)
a Array denominator (n_modes, 3)
worN Array frequencies (n_freqs,)
sample_rate int The sample rate in Hz of the transfer function
Returns jnp.ndarray The frequency response of the transfer function

compute_spectrogram

 compute_spectrogram (signal:numpy.ndarray, sample_rate:int, n_fft:int,
                      hop_length:int, max_freq:float=None,
                      time_limit_s:float=0.5)

display_audio_with_title

 display_audio_with_title (audio_data, sample_rate, title)

Display audio with a title next to it in a Jupyter notebook.