Skip to content

openstb.simulator.system.signal

Classes:

Name Description
HFMChirp

Hyperbolic frequency modulated chirp.

LFMChirp

Linear frequency modulated chirp.

HFMChirp

HFMChirp(f_start, f_stop, duration, rms_spl, rms_after_window=True, window=None)

Bases: Signal

Hyperbolic frequency modulated chirp.

For a start frequency \(f_a\), stop frequency \(f_b\) and chirp length \(\tau\), we can define a unitless parameter

\[ b = \frac{1/f_b - 1/f_a}{\tau}. \]

In the passband, the HFM chirp is then given by

\[ s(t) = \exp \left(j2\pi \frac{\ln(1 + b f_a t)}{b} \right) \qquad 0 \leq t \leq \tau, \]

which has a hyperbolic instantaneous frequency \(f(t) = f_a / (1 + b f_a t)\). The inverse of this is the instantaneous period

\[ \frac{1}{f(t)} = \frac{1}{f_a} + bt \]

which is linear, giving rise to the alternative name of linear period modulated (LPM) chirp.

Parameters:

Name Type Description Default
f_start float

The start frequency of the chirp.

required
f_stop float

The stop frequency of the chirp.

required
duration float

The duration of the chirp in seconds.

required
rms_spl float

The RMS sound pressure level (decibels relative to 1 micropascal) of the signal.

required
rms_after_window bool

If True, scale the signal to the desired RMS SPL after applying the window. If False, scale before applying the window, meaning the windowed signal will have a lower RMS SPL. If no window is applied, this will be set to False.

True
window PluginOrSpec[SignalWindow] | None

Plugin specification for a signal window to apply to the samples of the signal.

None
Source code in openstb/simulator/system/signal.py
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
def __init__(
    self,
    f_start: float,
    f_stop: float,
    duration: float,
    rms_spl: float,
    rms_after_window: bool = True,
    window: PluginOrSpec[abc.SignalWindow] | None = None,
):
    """
    Parameters
    ----------
    f_start
        The start frequency of the chirp.
    f_stop
        The stop frequency of the chirp.
    duration
        The duration of the chirp in seconds.
    rms_spl
        The RMS sound pressure level (decibels relative to 1 micropascal) of the
        signal.
    rms_after_window
        If True, scale the signal to the desired RMS SPL after applying the window.
        If False, scale before applying the window, meaning the windowed signal will
        have a lower RMS SPL. If no window is applied, this will be set to False.
    window
        Plugin specification for a signal window to apply to the samples of the
        signal.

    """
    self.f_start = f_start
    self.f_stop = f_stop
    self._minimum_frequency = min(f_start, f_stop)
    self._maximum_frequency = max(f_start, f_stop)
    self._duration = duration
    self.rms_spl = rms_spl
    self.rms_after_window = rms_after_window and (window is not None)
    self.window = None if window is None else signal_window(window)

LFMChirp

LFMChirp(f_start, f_stop, duration, rms_spl, rms_after_window=True, window=None)

Bases: Signal

Linear frequency modulated chirp.

For a start frequency \(f_a\), stop frequency \(f_b\) and chirp length \(\tau\), we can calculate the chirp rate \(K = (f_b - f_a) / \tau\). In the passband, the LFM chirp is then

\[ s(t) = \exp (j\pi t (2f_a + Kt)) \qquad 0 \leq t \leq \tau, \]

which has a linear instantaneous frequency \(f(t) = f_a + Kt\).

Parameters:

Name Type Description Default
f_start float

The start frequency of the chirp.

required
f_stop float

The stop frequency of the chirp.

required
duration float

The duration of the chirp in seconds.

required
rms_spl float

The RMS sound pressure level (decibels relative to 1 micropascal) of the signal.

required
rms_after_window bool

If True, scale the signal to the desired RMS SPL after applying the window. If False, scale before applying the window, meaning the windowed signal will have a lower RMS SPL. If no window is applied, this parameter is ignored.

True
window PluginOrSpec[SignalWindow] | None

Plugin specification for a signal window to apply to the samples of the signal.

None
Source code in openstb/simulator/system/signal.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
def __init__(
    self,
    f_start: float,
    f_stop: float,
    duration: float,
    rms_spl: float,
    rms_after_window: bool = True,
    window: PluginOrSpec[abc.SignalWindow] | None = None,
):
    """
    Parameters
    ----------
    f_start
        The start frequency of the chirp.
    f_stop
        The stop frequency of the chirp.
    duration
        The duration of the chirp in seconds.
    rms_spl
        The RMS sound pressure level (decibels relative to 1 micropascal) of the
        signal.
    rms_after_window
        If True, scale the signal to the desired RMS SPL after applying the window.
        If False, scale before applying the window, meaning the windowed signal will
        have a lower RMS SPL. If no window is applied, this parameter is ignored.
    window
        Plugin specification for a signal window to apply to the samples of the
        signal.

    """
    self.f_start = f_start
    self.f_stop = f_stop
    self._minimum_frequency = min(f_start, f_stop)
    self._maximum_frequency = max(f_start, f_stop)
    self._duration = duration
    self.rms_spl = rms_spl
    self.rms_after_window = rms_after_window and (window is not None)
    self.window = None if window is None else signal_window(window)