sine_wave_generator#
- sine_wave_generator(fs, d, freq, spl_level)[source]#
Sine wave signal generation
This function creates a sine wave signal given a sampling rate, duration, frequency and sound pressure level.
- Parameters:
fs (int) – Sampling frequency in [Hz].
d (int) – Signal duration in [s].
freq (int) – Sine wave frequency in [Hz].
spl_level (int) – Sound pressure level signal in [dB SPL].
- Returns:
signal (array_like) – Signal time values in [Pa].
time (array_like) – Time axis in [s].
Warning
spl_level must be provided in dB, ref=2e-5 Pa.
Notes
Signal to be used for ECMA-418-2 validation must have a sampling frequency of 48 kHz.
Examples
>>> from mosqito.utils import sine_wave_generator >>> import matplotlib.pyplot as plt >>> import numpy as np >>> fs = 48000 >>> duration = 1 >>> freq = 10 >>> dB = 60 >>> signal, time = sine_wave_generator(fs, duration, freq, dB) >>> plt.plot(time, signal) >>> plt.xlabel("Time axis [s]") >>> plt.ylabel("Amplitude signal [Pa]")
(
Source code,png,hires.png,pdf)