rsc3/doc/help/ugen/binary-ops/atan2.help.scrbl

31 lines
721 B
Text
Raw Permalink Normal View History

2022-08-24 13:53:18 +00:00
#lang scribble/manual
@(require (for-label racket))
@title{(Atan2 x y)}
2022-08-28 10:27:01 +00:00
2022-08-24 13:53:18 +00:00
Returns the arctangent of y/x.
See also hypot.
add a pan to the hypot doppler examples by using atan2 to find the
azimuth, or direction angle, of the sound source. Assume speakers
at +/- 45 degrees and clip the direction to between those.
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(let* ((x 10)
(y (mul (lf-saw kr 1/6 0) 100))
(distance (hypot x y))
(amplitude (fdiv 40 (squared distance)))
(sound (rlpf (mul (f-sin-osc ar 200 0) (lf-pulse ar 31.3 0 0.4)) 400 0.3))
(azimuth (atan2 y x))
(loc (clip2 (fdiv azimuth (/ pi 2)) 1)))
(audition
(out 0 (pan2 (delay-l sound 110/344 (fdiv distance 344))
loc
amplitude))))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00