loading matrix file from js

jgastonraoul's icon

load_matrix_js.maxpat
Max Patch

load_matrix_js.js
application/x-javascript 0.26 KB

160.jxf.txt
text/plain 0.45 KB

Hi,

Every time I try to load matrix files in js, I get an error "jit.matrix: can't find file ..." although I have no problem loading the same file directly via read message.
I've attached a patcher and a js file for you to test. Just put the matrix file attached somewhere outside of Max path or patcher path (if there is a file with the same name in Max path, Max loads it instead of the one I'm asking for), open it via the "opendialog" object and trigger the 2 messages below to compare the 2 cases.
I think this is a bug and already reported it to Cycling '74 support, but I'd like to know if I'm missing something or if there is a workaround.

Regards,

Jérémie

PS : I've added a txt extension to the matrix file to be able to upload it to the forum but it's a binary matrix file.

Federico-AmazingMaxStuff's icon

Answered on Discord, JS file should be written like this:

autowatch = 1;
var myMat = new JitterMatrix();
function loadMatrix(path) {     
myMat.read(path);
outlet(0, "jit_matrix", myMat.name);
}
function notifydeleted() { myMat.freepeer(); }