Skip to content

Commit

Permalink
ATK: FIX for requirement to include MathLib Quark for sc3-plugins
Browse files Browse the repository at this point in the history
Contribution by @mtmccrea to resolve issue discussed:

#124
#125
http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabbl
e.com/Fwd-sc-users-Re-SC3-plugins-missed-class-td7628763.html

At the moment, it appears the long term solution will be to move all
the language side elements of the ATK to a separate Quark. (The ATK
team has been considering this option.) In the short term, this current
solution removes the dependency on users installing MathLib when
installing sc3-plugins.
  • Loading branch information
joslloand committed Nov 8, 2016
1 parent 0dcf7e2 commit 692f92f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 34 deletions.
38 changes: 31 additions & 7 deletions source/ATK/sc/Classes/ATKMatrix.sc
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,49 @@ FoaSpeakerMatrix {
}

AtkMatrix {
var <kind; // copyArgs
// copyArgs
var <kind, <set = 'FOA', <type; // NOTE: 'set' default will change with addition of HOA

var <matrix;
var <filePath; // matrices from files only
var <fileParse; // data parsed from YAML file
var <op = 'matrix';
var <set = 'FOA'; // ... for now

// most typically called by subclass
*new { |mtxKind|
^super.newCopyArgs(mtxKind)
// *new { |mtxKind, set, mtxType|
*new { |kind, set, type|
^super.newCopyArgs(kind).init(set, type)
}

init { |argSet, argType|
if (argSet.notNil) {
set = argSet
} { // detect from class
if (this.class.asString.keep(3) == "Foa") {
set = 'FOA';
}
};
if (argType.notNil) {
type = argType
} { // detect from class
type = switch( this.class,
FoaEncoderMatrix, {'encoder'},
FoaEncoderKernel, {'encoder'},
FoaDecoderMatrix, {'decoder'},
FoaDecoderKernel, {'decoder'},
FoaXformerMatrix, {'xformer'}
);
};
}

// used when writing a Matrix to file:
// need to convert to AtkMatrix first
*newFromMatrix { |aMatrix|
^super.newCopyArgs('fromMatrix').initFromMatrix(aMatrix)
*newFromMatrix { |aMatrix, set, type|
^super.newCopyArgs('fromMatrix').initFromMatrix(aMatrix, set, type)
}

initFromMatrix { |aMatrix|
initFromMatrix { |aMatrix, argSet, argType|
this.init(argSet, argType);
matrix = aMatrix;
}

Expand Down
13 changes: 13 additions & 0 deletions source/ATK/sc/Classes/extArray.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
+ Array {

// set: FOA, HOA1, HOA2, etc.
// type: \encoder, \decoder, \xformer
// NOTE: set and type aren't currently enforced, but it's a
// good idea to provide it for writing to file
asAtkMatrix { arg set, type;
var mtx;
mtx = Matrix.with(this.asArray);
^AtkMatrix.newFromMatrix(mtx, set, type);
}

}
16 changes: 0 additions & 16 deletions source/ATK/sc/Classes/extMatrix.sc

This file was deleted.

14 changes: 13 additions & 1 deletion source/ATK/sc/HelpSource/Classes/AtkMatrix.schelp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
TITLE:: AtkMatrix
summary:: A superclass to the Atk's various matrix classes.
categories:: Libraries>Ambisonic Toolkit>Internals
related:: Classes/FoaEncoderMatrix, Classes/FoaDecoderMatrix, Classes/FoaXformerMatrix, Classes/Matrix
related:: Classes/FoaEncoderMatrix, Classes/FoaDecoderMatrix, Classes/FoaXformerMatrix, Classes/Matrix, Guides/Guide-to-ATK-Matrix-Files

DESCRIPTION::
An AtkMatrix is not typically instantiated directly, but rather through one of its subclasses:
Expand All @@ -24,6 +24,18 @@ code::
Matrix.with([[row1],[row2],...[rowN]])
::

ARGUMENT:: set
code::'FOA', 'HOA1', 'HOA2', ... etc::.
Set describes both the signal set and the tool set, encompassing the Ambisonic order, as well as channel ordering and normalisation.

ARGUMENT:: type
code::'decoder', 'encoder', or 'xformer'::.

NOTE::
strong::set:: and strong::type:: will be required if the code::AtkMatrix:: will subsequently be written to a file.
::


INSTANCEMETHODS::

PRIVATE:: set, kind
Expand Down
21 changes: 11 additions & 10 deletions source/ATK/sc/HelpSource/Guides/Guide-to-ATK-Matrix-Files.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ the link::Classes/AtkMatrix:: subclasses. When writing from these objects, some
can be inferred from them, such as the strong::set:: (Ambisonic order,
channel ordering, channel normalisation, e.g. code::'FOA'::, code::'HOA3'::,
etc.) and strong::type:: of matrix (e.g. code::'encoder', 'decoder', 'xformer'::).
In the case of a raw matrix, this information can't be inferred and should be
explicitly set when writing to file.
In the case of a raw matrix, you must cast it to an code::AtkMatrix::, specifying the
strong::set:: and strong::type:: explicitly, before writing it to a file.

code::
( // Here's a raw A-to-B encoder matrix:
Expand Down Expand Up @@ -259,21 +259,22 @@ code::
)
::

Now be sure to list the proper info for the arguments when writing it to file. This is how the ATK will know where to store the file by default (unless a full path is provided to the file name argument).
Be sure to specify the strong::set:: and strong::type:: when creating an
code::AtkMatrix:: from your code::Matrix::. This is how the ATK will know where
to store the file by default (unless a full path is provided to the file name
argument).

code::
(
~matrix.writeToFile( "myA2B_flu_Matrix.yml", // be sure to use .yml for metadata
'FOA', // set
'encoder', // type
~note,
~properties
)
~atkMatrix = ~matrix.asAtkMatrix('FOA', 'encoder'); // set, type
// be sure to use .yml extension for metadata
~atkMatrix.writeToFile("myA2B_flu_Matrix.yml", ~note, ~properties);
)
::

NOTE:: If providing a file path relative to your code::/ATK/extension/matrices/...::
directory, strong::set:: and strong::type:: are necessary arguments to locate the
directory, strong::set:: and strong::type:: arguments are necessary when creating the
code::AtkMatrix:: from your code::Matrix:: in order to locate the
proper directory to store your file. If providing an absolute file path,
strong::set:: and strong::type:: are recommended but not strictly enforced. This
allows storing matrices outside the ATK paradigm, e.g. VBAP matrices, etc.
Expand Down

0 comments on commit 692f92f

Please sign in to comment.