Created
September 13, 2016 18:59
-
-
Save joslloand/c70745ef0106afded73e1ea07ff69afc 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
// Icosahedron | |
// see: | |
"http://neilsloane.com/sphdesigns/dim3/des.3.12.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_a12_decoder_matrix, soa_a12_encoder_matrix; | |
// a-12 decoder matrix | |
soa_a12_decoder_matrix = Matrix.with([ | |
[ 0.11785113, 0.212662702, 0, -0.131432778, -0.0355875819, -0.279508497, 0, 0.226127124, 0 ], | |
[ 0.11785113, 0.131432778, -0.212662702, 0, -0.208333333, 0, 0, -0.139754249, -0.279508497 ], | |
[ 0.11785113, 0, -0.131432778, 0.212662702, 0.243920915, 0, -0.279508497, -0.0863728757, 0 ], | |
[ 0.11785113, 0.212662702, 0, 0.131432778, -0.0355875819, 0.279508497, 0, 0.226127124, 0 ], | |
[ 0.11785113, -0.131432778, -0.212662702, 0, -0.208333333, 0, 0, -0.139754249, 0.279508497 ], | |
[ 0.11785113, 0, 0.131432778, -0.212662702, 0.243920915, 0, -0.279508497, -0.0863728757, 0 ], | |
[ 0.11785113, -0.212662702, 0, -0.131432778, -0.0355875819, 0.279508497, 0, 0.226127124, 0 ], | |
[ 0.11785113, -0.131432778, 0.212662702, 0, -0.208333333, 0, 0, -0.139754249, -0.279508497 ], | |
[ 0.11785113, 0, 0.131432778, 0.212662702, 0.243920915, 0, 0.279508497, -0.0863728757, 0 ], | |
[ 0.11785113, -0.212662702, 0, 0.131432778, -0.0355875819, -0.279508497, 0, 0.226127124, 0 ], | |
[ 0.11785113, 0.131432778, 0.212662702, 0, -0.208333333, 0, 0, -0.139754249, 0.279508497 ], | |
[ 0.11785113, 0, -0.131432778, -0.212662702, 0.243920915, 0, 0.279508497, -0.0863728757, 0 ], | |
]); | |
// a-12 encoder matrix | |
soa_a12_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.850650808, 0.525731112, 0, 0.850650808, -0.525731112, 0, -0.850650808, -0.525731112, 0, -0.850650808, 0.525731112, 0 ], | |
[ 0, -0.850650808, -0.525731112, 0, -0.850650808, 0.525731112, 0, 0.850650808, 0.525731112, 0, 0.850650808, -0.525731112 ], | |
[ -0.525731112, 0, 0.850650808, 0.525731112, 0, -0.850650808, -0.525731112, 0, 0.850650808, 0.525731112, 0, -0.850650808 ], | |
[ -0.0854101966, -0.5, 0.585410197, -0.0854101966, -0.5, 0.585410197, -0.0854101966, -0.5, 0.585410197, -0.0854101966, -0.5, 0.585410197 ], | |
[ -0.894427191, 0, 0, 0.894427191, 0, 0, 0.894427191, 0, 0, -0.894427191, 0, 0 ], | |
[ 0, 0, -0.894427191, 0, 0, -0.894427191, 0, 0, 0.894427191, 0, 0, 0.894427191 ], | |
[ 0.723606798, -0.447213596, -0.276393202, 0.723606798, -0.447213596, -0.276393202, 0.723606798, -0.447213596, -0.276393202, 0.723606798, -0.447213596, -0.276393202 ], | |
[ 0, -0.894427191, 0, 0, 0.894427191, 0, 0, -0.894427191, 0, 0, 0.894427191, 0 ], | |
]); | |
// -- test... should return identity matrix | |
soa_a12_encoder_matrix.mulMatrix(soa_a12_decoder_matrix) | |
) | |
/* | |
1st-order FuMa-MaxN A-format decoder | |
*/ | |
( | |
var cart, spher, foa_a12_decoder_matrix; | |
// directions | |
// the original coordinates, in cartesian | |
cart = [ | |
0.850650808352E+00, | |
0, | |
-0.525731112119E+00, | |
0.525731112119E+00, | |
-0.850650808352E+00, | |
0.000000000000E+00, | |
0, | |
-0.525731112119E+00, | |
0.850650808352E+00, | |
0.850650808352E+00, | |
0, | |
0.525731112119E+00, | |
-0.525731112119E+00, | |
-0.850650808352E+00, | |
0, | |
0, | |
0.525731112119E+00, | |
-0.850650808352E+00, | |
-0.850650808352E+00, | |
0, | |
-0.525731112119E+00, | |
-0.525731112119E+00, | |
0.850650808352E+00, | |
0, | |
0, | |
0.525731112119E+00, | |
0.850650808352E+00, | |
-0.850650808352E+00, | |
0, | |
0.525731112119E+00, | |
0.525731112119E+00, | |
0.850650808352E+00, | |
0, | |
0, | |
-0.525731112119E+00, | |
-0.850650808352E+00 | |
]; | |
// 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_a12_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