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