| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
--env:SSDIR+=../../SourceMaterials -odac -m0 |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 32 |
| 8 |
nchnls = 2 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
zakinit 81, 1 ; zak space with the 11 channels of the B-format |
| 12 |
|
| 13 |
#include "../../SourceMaterials/ambisonics_udos.txt" |
| 14 |
|
| 15 |
opcode ambi3D_enc_dist1, 0, aikkk |
| 16 |
asnd,iorder,kaz,kel,kdist xin |
| 17 |
kaz = $M_PI*kaz/180 |
| 18 |
kel = $M_PI*kel/180 |
| 19 |
kaz = (kdist < 0 ? kaz + $M_PI : kaz) |
| 20 |
kel = (kdist < 0 ? -kel : kel) |
| 21 |
kdist = abs(kdist)+0.00001 |
| 22 |
kgainW = taninv(kdist*1.5708) / (kdist*1.5708) |
| 23 |
kgainHO = (1 - exp(-kdist)) ;*kgainW |
| 24 |
outvalue "kgainHO", kgainHO |
| 25 |
outvalue "kgainW", kgainW |
| 26 |
kcos_el = cos(kel) |
| 27 |
ksin_el = sin(kel) |
| 28 |
kcos_az = cos(kaz) |
| 29 |
ksin_az = sin(kaz) |
| 30 |
asnd = kgainW*asnd |
| 31 |
zawm asnd,0 ; W |
| 32 |
asnd = kgainHO*asnd |
| 33 |
zawm kcos_el*ksin_az*asnd,1 ; Y = Y(1,-1) |
| 34 |
zawm ksin_el*asnd,2 ; Z = Y(1,0) |
| 35 |
zawm kcos_el*kcos_az*asnd,3 ; X = Y(1,1) |
| 36 |
if iorder < 2 goto end |
| 37 |
/* |
| 38 |
... |
| 39 |
*/ |
| 40 |
end: |
| 41 |
|
| 42 |
endop |
| 43 |
|
| 44 |
instr 1 |
| 45 |
asnd init 1 |
| 46 |
kaz invalue "az" |
| 47 |
kel invalue "el" |
| 48 |
kdist invalue "dist" |
| 49 |
ambi_enc_dist asnd,5,kaz,kel,kdist |
| 50 |
ao1,ao2,ao3,ao4 ambi_decode 5,17 |
| 51 |
outvalue "sp1", downsamp(ao1) |
| 52 |
outvalue "sp2", downsamp(ao2) |
| 53 |
outvalue "sp3", downsamp(ao3) |
| 54 |
outvalue "sp4", downsamp(ao4) |
| 55 |
outc 0*ao1,0*ao2;,2*ao3,2*ao4 |
| 56 |
zacl 0,80 |
| 57 |
endin |
| 58 |
</CsInstruments> |
| 59 |
<CsScore> |
| 60 |
f17 0 64 -2 0 0 0 90 0 180 0 0 90 0 0 0 0 |
| 61 |
i1 0 100 |
| 62 |
</CsScore> |
| 63 |
</CsoundSynthesizer> |
| 64 |
;example by martin neukom |