Zephyr Scientific Library (zscilib)
Files | Functions
Sounds

Sound functions. More...

Files

file  sound.h
 API header file for sound in zscilib.
 

Functions

int zsl_phy_sound_press_amp (zsl_real_t b, zsl_real_t k, zsl_real_t a, zsl_real_t *p)
 Calculates the mamimum acoustic pressure of a sound wave in pascals. More...
 
int zsl_phy_sound_level (zsl_real_t i, zsl_real_t i0, zsl_real_t *b)
 Calculates the sound intensity level in decibels based on the input intensity and a reference intensity. More...
 
int zsl_phy_sound_intensity (zsl_real_t b, zsl_real_t d, zsl_real_t p, zsl_real_t *i)
 Calculates the sound intensity in watts per meter squared based on the Bulk Modulus (b) and density (d) of the medium and the maximum pressure (p). More...
 
int zsl_phy_sound_shock_wave_angle (zsl_real_t v, zsl_real_t vs, zsl_real_t *theta)
 Calculates the angle of the mach wave created by a moving sound source of velocity 'vs'. More...
 
int zsl_phy_sound_dop_effect (zsl_real_t v, zsl_real_t vs, zsl_real_t vl, zsl_real_t fs, zsl_real_t *fl)
 Calculates the frequency measured by a moving receptor while a sound emiting source moves towards it. More...
 
int zsl_phy_sound_beat (zsl_real_t fa, zsl_real_t fb, zsl_real_t *f)
 Calculates the frequency of the beats created by the interference of two waves with different frequency. More...
 

Detailed Description

Sound functions.

Function Documentation

◆ zsl_phy_sound_beat()

int zsl_phy_sound_beat ( zsl_real_t  fa,
zsl_real_t  fb,
zsl_real_t f 
)

Calculates the frequency of the beats created by the interference of two waves with different frequency.

Parameters
faFrequency of the first wave in hertzs.
fbFrequency of the second wave in hertzs.
fPointer to the frequency of the beats in hertzs. Will be set to NAN if any of the input frequencies is negative.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_sound_dop_effect()

int zsl_phy_sound_dop_effect ( zsl_real_t  v,
zsl_real_t  vs,
zsl_real_t  vl,
zsl_real_t  fs,
zsl_real_t fl 
)

Calculates the frequency measured by a moving receptor while a sound emiting source moves towards it.

Parameters
vVelocity of sound in the medium in meters per second.
vsVelocity of the sound source in meters per second.
vlVelocity of the sound receptor in meters per second.
fsFrequency of the sound in the source in hertzs.
flPointer to the output frequency in hertzs. Will be set to NAN if either the input or the output frequency is negative, or if v + vs is zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_sound_intensity()

int zsl_phy_sound_intensity ( zsl_real_t  b,
zsl_real_t  d,
zsl_real_t  p,
zsl_real_t i 
)

Calculates the sound intensity in watts per meter squared based on the Bulk Modulus (b) and density (d) of the medium and the maximum pressure (p).

Parameters
bBulk Modulus in pascals.
dDensity in kilograms per meter cubed.
pAmplitude of the acoustic pressure in pascals.
iPointer to the output sound intensity in watts per meter squared. Will be set to NAN if the Bulk Modulus, the density or the pressure are negative, or if the density is zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_sound_level()

int zsl_phy_sound_level ( zsl_real_t  i,
zsl_real_t  i0,
zsl_real_t b 
)

Calculates the sound intensity level in decibels based on the input intensity and a reference intensity.

Parameters
iInput sound intensity in watts per meter squared.
i0Reference sound intensity in watts per meter squared.
bPointer to the sound intensity level in decibels. Will be set to NAN if either the input intensity or the reference intensity are negative.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_sound_press_amp()

int zsl_phy_sound_press_amp ( zsl_real_t  b,
zsl_real_t  k,
zsl_real_t  a,
zsl_real_t p 
)

Calculates the mamimum acoustic pressure of a sound wave in pascals.

Parameters
bBulk Modulus in pascals.
kWave number of the sound wave in radians per second.
aAmplitude of the sound wave in meters.
pPointer to the output mamimum acoustic pressure in pascals. Will be set to NAN if the Bulk Modulus, the wave number or the wave amplitude are negative.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_sound_shock_wave_angle()

int zsl_phy_sound_shock_wave_angle ( zsl_real_t  v,
zsl_real_t  vs,
zsl_real_t theta 
)

Calculates the angle of the mach wave created by a moving sound source of velocity 'vs'.

Parameters
vVelocity of the sound in the medium in meters per second.
vsVelocity of the sound source in meters per second.
thetaPointer to the output angle in radians.
Returns
0 if everything executed properly, error code on failure.