Math.log2()

redhexagonal's icon

I need to convert list of frequencies to midi values, so i have
var freqList;
    function anything()
{
    var freqList = arrayfromargs(arguments);
    var freqList = freqList.map(function(element) {
    return 69 + 12 * Math.log2(element / 440);
    });
    outlet(0,freqList);
}

but Max returns an error "Math.log2 is not a function"
Any ideas?

Martin Beck's icon

https://stackoverflow.com/questions/3019278/how-can-i-specify-the-base-for-math-log-in-javascript/3019290

redhexagonal's icon

Thanks, that works . So javascript within Max doesn't have access to all the standard built in objects of javascript?

Martin Beck's icon

I am not sure which version of javascript supports the functionality that you are referring to, but maybe this here helps to understand what javascript version is supported by Max.
https://cycling74.com/forums/any-plans-to-update-support-for-recent-versions-of-js