1
2
3
4
5
6
7
8
9
10
11
12
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
44
45
46
47
48
49
50
/// A rotator of some speaker channels by the room angle.
#[macro_export(local_inner_macros)]
macro_rules! rotate {
    (2ch, $room_angle:expr, $gained:ident) => {
        if $room_angle == 180 {
            $gained.swap(0, 1);
        }
    };
    (4ch, $room_angle:expr, $gained:ident) => {
        match $room_angle {
            90 => {
                $gained.swap(0, 1);
                $gained.swap(1, 3);
                $gained.swap(2, 3);
            }
            180 => {
                $gained.swap(0, 3);
                $gained.swap(1, 2);
            }
            270 => {
                $gained.swap(0, 1);
                $gained.swap(2, 3);
                $gained.swap(0, 3);
            }
            _ => {}
        }
    };
    (6ch, $room_angle:expr, $gained:ident) => {
        match $room_angle {
            90 => {
                $gained[4] = ($gained[1] + $gained[3]) / 2.0;
                $gained.swap(0, 1);
                $gained.swap(2, 3);
                $gained.swap(1, 2);
            }
            180 => {
                $gained[4] = ($gained[2] + $gained[3]) / 2.0;
                $gained.swap(0, 3);
                $gained.swap(1, 2);
            }
            270 => {
                $gained[4] = ($gained[0] + $gained[2]) / 2.0;
                $gained.swap(0, 1);
                $gained.swap(2, 3);
                $gained.swap(0, 3);
            }
            _ => {}
        }
    };
}