Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some documentation of the demodulation functions. #370

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions clarity/evaluator/haspi/eb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# pylint: disable=import-error
import logging
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Tuple

import numpy as np
from numba import njit # type: ignore # <-- silence mypy no attribute error
Expand Down Expand Up @@ -790,20 +790,27 @@ def gammatone_basilar_membrane(

@njit
def gammatone_bandwidth_demodulation(
npts, tpt, center_freq, center_freq_cos, center_freq_sin
):
"""Gamma tone bandwidth demodulation
npts: int,
tpt: float,
center_freq: float,
center_freq_cos: np.ndarray,
center_freq_sin: np.ndarray,
) -> tuple(np.ndarray, np.ndarray):
"""Create the carriers for demodulaton, using the 2d Rotation method from
https://ccrma.stanford.edu/~jos/pasp/Digital_Sinusoid_Generators.html
to generate the sin and cos components. More efficient, perhaps, than
calculating the sin and cos at each point in time.

Arguments:
npts (): ???
tpt (): ???
center_freq (): ???
center_freq_cos (): ???
sincf (): ???
npts (): How many points are needed.
tpt (): Phase change (2pi/T) due to each sample time.
center_freq (): The carrier frequency
center_freq_cos (): Array to overwrite for the output.
center_freq_sin (): Array to overwrite for the output.

Returns:
sincf (): ???
coscf (): ???
sincf (): Samples of the carrier frequency in sin phase.
coscf (): Samples of the carrier frequency in cos phase.
"""
cos_n = np.cos(tpt * center_freq)
sin_n = np.sin(tpt * center_freq)
Expand All @@ -828,7 +835,9 @@ def bandwidth_adjust(
level1: float,
) -> float:
"""
Compute the increase in auditory filter bandwidth in response to high signal levels.
Compute the increase in auditory filter bandwidth in response to high signal
levels. The RMS of the control signal, a scalar, is used to set the
bandwidth for the entire signal.

Arguments:
control (): envelope output in the control filter band
Expand Down
Loading