Forums > Javascript

jit.map in JS

July 19, 2010 | 8:25 pm

Hi,

I’m trying to figure out how to use [jit.map] with JS without success.
The code below works but
var mapper = new JitterObject("jit.map");
seems blind for the code.

inlets = 1;
outlets = 1;
autowatch = 1;

// création jit.noise, jit.matrix, jit,map
var noiser = new JitterObject("jit.noise");
noiser.dim = 1;
noiser.planecount = 1;
noiser.type = "float32";

var mtrx = new JitterMatrix(1, "float32", 1);

var mapper = new JitterObject("jit.map");
mapper.dim = 1;
mapper.planecount = 1;
mapper.type = "float32";
mapper.map = (0., 1., 5., 10.);

// ce code est exécuté 1 fois au lancement du patch
function loadbang()
{
init();
post("jit.noise bangé n");
}

//fonction appelée par la fonction loadbang
function init()
{
// generate a random matrix between -1 and 1
noiser.matrixcalc(mtrx, mtrx);

//mtrx.op("*", 2.0);
//mtrx.op("-", 1.0);
}

function bang()
{
mapper.matrixcalc(mtrx,mtrx);
outlet(0, "jit_matrix", mtrx.name);
}

_____________patcher_____________

– Pasted Max Patch, click to expand. –
Attachments:
  1. matrixcalc-base.js

July 20, 2010 | 1:26 pm

What I understand is that there is no jitmap in JS.
So I’m using jitexpr and go this way:

inlets = 1;
outlets = 1;
autowatch = 1;

var mtrx = new JitterMatrix(1, "float32", 1);
var outmtrx = new JitterMatrix(1, "float32", 1);

function initValue(a)
{
allValue = a;
mtrx.setall(allValue);

var myexpr = new JitterObject("jit.expr");
myexpr.expr = "in[0]* 5. + 5.";

function bang()
{
myexpr.matrixcalc(mtrx, outmtrx);
outlet(0, "jit_matrix", outmtrx.name);
}


Viewing 2 posts - 1 through 2 (of 2 total)