13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/synthesizer/utils.rb', line 13
def self.cross_panning(pan)
if pan<-1.0
pan = -1.0
elsif 1.0<pan
pan = 1.0
end
l_gain = 1.0 - pan
lr_gain = 0.0
if 1.0<l_gain
lr_gain = l_gain - 1.0
l_gain = 1.0
end
r_gain = 1.0 + pan
rl_gain = 0.0
if 1.0<r_gain
rl_gain = r_gain - 1.0
r_gain = 1.0
end
normalize = [1.0 - pan, 1.0 + pan].max
{
l_gain: l_gain,
lr_gain: lr_gain,
r_gain: r_gain,
rl_gain: rl_gain,
normalize: normalize
}
end
|