Trouble with setTimeout in javascript for MaxMSP -


i've looked @ quite few other questions can't seem fix issue settimeout

so i've been working on , came this, reason settimeout not work, tips?

function curves(val_name, mini, maxi, t_amount, steps) {     //t_amount must in ms     (x = 0; x < steps; x++) {         var x_mod = scale(x, -6, 0, 0, steps);         var value = settimeout(calculate_curve, (t_amount / steps), x_mod);          switch (val_name) {             case "vol_stretch1":                 var vol_stretch1 = this.patcher.getnamed("stretching").subpatcher(0).getnamed("vol_stretch1");                 vol_stretch1 = value                 break;             case "vol_stretch2":                 var vol_stretch2 = this.patcher.getnamed("stretching").subpatcher(0).getnamed("vol_stretch2");                 vol_stretch2 = value                 break;             case "vol_stretch3":                 var vol_stretch3 = this.patcher.getnamed("stretching").subpatcher(0).getnamed("vol_stretch3");                 vol_stretch3 = value                 break;         }     } }  function calculate_curve(x) {     var constant_e = 2.718281828459;     var result = (1 / 1 + (constant_e ^ (x * -1))) * -1; //sigmoid function * -1 have nice rise }  function scale(unscalednum, minallowed, maxallowed, minimum, maximum) {     return (maxallowed - minallowed) * (unscalednum - minimum) / (maximum - minimum) + minallowed; } 

you can ignore switch works extension maxmsp isn't important here. error "javascript referenceerror: settimeout not defined". appreciated!

i've not worked max before, small amount of searching looks you're writing along lines of plugin.

it looks max running it's own javascript environment of sort. settimeout method on window object of browsers in javascript, , such not implemented in javascript outside of browser, max appears be.

the recommended alternative seems to use task object exposed environment, has documentation here: https://docs.cycling74.com/max5/vignettes/js/jstaskobject.html

i have no way of testing this, documentation looks along lines of below should work:

var task = new task(function() {     calculate_curve(x_mod); }, this); task.schedule((t_amount / steps)); 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -