Debian Codegraph @

src/Examples/FLOSS Manual Examples/05 Sound Modification/05B12_udo_ambisonics2D_3.csd

raw
1 <CsoundSynthesizer>
2 <CsOptions>
3 -odac
4 </CsOptions>
5 <CsInstruments>
6
7 sr = 44100
8 ksmps = 32
9 nchnls = 4
10 0dbfs = 1
11
12 opcode ambi2D_encode_n, 0, aik
13 asnd,iorder,kaz xin
14 kaz = $M_PI*kaz/180
15 kk = iorder
16 c1:
17 zawm cos(kk*kaz)*asnd,2*kk-1
18 zawm sin(kk*kaz)*asnd,2*kk
19 kk = kk-1
20
21 if kk > 0 goto c1
22 zawm asnd,0
23
24 endop
25
26 ;in-phase-decoding
27 opcode ambi2D_dec_inph, a, ii
28 ; weights and norms up to 12th order
29 iNorm2D[] array 1,0.75,0.625,0.546875,0.492188,0.451172,0.418945,
30 0.392761,0.370941,0.352394,0.336376,0.322360
31 iWeight2D[][] init 12,12
32 iWeight2D array 0.5,0,0,0,0,0,0,0,0,0,0,0,
33 0.666667,0.166667,0,0,0,0,0,0,0,0,0,0,
34 0.75,0.3,0.05,0,0,0,0,0,0,0,0,0,
35 0.8,0.4,0.114286,0.0142857,0,0,0,0,0,0,0,0,
36 0.833333,0.47619,0.178571,0.0396825,0.00396825,0,0,0,0,0,0,0,
37 0.857143,0.535714,0.238095,0.0714286,0.012987,0.00108225,0,0,0,0,0,0,
38 0.875,0.583333,0.291667,0.1060601,0.0265152,0.00407925,0.000291375,
39 0,0,0,0,0, 0.888889,0.622222,0.339394,0.141414,0.043512,
40 0.009324,0.0012432, 0.0000777,0,0,0,0,
41 0.9,0.654545,0.381818,0.176224,0.0629371,0.0167832,0.00314685,
42 0.000370218,0.0000205677,0,0,0,
43 0.909091,0.681818,0.41958,0.20979,0.0839161,0.0262238,0.0061703,
44 0.00102838,0.000108251,0.00000541254,0,0,
45 0.916667,0.705128,0.453297,0.241758,0.105769,0.0373303,0.0103695,
46 0.00218306,0.000327459,0.0000311866,0.00000141757,0,
47 0.923077,0.725275,0.483516,0.271978,0.12799,0.0497738,0.015718,
48 0.00392951,0.000748478,0.000102065,0.00000887523,0.000000369801
49
50 iorder,iaz1 xin
51 iaz1 = $M_PI*iaz1/180
52 kk = iorder
53 a1 = .5*zar(0)
54 c1:
55 a1 += cos(kk*iaz1)*iWeight2D[iorder-1][kk-1]*zar(2*kk-1)
56 a1 += sin(kk*iaz1)*iWeight2D[iorder-1][kk-1]*zar(2*kk)
57 kk = kk-1
58 if kk > 0 goto c1
59 xout iNorm2D[iorder-1]*a1
60 endop
61
62 zakinit 7, 1
63
64 instr 1
65 asnd rand p4
66 ares reson asnd,p5,p6,1
67 kaz line 0,p3,p7*360 ;turns around p7 times in p3 seconds
68 ambi2D_encode_n asnd,3,kaz
69 endin
70
71 instr 11
72
73 a1 ambi2D_dec_inph 3,0
74 a2 ambi2D_dec_inph 3,90
75 a3 ambi2D_dec_inph 3,180
76 a4 ambi2D_dec_inph 3,270
77 outc a1,a2,a3,a4
78 zacl 0,6 ; clear the za variables
79 endin
80
81 </CsInstruments>
82 <CsScore>
83 ; amp cf bw turns
84 i1 0 3 .1 1500 12 1
85 i11 0 3
86 </CsScore>
87 </CsoundSynthesizer>
88 ;example by martin neukom