<CsoundSynthesizer><CsInstruments>sr = 44100kr = 441ksmps = 100nchnls = 2gidecchnls = 8		; specifies the speaker setup:				; 2 	= stereo speaker setup				; 4 	= quattro (square) speaker setup				; 5 	= pentagon speaker setup				; 5.1 = 5.1 surround speaker setup				; 6 	= hexagonoctogon1 				; 8.1 = octogon1 				; 8.2 = octogon2 				; 8 	= cube				; 12.1= dodecahedron1 				; 12.2= dodecahedron2 			    girescale = 1		;  for test decoding; girescale = 		;  for 2chnl decoding; girescale = 		;  for 5 chnl encoding ; girescale = 		;  for 5.1 chnl encoding ; girescale = 		;  for octogon1 decoding ; girescale = 		;  for octogon2 decoding ; girescale = 		;  for 8chnl cube decoding; girescale = 		;  for dodecahedron1 decoding ; girescale = 		;  for dodecahedron2 decoding ;	**************************************************************************************instr 81	; First  ORDER AMBISONICS DECODER				coded 1999-2002 by Jan Jacob Hofmann.	; FURSE - MALHAM - SET OF  EQUATIONS				Thanks to Richard Furse and Dave Malham	; More sets of speaker- layouts may be discovered at	; http://www.muse.demon.co.uk/ref/speakers.html;	**************************************************************************************ieqshift 	= p4		;  factor for shifting between spherical harmonic [0] decoding matrix and controlled opposites [1] decoding matrix				;  choose any factor between 0 and 1  						;  [0] produces a strict idealised response that satisfies the Ambisonic matching equations.				;  Generally this type of configuration produces a relatively small stable listening area. 				;  [1] produces an `in-phase' response and each speaker will have only a single maximum given a moving virtual sound source.				;  Values of ieqshift closer to 0 are only recomended if a sufficient number of speakers are available.aw, ax, ay, az	soundin	"ambisonics-bformat.aif"	; input for encoded 4 chnl- files; aw	soundin	"ambisonics-w.aif"				; input for encoded mono- files; ax	soundin	"ambisonics-x.aif"; ay	soundin	"ambisonics-y.aif"; az	soundin	"ambisonics-z.aif"aw =	aw *  girescaleax =	ax *  girescale	ay =	ay *  girescale	az =	az *  girescale	if	gidecchnls ==  2	   	goto 	stereo 		; goto	2chnl  decode	if	gidecchnls ==  4	   	goto 	square		; goto	4chnl  decode	if	gidecchnls ==  5	   	goto 	penta 		; goto	5chnl   decode	if	gidecchnls ==  5.1	goto 	surround		; goto	surround5.1  decode	if	gidecchnls ==  6	   	goto 	hexagon 		; goto	6chnl   decode	if	gidecchnls ==  8.1	goto 	octagon1		; goto	8chnl  decode	(octogon 1)if	gidecchnls ==  8.2	goto 	octagon2		; goto	8chnl  decode	(octogon 2)if	gidecchnls ==  8	   	goto 	cube			; goto	8chnl  decode	if	gidecchnls ==  12.1	goto 	dodecahedron1	; goto	12chnl  decode (dodecahedron1)if	gidecchnls ==  12.2	goto 	dodecahedron2	; goto	12chnl  decode (dodecahedron2);	******************************************************************************************************************************stereo: 		; 2chnl (stereo ) decode,2nd  order (second order controlled opposites);	******************************************************************************************************************************;Rig `Controlled Opposites' Decode Matrix (second Order);			w		x		y		z	; Speaker1	<0.0000,1.0000,0.0000>	leftachnl1 	sum 	aw * 0.7071,		ay * 0.5000 ; Speaker2	<0.0000,-1.0000,0.0000>	rightachnl2 	sum	aw * 0.7071,		ay * -0.5000 outs	 achnl1, achnl2; soundout	 achnl1, "ambisonics,dec1",4; soundout	 achnl2, "ambisonics,dec2",4goto 	skipend;	******************************************************************************************************************************square:		; Rig `Controlled Opposites' Decode Matrix (First Order);	******************************************************************************************************************************; 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	; Speaker1<0.7071,0.7071,0.0000>  left frontachnl1 	sum	aw *0.3536,	ax *0.3536,	ay * 0.3536						; Speaker2<0.7071,-0.7071,0.0000>  right frontachnl2 	sum	aw *0.3536,	ax *0.3536,	ay * -0.3536					; Speaker3<-0.7071,-0.7071,0.0000>  right backachnl3 	sum	aw *0.3536,	ax *-0.3536, ay * -0.3536					; Speaker4 <-0.7071,0.7071,0.0000>  left backachnl4 	sum	aw *0.3536,	ax -0.3536,	ay * 0.3536						kpeak1	peak	achnl1	kpeak2	peak	achnl2	kpeak3	peak	achnl3	kpeak4	peak	achnl4		printk	p3, kpeak1,0	printk	p3, kpeak2,4	printk	p3, kpeak3,8	printk	p3, kpeak4,12fout 	"ambisquaredec1", 2,  achnl1fout 	"ambisquaredec2", 2,  achnl2fout 	"ambisquaredec3", 2,  achnl3fout 	"ambisquaredec4", 2,  achnl4goto skipend;	******************************************************************************************************************************penta:;	******************************************************************************************************************************; 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	; Speaker1 <0.8090,0.5878,0.0000> front leftachnl1 	sum	aw *0.2828,	ax *0.1618,	ay * 0.1176; Speaker2 <-0.3090,0.9511,0.0000> back leftachnl2 	sum	aw *0.2828,	ax *-0.0618,ay * 0.1902; Speaker3 <-1.0000,0.0000,0.0000> backachnl3 	sum	aw *0.2828,	ax * -0.2; Speaker4 <-0.3090,-0.9511,0.0000> back rightachnl4 	sum	aw *0.2828,	ax *-0.0618, ay * -0.1902; Speaker5 <0.8090,-0.5878,0.0000> front rightachnl5 	sum	aw *0.2828,	ax *0.1618,	ay * -0.1176kpeak1	peak	achnl1	kpeak2	peak	achnl2	kpeak3	peak	achnl3	kpeak4	peak	achnl4	kpeak5	peak	achnl5			printk	p3, kpeak1,0		printk	p3, kpeak2,4		printk	p3, kpeak3,8		printk	p3, kpeak4,12		printk	p3, kpeak5,16fout 	"ambipentadec1", 2,  achnl1fout 	"ambipentadec2", 2,  achnl2fout 	"ambipentadec3", 2,  achnl3fout 	"ambipentadec4", 2,  achnl4fout 	"ambipentadec5", 2,  achnl5goto skipend;	******************************************************************************************************************************surround:	; Rig `Controlled Opposites' Decode Matrix (First Order controlled opposites);		Note that the second order rig has a high symmetry distortion rating. Such a rig is likely to provide an unstable image.;	******************************************************************************************************************************;			w		x		y		z	; Speaker 1	<0.8660,0.5000,0.0000>   front left achnl1 	sum	aw *0.1690,	ax *0.0797,	ay * 0.0891	; Speaker 2<1.0000,0.0000,0.0000>   front center achnl2 	sum	aw *0.1635,	ax * 0.0923	 ; Speaker 3<0.8660,-0.5000,0.0000>  front right achnl3 	sum	aw *0.1690,	ax *0.0797,	ay * -0.0891	; Speaker 4<-0.5000,0.8660,0.0000>  back left achnl4 	sum	aw *0.4563,	ax *-0.1259,ay * 0.1543	; Speaker 5<-0.5000,-0.8660,0.0000> back right achnl5 	sum	aw *0.4563,	ax *-0.1259,ay * -0.1543kpeak1	peak	achnl1	kpeak2	peak	achnl2	kpeak3	peak	achnl3	kpeak4	peak	achnl4	kpeak5	peak	achnl5			printk	p3, kpeak1,0		printk	p3, kpeak2,4		printk	p3, kpeak3,8		printk	p3, kpeak4,12		printk	p3, kpeak5,16fout 	"ambisonic-5_1dec1", 2,  achnl1			;front-leftfout 	"ambisonic-5_1dec2", 2,  achnl2			;front-centerfout 	"ambisonic-5_1dec3", 2,  achnl3			;front-rightfout 	"ambisonic-5_1dec4", 2,  achnl4			;back-leftfout 	"ambisonic-5_1dec5", 2,  achnl5			;back-rightgoto skipend;	******************************************************************************************************************************hexagon:	; 6 chnl  decode (hexagon)	first  order ;	******************************************************************************************************************************;	Rig Decode Matrix to Reproduce Spherical Harmonics (First Order);	This rig configuration produces a strict idealised response that satisfies the Ambisonic matching equations.;	Generally this type of configuration produces a relatively small stable listening area. (See controlled opposites below.)  achnlsh1	init	0 achnlsh2	init	0 achnlsh3	init	0 achnlsh4	init	0 achnlsh5	init	0 achnlsh6	init	0  achnlco1	init	0 achnlco2	init	0 achnlco3	init	0 achnlco4	init	0 achnlco5	init	0 achnlco6	init	0 if	ieqshift =  1	   	goto 	hexcontrolled;			w		x		y		z	; Speaker 1 <0.8660,0.5000,0.0000> achnlsh1 	sum	aw *0.2357,	ax *0.2887,	ay * 0.1667; Speaker 2 <0.0000,1.0000,0.0000> achnlsh2 	sum	aw * 0.2357,		ay * 0.3333; Speaker 3 <-0.8660,0.5000,0.0000> achnlsh3 	sum	aw *0.2357,	ax *-0.2887, ay * 0.1667; Speaker 4 <-0.8660,-0.5000,0.0000> achnlsh4 	sum	aw *0.2357, ax *-0.2887, ay * -0.1667; Speaker 5 <0.0000,-1.0000,0.0000> achnlsh5 	sum	aw * 0.2357,		ay * -0.3333; Speaker 6 <0.8660,-0.5000,0.0000> achnlsh6 	sum	aw *0.2357,	ax *0.2887,	ay * -0.1667if	ieqshift =  0	   	goto 	hexmixhexcontrolled:;	Rig decode matrix to reproduce controlled opposites (First Order);			w		x		y		z	; Speaker 1 <0.8660,0.5000,0.0000> achnlco1 	sum	aw *0.2357,	ax *0.1443,	ay * 0.0833			; Speaker 2 <0.0000,1.0000,0.0000> achnlco2 	sum	aw * 0.2357,		ay * 0.1667		; Speaker 3 <-0.8660,0.5000,0.0000> achnlco3 	sum	aw *0.2357,	ax *-0.1443, ay * 0.0833; Speaker 4 <-0.8660,-0.5000,0.0000> achnlco4 	sum	aw *0.2357,	ax *-0.1443, ay * -0.0833	; Speaker 5 <0.0000,-1.0000,0.0000> achnlco5 	sum	aw * 0.2357,		ay * -0.1667	; Speaker 6 <0.8660,-0.5000,0.0000> achnlco6 	sum	aw *0.2357,	ax *0.1443,	ay * -0.0833	hexmix:achnl1	sum 	achnlco1 * ieqshift, achnlsh1 * 1 - ieqshiftachnl2	sum 	achnlco2 * ieqshift, achnlsh2 * 1 - ieqshiftachnl3	sum 	achnlco3 * ieqshift, achnlsh3 * 1 - ieqshiftachnl4	sum 	achnlco4 * ieqshift, achnlsh4 * 1 - ieqshiftachnl5	sum 	achnlco5 * ieqshift, achnlsh5 * 1 - ieqshiftachnl6	sum 	achnlco6 * ieqshift, achnlsh6 * 1 - ieqshiftkpeak1	peak	achnl1	kpeak2	peak	achnl2	kpeak3	peak	achnl3	kpeak4	peak	achnl4	kpeak5	peak	achnl5	kpeak6	peak	achnl6			printk	p3, kpeak1,0		printk	p3, kpeak2,4		printk	p3, kpeak3,8		printk	p3, kpeak4,12		printk	p3, kpeak5,16		printk	p3, kpeak6,20fout 	"ambisonic-hexdec1", 2,  achnl1			fout 	"ambisonic-hexdec2", 2,  achnl2			fout 	"ambisonic-hexdec3", 2,  achnl3			fout 	"ambisonic-hexdec4", 2,  achnl4		fout 	"ambisonic-hexdec5", 2,  achnl5			fout 	"ambisonic-hexdec6", 2,  achnl6			goto skipend;	******************************************************************************************************************************octagon1:	; 8 chnl  decode (octagon 1),first  order ;	******************************************************************************************************************************;	Rig Decode Matrix to Reproduce Spherical Harmonics (First Order);	This rig configuration produces a strict idealised response that satisfies the Ambisonic matching equations.;	Generally this type of configuration produces a relatively small stable listening area. (See controlled opposites below.)  achnlsh1	init	0 achnlsh2	init	0 achnlsh3	init	0 achnlsh4	init	0 achnlsh5	init	0 achnlsh6	init	0 achnlsh7	init	0 achnlsh8	init	0 achnlco1	init	0 achnlco2	init	0 achnlco3	init	0 achnlco4	init	0 achnlco5	init	0 achnlco6	init	0 achnlco7	init	0 achnlco8	init	0if	ieqshift =  1	   	goto 	octo1controlled;			w		x		y		z	; Speaker 1 <0.9239,0.3827,0.0000>		front left achnlsh1 	sum	aw *0.1768, ax *0.231,	ay * 0.0957; Speaker 2 <0.3827,0.9239,0.0000>		front midleft achnlsh2 	sum	aw *0.1768,	ax *0.0957,	ay * 0.231; Speaker 3 <-0.3827,0.9239,0.0000>		back midleft achnlsh3 	sum	aw *0.1768,	ax *-0.0957, ay * 0.231; Speaker 4 <-0.9239,0.3827,0.0000>		back left achnlsh4 	sum	aw *0.1768,	ax *-0.231,	ay * 0.0957; Speaker 5 <-0.9239,-0.3827,0.0000>	back right achnlsh5 	sum	aw *0.1768, ax *-0.231,	ay * -0.0957; Speaker 6 <-0.3827,-0.9239,0.0000>	back midright achnlsh6 	sum	aw *0.1768,	ax *-0.0957, ay * -0.231; Speaker 7 <0.3827,-0.9239,0.0000>		front midright achnlsh7 	sum	aw *0.1768, ax *0.0957,	ay * -0.231; Speaker 8 <0.9239,-0.3827,0.0000>		front right achnlsh8 	sum	aw *0.1768,	ax * 0.231,	ay * -0.0957if	ieqshift =  0	   	goto 	octo1mixocto1controlled:;	Rig decode matrix to reproduce controlled opposites (First Order);			w		x		y		z	; Speaker 1 <0.924,0.383,0.000>	front left achnlco1 	sum	aw *1.768, 	ax*0.1155,	ay * 0.0478	; Speaker 2 <0.383,0.924,0.000>	front midleft  achnlco2 	sum	aw *1.768,	ax*0.0478, 	ay * 0.1155	  ; Speaker 3   <-0.383,0.924,0.000>	back midleft  achnlco3	sum	aw * 1.768,	ax*-0.0478,	ay * 0.1155	; Speaker 4  <-0.924,0.383,0.000>	back left achnlco4	sum	aw *1.768,	ax*-0.1155, ay * 0.0478	; Speaker5   <-0.924,-0.383,0.000>	back right achnlco5 	sum	aw *1.768,	ax*-0.1155,	ay * -0.0478	; Speaker 6   <-0.383,-0.924,0.000>	back midright achnlco6	sum	aw *1.768,	ax*-0.0478,	ay * -0.1155	; Speaker 7   <0.383,-0.924,0.000>	front midright achnlco7 	sum	aw *1.768,	ax* 0.0478,	ay * -0.1155	 ; Speaker 8  <0.924,-0.383,0.000>	front right achnlco8 	sum	aw *1.768,	ax *0.1155,	ay * -0.0478	octo1mix:achnl1	sum 	achnlco1 * ieqshift, achnlsh1 * 1 - ieqshiftachnl2	sum 	achnlco2 * ieqshift, achnlsh2 * 1 - ieqshiftachnl3	sum 	achnlco3 * ieqshift, achnlsh3 * 1 - ieqshiftachnl4	sum 	achnlco4 * ieqshift, achnlsh4 * 1 - ieqshiftachnl5	sum 	achnlco5 * ieqshift, achnlsh5 * 1 - ieqshiftachnl6	sum 	achnlco6 * ieqshift, achnlsh6 * 1 - ieqshiftachnl7	sum 	achnlco7 * ieqshift, achnlsh7 * 1 - ieqshiftachnl8	sum 	achnlco8 * ieqshift, achnlsh8 * 1 - ieqshiftkpeak1	peak	achnl1	kpeak2	peak	achnl2	kpeak3	peak	achnl3	kpeak4	peak	achnl4	kpeak5	peak	achnl5	kpeak6	peak	achnl6	kpeak7	peak	achnl7	kpeak8	peak	achnl8		printk	p3, kpeak1,0	printk	p3, kpeak2,4	printk	p3, kpeak3,8	printk	p3, kpeak4,12	printk	p3, kpeak5,16	printk	p3, kpeak6,20	printk	p3, kpeak7,24	printk	p3, kpeak8,28fout 	"ambisonic-oct1dec1", 2,  achnl1fout 	"ambisonic-oct1dec2", 2,  achnl2fout 	"ambisonic-oct1dec3", 2,  achnl3fout 	"ambisonic-oct1dec4", 2,  achnl4fout 	"ambisonic-oct1dec5", 2,  achnl5fout 	"ambisonic-oct1dec6", 2,  achnl6fout 	"ambisonic-oct1dec7", 2,  achnl7fout 	"ambisonic-oct1dec8", 2,  achnl8goto skipend;	******************************************************************************************************************************octagon2:	; 8 chnl  decode (octagon 2),first  order (controlled opposites);	******************************************************************************************************************************;	Rig Decode Matrix to Reproduce Spherical Harmonics (First Order);	This rig configuration produces a strict idealised response that satisfies the Ambisonic matching equations.;	Generally this type of configuration produces a relatively small stable listening area. (See controlled opposites below.)  achnlsh1	init	0 achnlsh2	init	0 achnlsh3	init	0 achnlsh4	init	0 achnlsh5	init	0 achnlsh6	init	0 achnlsh7	init	0 achnlsh8	init	0 achnlco1	init	0 achnlco2	init	0 achnlco3	init	0 achnlco4	init	0 achnlco5	init	0 achnlco6	init	0 achnlco7	init	0 achnlco8	init	0if	ieqshift =  1	   	goto 	octo2controlled;			w		x		y		z	; Speaker 1 <1.0000,0.0000,0.0000>		front left achnlsh1 	sum	aw *0.1768,	ax * 0.2500; Speaker 2 <0.7071,0.7071,0.0000>		front midleft achnlsh2 	sum	aw *0.1768,	ax *0.1768,	ay * 0.1768; Speaker 3 <0.0000,1.0000,0.0000>		back midleft achnlsh3 	sum	aw * 0.1768,		ay * 0.2500; Speaker 4 <-0.7071,0.7071,0.0000> 	back left achnlsh4 	sum	aw *0.1768,	ax *-0.1768, ay * 0.1768; Speaker 5 <-1.0000,0.0000,0.0000>		back right achnlsh5 	sum	aw *0.1768,	ax * -0.2500; Speaker 6 <-0.7071,-0.7071,0.0000>	back midright achnlsh6 	sum	aw *0.1768,	ax *-0.1768, ay * -0.1768; Speaker 7 <0.0000,-1.0000,0.0000> 	front midright achnlsh7 	sum	aw * 0.1768,		ay * -0.2500; Speaker 8 <0.7071,-0.7071,0.0000>		front right achnlsh8 	sum	aw *0.1768,	ax *0.1768,	ay * -0.1768if	ieqshift =  0	   	goto 	octo2mixocto2controlled:;	Rig decode matrix to reproduce controlled opposites (First Order);			w		x		y		z	; Speaker 1 <1.0000,0.0000,0.0000> achnlco1 	sum	aw *0.1768,	ax * 0.1250; Speaker  2 <0.7071,0.7071,0.0000> achnlco2 	sum	aw *0.1768,	ax *0.0884,	ay * 0.0884; Speaker  3 <0.0000,1.0000,0.0000> achnlco3 	sum	aw *0.1768,			ay * 0.1250; Speaker 4 <-0.7071,0.7071,0.0000> achnlco4 	sum	aw *0.1768,	ax *-0.0884, ay * 0.0884; Speaker 5 <-1.0000,0.0000,0.0000> achnlco5 	sum	aw *0.1768, ax * -0.1250; Speaker  6 <-0.7071,-0.7071,0.0000> achnlco6 	sum	aw *0.1768,	ax *-0.0884, ay * -0.0884; Speaker  7 <0.0000,-1.0000,0.0000> achnlco7 	sum	aw *0.1768, ax * -0.1250; Speaker 8 <0.7071,-0.7071,0.0000> achnlco8 	sum	aw *0.1768, ax *0.0884,	ay * -0.0884octo2mix:achnl1	sum 	achnlco1 * ieqshift, achnlsh1 * 1 - ieqshiftachnl2	sum 	achnlco2 * ieqshift, achnlsh2 * 1 - ieqshiftachnl3	sum 	achnlco3 * ieqshift, achnlsh3 * 1 - ieqshiftachnl4	sum 	achnlco4 * ieqshift, achnlsh4 * 1 - ieqshiftachnl5	sum 	achnlco5 * ieqshift, achnlsh5 * 1 - ieqshiftachnl6	sum 	achnlco6 * ieqshift, achnlsh6 * 1 - ieqshiftachnl7	sum 	achnlco7 * ieqshift, achnlsh7 * 1 - ieqshiftachnl8	sum 	achnlco8 * ieqshift, achnlsh8 * 1 - ieqshiftkpeak1	peak	achnl1	kpeak2	peak	achnl2	kpeak3	peak	achnl3	kpeak4	peak	achnl4	kpeak5	peak	achnl5	kpeak6	peak	achnl6	kpeak7	peak	achnl7	kpeak8	peak	achnl8		printk	p3, kpeak1,0	printk	p3, kpeak2,4	printk	p3, kpeak3,8	printk	p3, kpeak4,12	printk	p3, kpeak5,16	printk	p3, kpeak6,20	printk	p3, kpeak7,24	printk	p3, kpeak8,28fout 	"ambisonic-oct2dec1", 2,  achnl1fout 	"ambisonic-oct2dec2", 2,  achnl2fout 	"ambisonic-oct2dec3", 2,  achnl3fout 	"ambisonic-oct2dec4", 2,  achnl4fout 	"ambisonic-oct2dec5", 2,  achnl5fout 	"ambisonic-oct2dec6", 2,  achnl6fout 	"ambisonic-oct2dec7", 2,  achnl7fout 	"ambisonic-oct2dec8", 2,  achnl8goto skipend;	******************************************************************************************************************************cube:		; 8chnl  decode (cube),1st  order (First order controlled opposites);	******************************************************************************************************************************;	Rig `Controlled Opposites' Decode Matrix (First Order);			w		x		y		z		  ; Speaker1	<0.5774,0.5774,-0.5774>  	front left lowerachnl1 	sum	aw *0.1768,	ax *0.0722,	ay *0.0722,	az * -0.0722	; Speaker2	<0.5774,-0.5774,-0.5774>	front right lowerachnl2 	sum	aw *0.1768,	ax *0.0722,	ay *-0.0722, az * -0.0722	; Speaker3	<-0.5774,-0.5774,-0.5774>	back right lowerachnl3 	sum	aw *0.1768,	ax *-0.0722, ay *-0.0722, az * -0.0722	; Speaker4	<-0.5774,0.5774,-0.5774>	back left lowerachnl4 	sum	aw *0.1768,	ax *-0.0722, ay *0.0722, az * -0.0722	; Speaker5	<0.5774,0.5774,0.5774>		front left upperachnl5 	sum	aw *0.1768,	ax *0.0722,	ay *0.0722,	az * 0.0722	; Speaker6	<0.5774,-0.5774,0.5774>		front right upperachnl6 	sum	aw *0.1768,	ax *0.0722,	ay *-0.0722, az * 0.0722	; Speaker7	<-0.5774,-0.5774,0.5774>	back  right upperachnl7 	sum	aw *0.1768,	ax *-0.0722, ay *-0.0722, az * 0.0722	; Speaker8	<-0.5774,0.5774,0.5774>		back left upperachnl8 	sum	aw *0.1768,	ax *-0.0722, ay *0.0722, az * 0.0722	kpeak1	peak	achnl1	kpeak2	peak	achnl2	kpeak3	peak	achnl3	kpeak4	peak	achnl4	kpeak5	peak	achnl5	kpeak6	peak	achnl6	kpeak7	peak	achnl7	kpeak8	peak	achnl8		printk	p3, kpeak1,0	printk	p3, kpeak2,4	printk	p3, kpeak3,8	printk	p3, kpeak4,12	printk	p3, kpeak5,16	printk	p3, kpeak6,20	printk	p3, kpeak7,24	printk	p3, kpeak8,28;outo	  achnl1, achnl2, achnl3, achnl4, achnl5, achnl6, achnl7, achnl8		;output for writing on Disk or Datfout 	"ambisonic-cubedec1", 2,  achnl1fout 	"ambisonic-cubedec2", 2,  achnl2fout 	"ambisonic-cubedec3", 2,  achnl3fout 	"ambisonic-cubedec4", 2,  achnl4fout 	"ambisonic-cubedec5", 2,  achnl5fout 	"ambisonic-cubedec6", 2,  achnl6fout 	"ambisonic-cubedec7", 2,  achnl7fout 	"ambisonic-cubedec8", 2,  achnl8goto	skipend;	******************************************************************************************************************************dodecahedron1:			;	******************************************************************************************************************************;	Rig Decode Matrix to Reproduce Spherical Harmonics (First Order);	This rig configuration produces a strict idealised response that satisfies the Ambisonic matching equations.;	Generally this type of configuration produces a relatively small stable listening area. (See controlled opposites below.)   achnlsh1	init	0 achnlsh2	init	0 achnlsh3	init	0 achnlsh4	init	0 achnlsh5	init	0 achnlsh6	init	0 achnlsh7	init	0 achnlsh8	init	0 achnlsh9	init	0 achnlsh10	init	0 achnlsh11	init	0 achnlsh12	init	0 achnlco1	init	0 achnlco2	init	0 achnlco3	init	0 achnlco4	init	0 achnlco5	init	0 achnlco6	init	0 achnlco7	init	0 achnlco8	init	0 achnlco9	init	0 achnlco10	init	0 achnlco11	init	0 achnlco12	init	0if	ieqshift =  1	   	goto 	dodec1controlled;			w		x		y		z; Speaker 1 <0.0000,0.0000,1.0000>achnlsh1 	sum	aw * 0.1179,				az * 0.2500; Speaker 2 <0.0000,0.0000,-1.0000>achnlsh2 	sum	aw * 0.1179,				az * -0.2500; Speaker 3 <0.7236,0.5257,0.4472>achnlsh3 	sum	aw *0.1179,	ax *0.1809,	ay *0.1314,	az * 0.1118; Speaker 4 <-0.7236,-0.5257,-0.4472>achnlsh4 	sum	aw *0.1179,	ax *-0.1809, ay *-0.1314, az * -0.1118; Speaker 5 <0.7236,-0.5257,0.4472>achnlsh5 	sum	aw *0.1179,	ax *0.1809,	ay *-0.1314, az * 0.1118; Speaker 6 <-0.7236,0.5257,-0.4472>achnlsh6 	sum	aw *0.1179,	ax *-0.1809, ay *0.1314, az * -0.1118; Speaker 7 <-0.2764,0.8507,0.4472>achnlsh7 	sum	aw *0.1179,	ax *-0.0691, ay *0.2127, az * 0.1118; Speaker 8 <0.2764,-0.8507,-0.4472>achnlsh8 	sum	aw *0.1179,	ax * 0.0691, ay *-0.2127, az * -0.1118; Speaker 9 <-0.2764,-0.8507,0.4472>achnlsh9 	sum	aw *0.1179,	ax *-0.0691, ay *-0.2127, az * 0.1118; Speaker 10 <0.2764,0.8507,-0.4472>achnlsh10 	sum	aw *0.1179,	ax *0.0691,	ay *0.2127,	az * -0.1118; Speaker 11 <-0.8944,0.0000,0.4472>achnlsh11 	sum	aw *0.1179,	ax * -0.2236,		az * 0.1118; Speaker 12 <0.8944,0.0000,-0.4472>achnlsh12 	sum	aw *0.1179,	ax * 0.2236,		az * -0.1118if	ieqshift =  0	   	goto 	dodec1mixdodec1controlled:;Rig `Controlled Opposites' Decode Matrix (First Order);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; Speaker 1 <0.0000,0.0000,1.0000>achnlco1 	sum	aw * 0.1179,				az * 0.0833                                                                  ; Speaker 2 <0.0000,0.0000,-1.0000>achnlco2 	sum	aw * 0.1179,				az * -0.0833; Speaker 3 <0.7236,0.5257,0.4472>achnlco3 	sum	aw *0.1179,	ax *0.0603,	ay *0.0438,	az * 0.0373; Speaker 4 <-0.7236,-0.5257,-0.4472>achnlco4	sum	aw *0.1179,	ax *-0.0603, ay *-0.0438, az * -0.0373; Speaker 5 <0.7236,-0.5257,0.4472>achnlco5 	sum	aw *0.1179,	ax *0.0603,	ay *-0.0438,az * 0.0373; Speaker 6 <-0.7236,0.5257,-0.4472>achnlco6 	sum	aw *0.1179,	ax *-0.0603, ay *0.0438, az * -0.0373; Speaker 7 <-0.2764,0.8507,0.4472>achnlco7 	sum	aw *0.1179,	ax *-0.0230, ay *0.0709, az * 0.0373; Speaker 8 <0.2764,-0.8507,-0.4472>achnlco8 	sum	aw *0.1179,	ax *0.0230,	ay *-0.0709,az * -0.0373; Speaker 9 <-0.2764,-0.8507,0.4472>achnlco9	sum	aw *0.1179,	ax *-0.0230, ay *-0.0709,az * 0.0373; Speaker 10 <0.2764,0.8507,-0.4472>achnlco10 	sum	aw *0.1179,	ax *0.0230,	ay *0.0709,	az * -0.0373; Speaker 11 <-0.8944,0.0000,0.4472>achnlco11 	sum	aw *0.1179,	ax * -0.0745,		az * 0.0373; Speaker 12 <0.8944,0.0000,-0.4472>achnlco12	sum	aw *0.1179,	ax * 0.0745,		az * -0.0373dodec1mix:achnl1	sum 	achnlco1 * ieqshift, achnlsh1 * 1 - ieqshiftachnl2	sum 	achnlco2 * ieqshift, achnlsh2 * 1 - ieqshiftachnl3	sum 	achnlco3 * ieqshift, achnlsh3 * 1 - ieqshiftachnl4	sum 	achnlco4 * ieqshift, achnlsh4 * 1 - ieqshiftachnl5	sum 	achnlco5 * ieqshift, achnlsh5 * 1 - ieqshiftachnl6	sum 	achnlco6 * ieqshift, achnlsh6 * 1 - ieqshiftachnl7	sum 	achnlco7 * ieqshift, achnlsh7 * 1 - ieqshiftachnl8	sum 	achnlco8 * ieqshift, achnlsh8 * 1 - ieqshiftachnl9	sum 	achnlco9 * ieqshift, achnlsh9 * 1 - ieqshiftachnl10	sum 	achnlco10 * ieqshift, achnlsh10 * 1 - ieqshiftachnl11	sum 	achnlco11 * ieqshift, achnlsh11 * 1 - ieqshiftachnl12	sum 	achnlco12 * ieqshift, achnlsh12 * 1 - ieqshift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; soundout	 achnl1, "ambisonics,dec1",4; soundout	 achnl2, "ambisonics,dec2",4; soundout	 achnl3, "ambisonics,dec3",4; soundout	 achnl4, "ambisonics,dec4",4; soundout	 achnl5, "ambisonics,dec5",4; soundout	 achnl6, "ambisonics,dec6",4; soundout	 achnl7, "ambisonics,dec7",4; soundout	 achnl8, "ambisonics,dec8",4; soundout	 achnl9, "ambisonics,dec9",4; soundout	 achnl10, "ambisonics,dec10",4; soundout	 achnl11, "ambisonics,dec11",4; soundout	 achnl12, "ambisonics,dec12",4fout 	"ambisonic-do1dec1", 2,  achnl1fout 	"ambisonic-do1dec2", 2,  achnl2fout 	"ambisonic-do1dec3", 2,  achnl3fout 	"ambisonic-do1dec4", 2,  achnl4fout 	"ambisonic-do1dec5", 2,  achnl5fout 	"ambisonic-do1dec6", 2,  achnl6fout 	"ambisonic-do1dec7", 2,  achnl7fout 	"ambisonic-do1dec8", 2,  achnl8fout 	"ambisonic-do1dec9", 2,  achnl9fout 	"ambisonic-do1dec10", 2,  achnl10fout 	"ambisonic-do1dec11", 2,  achnl11fout 	"ambisonic-do1dec12", 2,  achnl12goto	skipend;	******************************************************************************************************************************dodecahedron2:			;	******************************************************************************************************************************;	Rig Decode Matrix to Reproduce Spherical Harmonics (First Order);	This rig configuration produces a strict idealised response that satisfies the Ambisonic matching equations.;	Generally this type of configuration produces a relatively small stable listening area. (See controlled opposites below.)   achnlsh1	init	0 achnlsh2	init	0 achnlsh3	init	0 achnlsh4	init	0 achnlsh5	init	0 achnlsh6	init	0 achnlsh7	init	0 achnlsh8	init	0 achnlsh9	init	0 achnlsh10	init	0 achnlsh11	init	0 achnlsh12	init	0 achnlco1	init	0 achnlco2	init	0 achnlco3	init	0 achnlco4	init	0 achnlco5	init	0 achnlco6	init	0 achnlco7	init	0 achnlco8	init	0 achnlco9	init	0 achnlco10	init	0 achnlco11	init	0 achnlco12	init	0if	ieqshift =  1	   	goto 	dodec2controlled;			w		x		y		z; Speaker 1 <0.0000,0.0000,1.0000>achnlsh1 	sum	aw *0.1179,	ax * 0.2500; Speaker 2 <-1.0000,0.0000,0.0000>achnlsh2 	sum	aw *0.1179,	ax * -0.2500; Speaker 3 <0.4472,0.0000,-0.8944>achnlsh3 	sum	aw *0.1179,	ax * 0.1118,		az * -0.2236; Speaker 4 <-0.4472,0.0000,0.8944>achnlsh4 	sum	aw *0.1179,	ax * -0.1118,		az * 0.2236; Speaker 5 <0.4472,0.8507,-0.2764>achnlsh5 	sum	aw *0.1179,	ax *0.1118,	ay *0.2127,	az * -0.0691; Speaker 6 <-0.4472,-0.8507,0.2764>achnlsh6 	sum	aw *0.1179, ax *-0.1118, ay *-0.2127, az * 0.0691; Speaker 7 <0.4472,-0.8507,-0.2764>achnlsh7 	sum	aw *0.1179,	ax *0.1118,	ay *-0.2127, az * -0.0691; Speaker 8 <-0.4472,0.8507,0.2764>achnlsh8 	sum	aw *0.1179,	ax *-0.1118, ay *0.2127, az * 0.0691; Speaker 9 <0.4472,0.5257,0.7236>achnlsh9 	sum	aw *0.1179,	ax *0.1118,	ay *0.1314,	az * 0.1809; Speaker 10 <-0.4472,-0.5257,-0.7236>achnlsh10 	sum	aw *0.1179,	ax *-0.1118, ay *-0.1314, az *-0.1809; Speaker 11 <0.4472,-0.5257,0.7236>achnlsh11 	sum	aw *0.1179,	ax *0.1118, ay * -0.1314, az * 0.1809; Speaker 12 <-0.4472,0.5257,-0.7236>achnlsh12 	sum	aw *0.1179,	ax *-0.1118, ay *0.1314, az * -0.1809if	ieqshift =  0	   	goto 	dodec2mixdodec2controlled:;	Rig `Controlled Opposites' Decode Matrix (First Order);	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; Speaker 1 <1.0000,0.0000,0.0000>achnlco1 	sum	aw *0.1179,	ax * 0.0833; Speaker 2 <-1.0000,0.0000,0.0000>achnlco2 	sum	aw *0.1179,	ax * -0.0833; Speaker 3 <0.4472,0.0000,-0.8944>achnlco3 	sum	aw *0.1179,	ax * 0.0373,		az * -0.0745; Speaker 4 <-0.4472,0.0000,0.8944>achnlco4 	sum	aw *0.1179,	ax * -0.0373,		az * 0.0745; Speaker 5 <0.4472,0.8507,-0.2764>achnlco5 	sum	aw *0.1179, ax *0.0373,	ay *0.0709,	az * -0.0230; Speaker 6 <-0.4472,-0.8507,0.2764>achnlco6 	sum	aw *0.1179,	ax *-0.0373, ay *-0.0709, az * 0.0230; Speaker 7 <0.4472,-0.8507,-0.2764>achnlco7 	sum	aw *0.1179,	ax *0.0373,	ay *-0.0709, az * -0.0230; Speaker 8 <-0.4472,0.8507,0.2764>achnlco8 	sum	aw *0.1179,	ax *-0.0373, ay *0.0709, az * 0.0230; Speaker 9 <0.4472,0.5257,0.7236>achnlco9 	sum	aw *0.1179,	ax *0.0373,	ay *0.0438,	az * 0.0603; Speaker 10 <-0.4472,-0.5257,-0.7236>achnlco10 	sum	aw *0.1179,	ax *-0.0373, ay *-0.0438, az * -0.0603; Speaker 11 <0.4472,-0.5257,0.7236>achnlco11 	sum	aw *0.1179,	ax *0.0373, ay *-0.0438, az * 0.0603; Speaker 12 <-0.4472,0.5257,-0.7236>achnlco12 	sum	aw *0.1179,	ax *-0.0373, ay *0.0438, az * -0.0603dodec2mix:achnl1	sum 	achnlco1 * ieqshift, achnlsh1 * 1 - ieqshiftachnl2	sum 	achnlco2 * ieqshift, achnlsh2 * 1 - ieqshiftachnl3	sum 	achnlco3 * ieqshift, achnlsh3 * 1 - ieqshiftachnl4	sum 	achnlco4 * ieqshift, achnlsh4 * 1 - ieqshiftachnl5	sum 	achnlco5 * ieqshift, achnlsh5 * 1 - ieqshiftachnl6	sum 	achnlco6 * ieqshift, achnlsh6 * 1 - ieqshiftachnl7	sum 	achnlco7 * ieqshift, achnlsh7 * 1 - ieqshiftachnl8	sum 	achnlco8 * ieqshift, achnlsh8 * 1 - ieqshiftachnl9	sum 	achnlco9 * ieqshift, achnlsh9 * 1 - ieqshiftachnl10	sum 	achnlco10 * ieqshift, achnlsh10 * 1 - ieqshiftachnl11	sum 	achnlco11 * ieqshift, achnlsh11 * 1 - ieqshiftachnl12	sum 	achnlco12 * ieqshift, achnlsh12 * 1 - ieqshift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; soundout	 achnl1, "ambisonics,dec1",4; soundout	 achnl2, "ambisonics,dec2",4; soundout	 achnl3, "ambisonics,dec3",4; soundout	 achnl4, "ambisonics,dec4",4; soundout	 achnl5, "ambisonics,dec5",4; soundout	 achnl6, "ambisonics,dec6",4; soundout	 achnl7, "ambisonics,dec7",4; soundout	 achnl8, "ambisonics,dec8",4; soundout	 achnl9, "ambisonics,dec9",4; soundout	 achnl10, "ambisonics,dec10",4; soundout	 achnl11, "ambisonics,dec11",4; soundout	 achnl12, "ambisonics,dec12",4fout 	"ambisonic-do2dec1", 2,  achnl1fout 	"ambisonic-do2dec2", 2,  achnl2fout 	"ambisonic-do2dec3", 2,  achnl3fout 	"ambisonic-do2dec4", 2,  achnl4fout 	"ambisonic-do2dec5", 2,  achnl5fout 	"ambisonic-do2dec6", 2,  achnl6fout 	"ambisonic-do2dec7", 2,  achnl7fout 	"ambisonic-do2dec8", 2,  achnl8fout 	"ambisonic-do2dec9", 2,  achnl9fout 	"ambisonic-do2dec10", 2,  achnl10fout 	"ambisonic-do2dec11", 2,  achnl11fout 	"ambisonic-do2dec12", 2,  achnl12skipend:endin</CsInstruments><CsScore>/*instr 81     9-CHNL DECODING UNIT, 2nd ORDER AMBISONICS  */		i81	0	35	1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  */</CsScore></CsoundSynthesizer><MacOptions>Version: 3Render: RealAsk: YesFunctions: WindowWindowBounds: 31 70 990 722Options: -b128 -A -s -m7 -R </MacOptions><MacGUI>ioView nobackground {65535, 65535, 65535}
ioListing {10, 10} {400, 500}</MacGUI>