| 1 |
<CsoundSynthesizer> |
| 2 |
<CsOptions> |
| 3 |
--env:SSDIR+=../../SourceMaterials -odac -m0 |
| 4 |
</CsOptions> |
| 5 |
<CsInstruments> |
| 6 |
sr = 44100 |
| 7 |
ksmps = 32 |
| 8 |
nchnls = 8 |
| 9 |
0dbfs = 1 |
| 10 |
|
| 11 |
#include "../../SourceMaterials/ambisonics2D_udos.txt" |
| 12 |
#include "../../SourceMaterials/ambisonics_utilities.txt" ;Absorb and Doppler |
| 13 |
|
| 14 |
/* these opcodes are included in "ambisonics2D_udos.txt" |
| 15 |
opcode xy_to_ad, kk, kk |
| 16 |
kx,ky xin |
| 17 |
kdist = sqrt(kx*kx+ky*ky) |
| 18 |
kaz taninv2 ky,kx |
| 19 |
xout 180*kaz/$M_PI, kdist |
| 20 |
endop |
| 21 |
|
| 22 |
opcode Absorb, a, ak |
| 23 |
asnd,kdist xin |
| 24 |
aabs tone 5*asnd,20000*exp(-.1*kdist) |
| 25 |
xout aabs |
| 26 |
endop |
| 27 |
|
| 28 |
opcode Doppler, a, ak |
| 29 |
asnd,kdist xin |
| 30 |
abuf delayr .5 |
| 31 |
adop deltapi interp(kdist)*0.0029137529 + .01 ; 1/343.2 |
| 32 |
delayw asnd |
| 33 |
xout adop |
| 34 |
endop |
| 35 |
*/ |
| 36 |
opcode write_ambi2D_2, 0, S |
| 37 |
Sname xin |
| 38 |
fout Sname,12,zar(0),zar(1),zar(2),zar(3),zar(4) |
| 39 |
endop |
| 40 |
|
| 41 |
zakinit 17, 1 ; zak space with the 17 channels of the B-format |
| 42 |
|
| 43 |
instr 1 |
| 44 |
asnd buzz p4,p5,50,1 |
| 45 |
;asnd soundin "/Users/user/csound/ambisonic/violine.aiff" |
| 46 |
kx line p7,p3,p8 |
| 47 |
ky line p9,p3,p10 |
| 48 |
kaz,kdist xy_to_ad kx,ky |
| 49 |
aabs absorb asnd,kdist |
| 50 |
adop Doppler .2*aabs,kdist |
| 51 |
ambi2D_enc_dist adop,5,kaz,kdist |
| 52 |
endin |
| 53 |
|
| 54 |
instr 10 ;decode all instruments |
| 55 |
a1,a2,a3,a4, |
| 56 |
a5,a6,a7,a8 ambi2D_dec_inph 5,0,45,90,135,180,225,270,315 |
| 57 |
outc a1,a2,a3,a4,a5,a6,a7,a8 |
| 58 |
; fout "B_format2D.wav",12,zar(0),zar(1),zar(2),zar(3),zar(4), |
| 59 |
; zar(5),zar(6),zar(7),zar(8),zar(9),zar(10) |
| 60 |
write_ambi2D_2 "ambi_ex5.wav" |
| 61 |
zacl 0,16 ; clear the za variables |
| 62 |
endin |
| 63 |
|
| 64 |
</CsInstruments> |
| 65 |
<CsScore> |
| 66 |
f1 0 32768 10 1 |
| 67 |
; amp f 0 x1 x2 y1 y2 |
| 68 |
i1 0 5 .8 200 0 40 -20 1 .1 |
| 69 |
i10 0 5 |
| 70 |
</CsScore> |
| 71 |
</CsoundSynthesizer> |
| 72 |
;example by martin neukom |