js: js: no function gettype [.js]


    Jul 30 2017 | 9:15 pm
    Getting a weird error even though the script works as expected:
    js: js: no function gettype [scriptname.js]
    Any ideas?

    • Jul 30 2017 | 9:34 pm
      link to code: http://codepad.org/5qFF1I89
    • Jul 31 2017 | 5:12 pm
      anyone any ideas?
    • Jul 31 2017 | 5:34 pm
      You don't have a gettype() function defined anywhere in the JS...is your patch sending a gettype message somewhere?
    • Aug 01 2017 | 5:27 pm
      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);
      }
    • Aug 01 2017 | 5:31 pm
      I should note this is a script in a Max for Live device and it works exactly as expected.
    • Aug 02 2017 | 5:48 pm
      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.
    • Aug 03 2017 | 3:32 pm
      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);
      }