mscelektronik Posted October 17, 2017 Share Posted October 17, 2017 hello logic scripter pro's It seems that the logarithmic slider type ist not capable to map a range of -70 to +10 as the linear slider does! (log 0 to 70 for example is working...) Any tips on how I can turn my linear slider into a logarithmic that is working? working: var PluginParameters = [ {name:"VCA Level [dB]", type:"lin", minValue: -70, maxValue: 10, numberOfSteps:800, defaultValue:0} ] not working: var PluginParameters = [ {name:"VCA Level [dB]", type:"log", minValue: -70, maxValue: 10, numberOfSteps:800, defaultValue:0} ] best regards, Marcel Quote Link to comment Share on other sites More sharing options...
Nseruame Posted October 25, 2017 Share Posted October 25, 2017 Hi there! Unless you are calling for help from the professionally confused, I can't really offer much I'm afraid. The logarithmic slider has a few quirks. In my experience, it does not accept 0 as its minimum value. It really should. The closest value to zero that it will accept for me is 0.0000000000000000000000000000000000001(36 zeros!). Add an additional zero and it will transform minValue to 1. I do not understand why on earth this is a restriction. I am all ears if you can get a 0-70 range into the logarithmic slider! I've wanted 0 based ranges for quite a while. JavaScriptCore (the system level javascript interpreter that Scripter uses) seems to have different effects on different operating systems for some reason. Maybe thats it. I don't know. The only "solution" I could throw out there would possibly be this: var PluginParameters = [ { name:"VCA Level [dB]" , type:"log" // offset the log slider into a supported range [-70, 10] to [1, 81] , minValue: 1 , maxValue: 81 , numberOfSteps:800 , defaultValue:1 } ] // a global variable to store the value var vcaLevel = 0 // A utility function to convert a number between two ranges // @see https://stackoverflow.com/questions/14224535/scaling-between-two-number-ranges function convertRange( value, r1, r2 ) { return ( value - r1[ 0 ] ) * ( r2[ 1 ] - r2[ 0 ] ) / ( r1[ 1 ] - r1[ 0 ] ) + r2[ 0 ]; } // monitor the parameters for changes function ParameterChanged (index, value) { var parameter = PluginParameters[index] // just in case you add more parameters at a later stage switch (parameter.name) { case "VCA Level [dB]": vcaLevel = convertRange(value, [1, 81], [-70, 10]) Trace(vcaLevel) break; } } function HandleMIDI (midi) { // whatever you want to do with vcaLevel? } I hope that goes someway towards helping out. I'd really like to know if its just my installation that doesn't accept 0, or if its a general problem out there! Namaste Quote Link to comment Share on other sites More sharing options...
mscelektronik Posted October 26, 2017 Author Share Posted October 26, 2017 hi Nseruame, thanks for your inputs. Your right, the log slider doesn't accept 0 as min value, it changes to 1... Your workaround doesn't work for me, as I've to map a range of -70 to 10 (dB) to values between 0 and 16383. I've a working code for this, but I'd like to have a logarithmic slider for the UI, as it controls a log parameter (dB). Anyone knows where the behavior of the sliders is defined? cheers, m Quote Link to comment Share on other sites More sharing options...
Nseruame Posted October 26, 2017 Share Posted October 26, 2017 No problem mscelektronic. I'm surprised the range mapping didn't work... it looks bloody awful having to offset it to a range of 1 to 81, but 800 steps between the values should still compute as it is still a logarithmic curve. Rethink. How about two range transformations? One from range [1-81] => [-70, 10], then, from that result, map that value between the ranges [-70, 10] => [0, 16383]? Or just map the value of the slider from the ranges [1, 81] => [0,16383] (sorry for mixed numbers, typing on train in a hurry and reception is patchy). var converted = 0 function ParameterChanged (index, value) { var parameter = PluginParameters[index] switch (parameter.name) { case "VCA Level [dB]": converted = convertRange(value, [1, 81], [0, 16383]) Trace(converted) break; } } ? Alternatively you could use a linear slider and compute the logarithmic exponent in your code... unsure about that though as the view and the data you are using would not correspond (not that 1-81 does either I guess). Its barmy. As far as I know, the behaviour of the sliders is defined internally. What I mean by that, is that there are Objective C bindings to a the JavaScriptCore instance that Scripter uses. Its not accessible and it is a real shame. Your use case is perfectly valid in my opinion. Thanks for clarifying that it does not accept a value of 0. I would consider this one of a few long term bugs with Scripter. Not sure what else can be done, but would be good if you could keep the thread updated as you go Quote Link to comment Share on other sites More sharing options...
mscelektronik Posted October 27, 2017 Author Share Posted October 27, 2017 the main problem with a log slider range of 1-81 will be, that the user won't have any clue how much dB he will boost or attenuate. the only workaround I found so far is to bring logic's smart controls into the game. it's possible to draw a custom curve to get a log type curve for a linear fader. but I definitely would prefer a solution in my script.. btw: here's the code with the lin fader: var PluginParameters = [ {name:"VCA Level [dB]", type:"lin", minValue: -70, maxValue: 10, unit:"dB", numberOfSteps:800, defaultValue:0}, {name:"Trim [dB]", type:"lin", minValue: -6, maxValue: 6, unit:"dB", numberOfSteps:1200, defaultValue:0}, {name:'CH 1', type:'menu', valueStrings:['off','on']}, {name:'CH 2', type:'menu', valueStrings:['off','on']}, {name:'CH 3', type:'menu', valueStrings:['off','on']}, {name:'CH 4', type:'menu', valueStrings:['off','on']}, {name:'CH 5', type:'menu', valueStrings:['off','on']}, {name:'CH 6', type:'menu', valueStrings:['off','on']}, {name:'CH 7', type:'menu', valueStrings:['off','on']}, {name:'CH 8', type:'menu', valueStrings:['off','on']}, {name:'CH 9', type:'menu', valueStrings:['off','on']}, {name:'CH 10', type:'menu', valueStrings:['off','on']}, {name:'CH 11', type:'menu', valueStrings:['off','on']}, {name:'CH 12', type:'menu', valueStrings:['off','on']}, {name:'CH 13', type:'menu', valueStrings:['off','on']}, {name:'CH 14', type:'menu', valueStrings:['off','on']}, {name:'CH 15', type:'menu', valueStrings:['off','on']}, {name:'CH 16', type:'menu', valueStrings:['off','on']} ]; // This is a function function Normalizer(min, max) { return function(val) { return (val - min) / (max - min); } } // This is another function Interpolater(min, max, clamp) { return function(val) { val = min + (max - min) * val; return clamp ? Math.min(Math.max(val, min), max) : val; } } // This is a third function Scale() { var domain = new Normalizer(0, 1); var range = new Interpolater(0, 1); var s = function(val) { return range(domain(val)); }; s.domain = function(min, max) { if (!arguments.length) return domain; domain = new Normalizer(min, max) return s }; s.range = function(min, max, clamp) { if (!arguments.length) return range; range = new Interpolater(min, max, clamp) return s }; return s; } // When the Parameter "VCA Level [dB]" changes, send the new Value to the selected Midi Channel function ParameterChanged() { var faderMSB = new ControlChange; var faderLSB = new ControlChange; var dBto14bit = new Scale().domain(-70.0, 10.0).range(0, 16383); var faderlevel = GetParameter("VCA Level [dB]") + GetParameter("Trim [dB]"); if(faderlevel > 10.00) faderlevel = 10.00; if(faderlevel < -70.00) faderlevel = -70.00; var input = dBto14bit(faderlevel); var MSB = ((input >> 7) & 0x7F); var LSB = input & 0x7F; for(var i=1; i<=16; i++){ if(GetParameter("CH " + i)){ faderMSB.value = MSB; faderMSB.number = "7"; faderMSB.channel = i; faderMSB.send(); faderMSB.value = LSB; faderMSB.number = "39"; faderMSB.channel = i; faderMSB.send(); } } } Quote Link to comment Share on other sites More sharing options...
mscelektronik Posted October 28, 2017 Author Share Posted October 28, 2017 different approach: is there a way to get the value of the Channel Volume Fader (on which the script is inserted) into scripter? Quote Link to comment Share on other sites More sharing options...
Nseruame Posted October 29, 2017 Share Posted October 29, 2017 No avoiding the UI confusion with the confusing 1-81 range. I personally don’t like it, but it’s the only way I could think of getting the numbers for you. It is a UI crime however. As regards channel strips, there is no way as far as I know. There are legends of a Fader parameter... but I’ve never encountered it in the past year and a bit that I’ve been using Scripter. What version of logic do you have? Looking forward to a decent WIFI connection and my Mac in a few days to check out your code properly. Quote Link to comment Share on other sites More sharing options...
mscelektronik Posted October 29, 2017 Author Share Posted October 29, 2017 I'm working on 10.3.2. Not sure what this bespoken fader() function is used for too.. Quote Link to comment Share on other sites More sharing options...
Nseruame Posted November 1, 2017 Share Posted November 1, 2017 Thanks for clarifying the version number - you have an up to date edition without the Fader "class" then. Where did you come across the 'fader' function? Or did you just type Fader quickly? Sorry for asking - its just that the whole Fader malarky is a bit of a bug bear of mine. I've never encountered it in any edition of Scripter that I have used, yet it seems to persist as being a valid Scripter object in various forums! Just curious Quote Link to comment Share on other sites More sharing options...
Unheardofski Posted November 16, 2017 Share Posted November 16, 2017 EventTypes.js did contain a Fader "class" or object if you so will. This is not a legend, it is a fact. I tried using it but it never "did" anything for me. I think of it a little as U2's Songs of Innocence. Quote Link to comment Share on other sites More sharing options...
Eric Cardenas Posted November 16, 2017 Share Posted November 16, 2017 EventTypes.js did contain a Fader "class" or object if you so will. This is not a legend, it is a fact. I can confirm this. It was in there in 10.2 - 10.2.2, but did not work. I think of it a little as U2's Songs of Innocence. Quote Link to comment Share on other sites More sharing options...
Nseruame Posted December 21, 2017 Share Posted December 21, 2017 Thanks for the clarification guys. I wasn't aware of that. I suppose the official line is that the Fader class existed, but was deprecated after 10.2.2. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.