sr = 44100
kr = 4410
ksmps = 10
nchnls = 2
#define FILE #Filename-# ;insert filename here
#define HEADER #aif# ;insert filetype here
girescale = 1 ; for test decoding
; girescale = ; for dodecahedron1-binaural decoding
giformat = 8
; Note: The files "HRTFcompact" schould reside in the same folder as the soundfiles to be read in. Make sure the Directory points there. Else there will be an instant crash of Csound without a warning message.
; **************************************************************************************************************************
instr 82 ; 2nd ORDER AMBISONICS TO BINAURAL DECODER- coded 1999-2006 by Jan Jacob Hofmann.
; FURSE - MALHAM - SET OF EQUATIONS Version 1.0 Feb. 12th 2007
; This decodes 2nd Order Ambisonic to Binaural http://www.sonicarchitecture.de
; by using 12 virtual speakers Thanks to Richard Furse, Dave Malham and Bruce Wiggins
; **************************************************************************************************************************
aw soundin "$FILEw.$HEADER." ; input for encoded mono- files, insert filename here
ax soundin "$FILEx.$HEADER." ; input for encoded mono- files, insert filename here
ay soundin "$FILEy.$HEADER." ; input for encoded mono- files, insert filename here
az soundin "$FILEz.$HEADER." ; input for encoded mono- files, insert filename here
ar soundin "$FILEr.$HEADER." ; input for encoded mono- files, insert filename here
as soundin "$FILEs.$HEADER." ; input for encoded mono- files, insert filename here
at soundin "$FILEt.$HEADER." ; input for encoded mono- files, insert filename here
au soundin "$FILEu.$HEADER." ; input for encoded mono- files, insert filename here
av soundin "$FILEv.$HEADER." ; input for encoded mono- files, insert filename here
aw = aw * girescale
ax = ax * girescale
ay = ay * girescale
az = az * girescale
ar = ar * girescale
as = as * girescale
at = at * girescale
au = au * girescale
av = av * girescale
; **************************************************************************************
; dodecahedron1 to binaural ;Rig `Controlled Opposites' Decode Matrix (Second Order) to binaural
; **************************************************************************************
;This rig configuration produces an 'in-phase' response and each speaker will have only a single maximum given a moving virtual sound source.
; w x y z r s t u v
; Speaker 1 <0.0000,0.0000,1.0000>
achnl1 sum aw * 0.1179, az *0.1316, ar *0.0491
; Speaker 2 <0.0000,0.0000,-1.0000>
achnl2 sum aw * 0.1179, az*-0.1316, ar *0.0491
; Speaker 3 <0.7236,0.5257,0.4472>
achnl3 sum aw *0.1179, ax *0.0952, ay *0.0692, az *0.0589, ar *-0.0098,as *0.0238, at *0.0173, au *0.0091, av * 0.0280
; Speaker 4 <-0.7236,-0.5257,-0.4472>
achnl4 sum aw *0.1179, ax *-0.0952, ay *-0.0692,az *-0.0589,ar *-0.0098,as *0.0238, at *0.0173, au *0.0091, av * 0.0280
; Speaker 5 <0.7236,-0.5257,0.4472>
achnl5 sum aw *0.1179, ax *0.0952, ay *-0.0692, az *0.0589, ar *-0.0098,as *0.0238, at *-0.0173, au *0.0091, av * -0.0280
; Speaker 6 <-0.7236,0.5257,-0.4472>
achnl6 sum aw *0.1179, ax *-0.0952, ay *0.0692, az *-0.0589,ar *-0.0098,as *0.0238, at *-0.0173, au* 0.0091, av * -0.0280
; Speaker 7 <-0.2764,0.8507,0.4472>
achnl7 sum aw *0.1179, ax *-0.0364, ay *0.1119, az *0.0589,ar *-0.0098,as *-0.0091, at *0.0280, au *-0.0238, av * -0.0173
; Speaker 8 <0.2764,-0.8507,-0.4472>
achnl8 sum aw *0.1179, ax *0.0364, ay *-0.1119, az *-0.0589,ar *-0.0098,as *-0.0091, at *0.0280, au *-0.0238, av * -0.0173
; Speaker 9 <-0.2764,-0.8507,0.4472>
achnl9 sum aw *0.1179, ax *-0.0364, ay *-0.1119,az *0.0589, ar *-0.0098,as *-0.0091, at *-0.0280, au *-0.0238, av * 0.0173
; Speaker 10 <0.2764,0.8507,-0.4472>
achnl10 sum aw *0.1179, ax *0.0364, ay *0.1119, az *-0.0589, ar *-0.0098,as *-0.0091, at *-0.0280, au*-0.0238, av * 0.0173
; Speaker 11 <-0.8944,0.0000,0.4472>
achnl11 sum aw *0.1179,ax * -0.1177, az *0.0589, ar *-0.0098, as *-0.0295, au * 0.0295
; Speaker 12 <0.8944,0.0000,-0.4472>
achnl12 sum aw *0.1179,ax * 0.1177, az *-0.0589, ar *-0.0098,as *-0.0295, au * 0.0295
; gain control for the first run: set girescale = 1 for test decoding and ajust girescale acording to the largest output of kpeak for the 2nd run.
kpeak1 peak achnl1
kpeak2 peak achnl2
kpeak3 peak achnl3
kpeak4 peak achnl4
kpeak5 peak achnl5
kpeak6 peak achnl6
kpeak7 peak achnl7
kpeak8 peak achnl8
kpeak9 peak achnl9
kpeak10 peak achnl10
kpeak11 peak achnl11
kpeak12 peak achnl12
printk p3, kpeak1,0
printk p3, kpeak2,3
printk p3, kpeak3,6
printk p3, kpeak4,9
printk p3, kpeak5,12
printk p3, kpeak6,15
printk p3, kpeak7,18
printk p3, kpeak8,21
printk p3, kpeak9,24
printk p3, kpeak10,27
printk p3, kpeak11,30
printk p3, kpeak12,33
; Processing with Head Related Transfer Function
aleft1,aright1 hrtfer achnl1, 1, 89.99, "HRTFcompact.R"
aleft2,aright2 hrtfer achnl2, -1, -89.99, "HRTFcompact.R"
aleft3,aright3 hrtfer achnl3, -36, 26.565, "HRTFcompact.R"
aleft4,aright4 hrtfer achnl4, 144, -26.565, "HRTFcompact.R"
aleft5,aright5 hrtfer achnl5, 36, 26.565, "HRTFcompact.R"
aleft6,aright6 hrtfer achnl6, -144, -26.565, "HRTFcompact.R"
aleft7,aright7 hrtfer achnl7, -108, 26.565, "HRTFcompact.R"
aleft8,aright8 hrtfer achnl8, 72, -26.565, "HRTFcompact.R"
aleft9,aright9 hrtfer achnl9, 108, 26.565, "HRTFcompact.R"
aleft10,aright10 hrtfer achnl10, -72, -26.565, "HRTFcompact.R"
aleft11,aright11 hrtfer achnl11, 180, 26.565, "HRTFcompact.R"
aleft12,aright12 hrtfer achnl12, 0, -26.565, "HRTFcompact.R"
; Adding Inter Aural Time Delay ITD
aleft1 delay aleft1, 0.00028986
aleft2 delay aleft2, 0.00028986
aleft3 delay aleft3, 0.00020974
aleft4 delay aleft4, 0.00036997
aleft5 delay aleft5, 0.00036997
aleft6 delay aleft6, 0.00020974
aleft7 delay aleft7, 0.00008011
aleft8 delay aleft8, 0.00049960
aleft9 delay aleft9, 0.00049960
aleft10 delay aleft10, 0.00008011
aleft11 delay aleft11, 0.00028986
aleft12 delay aleft12, 0.00028986
aright1 delay aright1, 0.00028986
aright2 delay aright2, 0.00028986
aright3 delay aright3, 0.00036997
aright4 delay aright4, 0.00020974
aright5 delay aright5, 0.00020974
aright6 delay aright6, 0.00036997
aright7 delay aright7, 0.000499597
aright8 delay aright8, 0.00008011
aright9 delay aright9, 0.00008011
aright10 delay aright10, 0.000499597
aright11 delay aright11, 0.00028986
aright12 delay aright12, 0.00028986
; mixing all spacial signals together
aright sum aright1, aright2, aright3, aright4, aright5, aright6, aright7, aright8, aright9, aright10, aright11, aright12
aleft sum aleft1, aleft2, aleft3, aleft4, aleft5, aleft6, aleft7, aleft8, aleft9, aleft10, aleft11, aleft12
; EQ- section to compensate for the uneven signal response of HRTF-compact.
; Note: These settings have been adjusted by taste. If there is a more "refined" oe "scientific" approach of compensation, please mail it to me, thanks!
keqon invalue "eqon"
klow invalue "klow"
kmidlow invalue "kmidlow"
kmidhigh invalue "kmidhigh"
khigh invalue "khigh"
klowfreq invalue "klowfreq"
kmidlowfreq invalue "kmidlowfreq"
kmidhighfreq invalue "kmidhighfreq"
khighfreq invalue "khighfreq"
alefteql pareq aleft, klowfreq, klow,0.70710, 1 ; Low shelving
arighteql pareq aright, klowfreq, klow,0.70710, 1 ; Low shelving
alefteqml pareq aleft, kmidlowfreq, kmidlow,0.70710, 0 ; Peaking
arighteqml pareq aright, kmidlowfreq, kmidlow,0.70710, 0 ; Peaking
alefteqmh pareq aleft, kmidhighfreq, kmidhigh, 0.70710, 0 ; Peaking
arighteqmh pareq aright, kmidhighfreq, kmidhigh, 0.70710, 0 ; Peaking
alefteqh pareq aleft, khighfreq, khigh, 0.70710, 2 ; High shelving
arighteqh pareq aright, khighfreq, khigh, 0.70710, 2 ; High shelving
aleft sum alefteql, alefteqml, alefteqmh, alefteqh
aright sum arighteql, arighteqml, arighteqmh, arighteqh
aright = aright * 28.6433 ; gain compensation for HRTFer
aleft = aleft * 28.6433 ; gain compensation for HRTFer
outs aright , aleft ; output of the binaural mix
endin
/*instr 82 9-CHNL DECODING UNIT, 2nd ORDER AMBISONICS to Binaural */
i82 0 90
e
e
/*instr 40 x,y,z -READER */
/*instr 42 x, y, z -CONVERTER*/
/*instr 46 A,E,D - MOVEMENT SCORE READER*/
/*instr 47 AED- MODULATOR*/
/*instr 48 AED RANDOMIZER*/
/*instr 50 SOUNDFILE READER*/
/*instr 60 LOCAL ( TRACK APPLIED) REVERB*/
/*instr 66 GLOBAL REVERB ( W- CHANNEL APPLIED)*/
/*instr 70 HRTF ENCODE+IID+ITD*/
/*instr 71 READING, MIXING, OUTPUT*/
/*instr 72 9-CHNL ENCODING UNIT, 2nd ORDER AMBISONICS*/
/*instr 73 MIXING, OUTPUT & 9-CHNL DECODING UNIT, 2nd ORDER AMBISONICS */
Version: 3
Render: Real
Ask: Yes
Functions: Window
Listing: Window
WindowBounds: 543 368 1519 1040
CurrentView: io
IOViewEdit: On
Options: -b128 -A -s -m167 -R --midi-velocity-amp=4 --midi-key-cps=5
ioView nobackground {65535, 65535, 65535}
ioButton {630, 44} {104, 63} value 0.000000 "eqon" "source" "/" i1 0 10
ioText {569, 65} {37, 34} display 1.000000 1.000000 "eqon" left "Lucida Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder
ioSlider {519, 126} {34, 294} 0.000000 12.000000 1.960800 kmidlow
ioSlider {600, 121} {34, 294} 0.000000 12.000000 1.185600 kmidhigh
ioSlider {683, 120} {34, 297} 0.000000 12.000000 1.488000 khigh
ioButton {437, 47} {104, 60} value 1.000000 "eqon" "filter" "/" i1 0 10
ioSlider {443, 119} {35, 296} 0.000000 12.000000 1.491600 klow
ioListing {15, 15} {400, 500}
ioText {516, 401} {42, 25} display 1.960800 0.100000 "kmidlow" left "Lucida Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder
ioText {440, 403} {42, 25} display 1.491600 0.100000 "klow" left "Lucida Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder
ioText {597, 403} {42, 25} display 1.185600 0.100000 "kmidhigh" left "Lucida Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder
ioText {680, 405} {42, 25} display 1.488000 0.100000 "khigh" left "Lucida Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder
ioKnob {513, 419} {48, 48} 200.000000 6000.000000 10.000000 1800.011108 kmidlowfreq
ioKnob {437, 421} {48, 48} 20.000000 2000.000000 10.000000 119.909904 klowfreq
ioKnob {594, 421} {48, 48} 6000.000000 15000.000000 100.000000 9099.999023 kmidhighfreq
ioKnob {677, 423} {48, 48} 10000.000000 20000.000000 100.000000 16400.000000 khighfreq
ioText {524, 457} {48, 29} display 1800.011108 10.000000 "kmidlowfreq" left "Lucida Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder
ioText {448, 459} {48, 29} display 119.909904 10.000000 "klowfreq" left "Lucida Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder
ioText {605, 459} {48, 29} display 9099.999023 10.000000 "kmidhighfreq" left "Lucida Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder
ioText {688, 461} {48, 29} display 16400.000000 10.000000 "khighfreq" left "Lucida Grande" 10 {0, 0, 0} {65535, 65535, 65535} nobackground noborder