music.localize2¶
- music.localize2(sonic_vector=None, theta=-70, x=0.1, y=0.01, zeta=0.215, air_temp=20, method='ifft', sample_rate=44100)[source]¶
Make a mono sound stereo and localize it by experimental methods.
See bellow for implementation notes. These implementations are not standard and are only to illustrate the method of using ITD and IID that are frequency dependent.
- Parameters:
- sonic_vectorarray_like
An one dimensional with the PCM samples of the sound.
- xscalar
The lateral component of the position in meters.
- yscalar
The frontal component of the position in meters.
- thetascalar
The azimuthal angle of the position in degrees. If theta is supplied, x and y are ignored and dist must also be supplied for the sound localization to have effect.
- zetascalar
The distance between the ears in meters.
- air_tempscalar
The temperature in Celsius used for calculating the speed of sound.
- method
str Set to “ifft” for a working method that changes the fourier spectral coefficients. Set to “brute” for using an implementation that sinthesizes each sinusoid in the fourier spectrum separately (currently not giving good results for all sounds).
- sample_rate
integer The sample rate.
- Returns:
- s
ndarray A (2, nsamples) shaped array with the PCM samples of the stereo sound.
- s
See also
Notes
Uses a less naive ITD and IID calculations as described in [1].
See localize() for further notes.
Cite the following article whenever you use this function.
References
[1]Fabbri, Renato, et al. “Musical elements in the discrete-time representation of sound.” arXiv preprint arXiv:abs/1412.6853 (2017)
Examples
>>> write_wav_stereo(localized2()) >>> write_wav_stereo(horizontal_stack([ ... localized2(note_with_vibrato(duration=1), x=i, y=j) ... for i, j in zip([.1, .7, np.pi - .1, np.pi - .7], ... [.1, .1, .1, .1])]))