Scale / Map incoming values

Discuss Lemur and share techniques.
Post Reply
maara
Newbie
Posts:3
Joined:27 Dec 2014 20:27
Scale / Map incoming values

Post by maara » 02 Jan 2015 13:59

Hi all,

I am completely new to Lemur so sorry for my stupid question...
I am trying to get a key value from traktor and display it in a text type object on the lemur.
The traktor is representing the value as a knob with range of -12 to 12 which is in fact midi message with range 0 to 127.
When I use the value directly, I get value 63 for 0 what is logical but not very comfortable so I decided to translate the value...
1) When I simply made a value expression to value = value -63 to "round" it, it was nto usable due to the looped subtraction...
2) I tried to use the following formula to extrapolate the numbers:
(value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
==>
(value - 0) * (12 - - 12) / (127 - 0) + -12;
...but not working...

Could anyone please check my approach if its correct? Isn't there some built in function to scale the incomming numbers?
Is it possible that I make such function and call it for mapping the values I need?
Any idea why the expression as above is not working?

Thanks a lot for your help!

Cheers!
Marek

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: Scale / Map incoming values

Post by Softcore » 02 Jan 2015 22:40

If you have also mapped any object to that value you can use the object's x with this formula:

value = x*24-12

If you wan to directly translate midi range (0-127) then use:

value= Midivalue*(24/127)-12

Here's a working example with both cases!
Attachments
values.jzml
(3.61KiB)Downloaded 61 times

maara
Newbie
Posts:3
Joined:27 Dec 2014 20:27

Re: Scale / Map incoming values

Post by maara » 04 Jan 2015 21:48

Hi Softcore,

Thanks for your explanation and example! - this is exactly what I was looking for.
One more question to this one - when I mapped the encoder to send the value to the application (the current status is only for displaying the value), it was not sending whole numbers (1 - +/- 12) even I set the encoder to grid 25 (for the middle 0 and 24 to each limit value)
-1 is -0.58 etc.

thanks!

Post Reply