js: js: no function gettype [.js]
Getting a weird error even though the script works as expected:
js: js: no function gettype [scriptname.js]
Any ideas?
link to code: http://codepad.org/5qFF1I89
anyone any ideas?
You don't have a gettype() function defined anywhere in the JS...is your patch sending a gettype message somewhere?
Entire script is as follows:
inlets = 1;
outlets = 1;
var x = 0;
Math.log2 = Math.log2 || function(x){return Math.log(x)*Math.LOG2E;};
function msg_float(v)
{
x = (v > 0 ? ((Math.log2(v) - Math.log2(10)) / (Math.log2(2000) - Math.log2(10))) : 0);
outlet(0, x);
}
I should note this is a script in a Max for Live device and it works exactly as expected.
JS throws that error when it is sent a message for which there is no corresponding function defined. Something in your device is sending a message "gettype" to your js object, and your script has no gettype() function.
Of course that makes sense but it isn't the case. I resolved this issue by replacing the polyfill:
inlets = 1;
outlets = 1;
function log2(x){ return Math.log(x)*Math.LOG2E;}
function msg_float(v)
{
var x = 0;
x = (v > 0 ? ((log2(v) - log2(10)) / (log2(2000) - log2(10))) : 0);
outlet(0, x);
}