Last active
September 13, 2016 19:13
-
-
Save joslloand/dab7e9974d463df366e54dd5f32a17d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dodecahedron | |
// see: | |
"http://neilsloane.com/sphdesigns/dim3/des.3.20.5.txt".openOS | |
// Matrix Author: Ambisonic Toolkit | |
// --J Anderson | |
"http://www.ambisonictoolkit.net".openOS | |
/* | |
2nd-order FuMa-MaxN A-format decoder & encoder | |
Use in conjunction with AtkMatrixMix*ar | |
*/ | |
( | |
var soa_a20_decoder_matrix, soa_a20_encoder_matrix; | |
// a-20 decoder matrix | |
soa_a20_decoder_matrix = Matrix.with([ | |
[ 0.0707106781, 0.0866025404, 0.0866025404, 0.0866025404, 0, 0.125, 0.125, 0, 0.125 ], | |
[ 0.0707106781, 0.0866025404, 0.0866025404, -0.0866025404, 0, -0.125, -0.125, 0, 0.125 ], | |
[ 0.0707106781, 0.0866025404, -0.0866025404, 0.0866025404, 0, 0.125, -0.125, 0, -0.125 ], | |
[ 0.0707106781, -0.0866025404, 0.0866025404, 0.0866025404, 0, -0.125, 0.125, 0, -0.125 ], | |
[ 0.0707106781, 0.0866025404, -0.0866025404, -0.0866025404, 0, -0.125, 0.125, 0, -0.125 ], | |
[ 0.0707106781, -0.0866025404, 0.0866025404, -0.0866025404, 0, 0.125, -0.125, 0, -0.125 ], | |
[ 0.0707106781, -0.0866025404, -0.0866025404, 0.0866025404, 0, -0.125, -0.125, 0, 0.125 ], | |
[ 0.0707106781, -0.0866025404, -0.0866025404, -0.0866025404, 0, 0.125, 0.125, 0, 0.125 ], | |
[ 0.0707106781, 0, 0.0535233135, 0.140125854, 0.202254249, 0, 0.125, -0.0238728757, 0 ], | |
[ 0.0707106781, 0, -0.0535233135, 0.140125854, 0.202254249, 0, -0.125, -0.0238728757, 0 ], | |
[ 0.0707106781, 0, 0.0535233135, -0.140125854, 0.202254249, 0, -0.125, -0.0238728757, 0 ], | |
[ 0.0707106781, 0, -0.0535233135, -0.140125854, 0.202254249, 0, 0.125, -0.0238728757, 0 ], | |
[ 0.0707106781, 0.140125854, 0, 0.0535233135, -0.0772542486, 0.125, 0, 0.163627124, 0 ], | |
[ 0.0707106781, 0.140125854, 0, -0.0535233135, -0.0772542486, -0.125, 0, 0.163627124, 0 ], | |
[ 0.0707106781, -0.140125854, 0, 0.0535233135, -0.0772542486, -0.125, 0, 0.163627124, 0 ], | |
[ 0.0707106781, -0.140125854, 0, -0.0535233135, -0.0772542486, 0.125, 0, 0.163627124, 0 ], | |
[ 0.0707106781, 0.0535233135, 0.140125854, 0, -0.125, 0, 0, -0.139754249, 0.125 ], | |
[ 0.0707106781, -0.0535233135, 0.140125854, 0, -0.125, 0, 0, -0.139754249, -0.125 ], | |
[ 0.0707106781, 0.0535233135, -0.140125854, 0, -0.125, 0, 0, -0.139754249, -0.125 ], | |
[ 0.0707106781, -0.0535233135, -0.140125854, 0, -0.125, 0, 0, -0.139754249, 0.125 ],]); | |
// a-20 encoder matrix | |
soa_a20_encoder_matrix = Matrix.with([ | |
[ 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781, 0.707106781 ], | |
[ 0.577350269, 0.577350269, 0.577350269, -0.577350269, 0.577350269, -0.577350269, -0.577350269, -0.577350269, 0, 0, 0, 0, 0.934172359, 0.934172359, -0.934172359, -0.934172359, 0.35682209, -0.35682209, 0.35682209, -0.35682209 ], | |
[ 0.577350269, 0.577350269, -0.577350269, 0.577350269, -0.577350269, 0.577350269, -0.577350269, -0.577350269, 0.35682209, -0.35682209, 0.35682209, -0.35682209, 0, 0, 0, 0, 0.934172359, 0.934172359, -0.934172359, -0.934172359 ], | |
[ 0.577350269, -0.577350269, 0.577350269, 0.577350269, -0.577350269, -0.577350269, 0.577350269, -0.577350269, 0.934172359, 0.934172359, -0.934172359, -0.934172359, 0.35682209, -0.35682209, 0.35682209, -0.35682209, 0, 0, 0, 0 ], | |
[ 0, 0, 0, 0, 0, 0, 0, 0, 0.809016994, 0.809016994, 0.809016994, 0.809016994, -0.309016994, -0.309016994, -0.309016994, -0.309016994, -0.5, -0.5, -0.5, -0.5 ], | |
[ 0.666666667, -0.666666667, 0.666666667, -0.666666667, -0.666666667, 0.666666667, -0.666666667, 0.666666667, 0, 0, 0, 0, 0.666666667, -0.666666667, -0.666666667, 0.666666667, 0, 0, 0, 0 ], | |
[ 0.666666667, -0.666666667, -0.666666667, 0.666666667, 0.666666667, -0.666666667, -0.666666667, 0.666666667, 0.666666667, -0.666666667, -0.666666667, 0.666666667, 0, 0, 0, 0, 0, 0, 0, 0 ], | |
[ 0, 0, 0, 0, 0, 0, 0, 0, -0.127322004, -0.127322004, -0.127322004, -0.127322004, 0.872677996, 0.872677996, 0.872677996, 0.872677996, -0.745355992, -0.745355992, -0.745355992, -0.745355992 ], | |
[ 0.666666667, 0.666666667, -0.666666667, -0.666666667, -0.666666667, -0.666666667, 0.666666667, 0.666666667, 0, 0, 0, 0, 0, 0, 0, 0, 0.666666667, -0.666666667, -0.666666667, 0.666666667 ],]); | |
// -- test... should return identity matrix | |
soa_a20_encoder_matrix.mulMatrix(soa_a20_decoder_matrix) | |
) | |
/* | |
1st-order FuMa-MaxN A-format decoder | |
*/ | |
( | |
var cart, spher, foa_a20_decoder_matrix; | |
// directions | |
// the original coordinates, in cartesian | |
cart = [ | |
0.57735026918962576449, | |
0.57735026918962576449, | |
0.57735026918962576449, | |
0.57735026918962576449, | |
0.57735026918962576449, | |
-0.57735026918962576449, | |
0.57735026918962576449, | |
-0.57735026918962576449, | |
0.57735026918962576449, | |
-0.57735026918962576449, | |
0.57735026918962576449, | |
0.57735026918962576449, | |
0.57735026918962576449, | |
-0.57735026918962576449, | |
-0.57735026918962576449, | |
-0.57735026918962576449, | |
0.57735026918962576449, | |
-0.57735026918962576449, | |
-0.57735026918962576449, | |
-0.57735026918962576449, | |
0.57735026918962576449, | |
-0.57735026918962576449, | |
-0.57735026918962576449, | |
-0.57735026918962576449, | |
0, | |
0.356822089773089932, | |
0.934172358962715698, | |
0, | |
-0.356822089773089932, | |
0.934172358962715698, | |
0, | |
0.356822089773089932, | |
-0.934172358962715698, | |
0, | |
-0.356822089773089932, | |
-0.934172358962715698, | |
0.934172358962715698, | |
0, | |
0.356822089773089932, | |
0.934172358962715698, | |
0, | |
-0.356822089773089932, | |
-0.934172358962715698, | |
0, | |
0.356822089773089932, | |
-0.934172358962715698, | |
0, | |
-0.356822089773089932, | |
0.356822089773089932, | |
0.934172358962715698, | |
0, | |
-0.356822089773089932, | |
0.934172358962715698, | |
0, | |
0.356822089773089932, | |
-0.934172358962715698, | |
0, | |
-0.356822089773089932, | |
-0.934172358962715698, | |
0, | |
]; | |
// convert to angles -- use these directions | |
spher = cart.clump(3).collect({ arg cart, i; | |
cart.asCartesian.asSpherical.angles; | |
}); | |
// make a 1st-order decoder matrix | |
foa_a20_decoder_matrix = FoaEncoderMatrix.newDirections(spher).matrix.pseudoInverse; | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment