Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 11-18-2009, 02:43 PM   #1
plamuk
Human being with feelings
 
Join Date: Feb 2007
Posts: 3,221
Default basic MIDI js request: when moving cc, ignore initial position +/- 1 (flicker-killer)

hey guys.
this is something i figured out how to code in arduino, where potentiometers give an incoming signal of 0-1023.

when you map this value down to 0-127, you often get a "flicker," ie cc data jumping between 45, 44, 45, 44 for example as the higher-resolution data of the sensor fluctuates on a scale that the lower resolution cc data cannot handle.

the trick in arduino is to convert the large resolution data from 0-1023 down to 0-255, do some math against a threshold of 2, and then divide the result before sending it off as cc data. here's an example, the bold part is the important thing:

transval = analogRead(transpin);
mappedtransval = map(transval, 0, 1023, 0, 16);
if(mappedtransval != lasttransval){
if(abs(mappedtransval - prevtransval) >= THRESHOLD){
prevtransval = mappedtransval;
applytrans = mappedtransval/2*12-48;
//Serial.println(transpose);
lasttransval = mappedtransval;}}

i'd like to achieve something similar in js, but i can't because the values are already in 0-127. for this reason, i need something that ignores a cc data change if it is + or - 1 of the initial position.

does this make any sense? any takers? it's undoubtedly dirt simple and i'd learn a lot from looking at it...tried to hack one out of "cc rider" but didn't get very far.

thanks
nym
plamuk is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:53 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.