aspen.sounds.fm_tone

Frequency-modulated (FM) tone

Functions

fm_tone([duration, freq, method, …])

Generate frequency modulated tone.

Classes

FmTone([fm_tone_duration, fm_tone_freq, …])

Generate frequency modulated tone.

class aspen.sounds.fm_tone.FmTone(fm_tone_duration=[1000], fm_tone_freq=[440], fm_tone_method=['sin'], fm_tone_modulation_freq=[2], fm_tone_freq_excursion=[25], fm_tone_num_signals=1, samp_freq=16000)[source]

Bases: aspen.interfaces.abs_common_interface.AbsCommonInterface, aspen.interfaces.abs_sound_interface.AbsSoundInterface

Generate frequency modulated tone.

Parameters
  • fm_tone_duration (Sequence[float]) – The duration of am tone in millisecond. Defaults to [1000].

  • fm_tone_freq (Sequence[float]) – The frequency of the carrier in Hz. Defaults to [440].

  • fm_tone_method (Sequence[str]) – The type of frequency sweep. The choices are sin, upward, downward, updown or downup. Defaults to [“sin”].

  • fm_tone_modulation_freq (Sequence[float]) – The frequency of the modulation. Defaults to [2].

  • fm_tone_freq_excursion (Sequence[float]) – The frequency excusion of modulator in Hz. Defaults to [25].

  • fm_tone_num_signals (int) – The number of signals. If this value greater than 2, the other arguments should contain 2 types. Defaults to 1.

  • samp_freq (int) – Sampling frequency. Defaults to 16000.

Todo

Other chirp method (e.g. logarithmic).

Ref: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.chirp.html

A rectangular approximation of the integral of the instantaneous frequency formula.

Ref: https://www.mathworks.com/help/signal/ref/modulate.html

Randomly changed phase for fm-sin (refer the frequency modulation detection limens).
Ref: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3946142/

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5112215/

__call__()

Generate a specified number of signals.

Return type

List[ndarray]

Returns

Generate signals.

Output well be sequence-like object such as list, tuple and so on.

_generate_each(idx)[source]

Generate each signal.

Parameters

idx (int) – Index of signal generation.

Return type

ndarray

Returns

Generate signal.

static add_arguments(parser)[source]

add arguments

classmethod load_class_kwargs(args)

Return the kwargs dict for class __init__ from parsed arguments

Parameters

args (Namespace) – (config)argparse arguments

Return type

dict

Returns

kwargs for class __init__

aspen.sounds.fm_tone.fm_tone(duration=[1000], freq=[440], method=['sin'], modulation_freq=[2], freq_excursion=[25], num_signals=1, samp_freq=16000)[source]

Generate frequency modulated tone.

Parameters
  • duration (Sequence[float]) – The duration of am tone in millisecond. Defaults to [1000].

  • freq (Sequence[float]) – The frequency of the carrier in Hz. Defaults to [440].

  • method (Sequence[str]) – The type of frequency sweep. The choices are sin, linear, updown or downup. Defaults to [“sin”].

  • modulation_freq (Sequence[float]) – The frequency of the modulation. Defaults to [2].

  • freq_excursion (Sequence[float]) – The frequency excusion of modulator in Hz. Defaults to [25].

  • num_signals (int) – The number of signals. If this value greater than 2, the other arguments should contain 2 types. Defaults to 1.

  • samp_freq (int) – Sampling frequency. Defaults to 16000.

Return type

List[ndarray]

Returns

Output signals.