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

47 lines
1.1 KiB
Text
Raw Permalink Normal View History

2022-08-24 13:53:18 +00:00
#lang scribble/manual
@(require (for-label racket))
@title{(hypot x y)}
2022-08-28 10:27:01 +00:00
2022-08-24 13:53:18 +00:00
Returns the square root of the sum of the squares of a and b. Or
equivalently, the distance from the origin to the point (x, y).
2022-08-28 10:27:01 +00:00
@racketblock[
2022-08-24 13:53:18 +00:00
(audition
(out 0 (mul (sin-osc ar 440 0)
(hypot (mouse-x kr 0 0.1 0 0.1)
(mouse-y kr 0 0.1 0 0.1)))))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00
Object travels 200 meters in 6 secs (=120kph) passing 10 meters
from the listener. The speed of sound is 344 meters/sec.
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))
(velocity (slope distance))
(pitch-ratio (fdiv (sub 344 velocity) 344))
(amplitude (fdiv 10 (squared distance))))
(audition
(out 0 (mul (f-sin-osc ar (mul 1000 pitch-ratio) 0)
amplitude))))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00
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)))
(audition
(out 0 (mul (delay-l sound 110/344 (fdiv distance 344))
amplitude))))
2022-08-28 10:27:01 +00:00
]
2022-08-24 13:53:18 +00:00