Reads all 15 analog inputs and drops them as midi cc messages (mapped). Inputs have a threshold, to avoid noise. 9/24/2018 burek GPL
on (connect inlet pval!) off (jump) 1 0 0){ map[i] = imap[i]; } else map[i] = i+1; } waitforpickup=0; /* Good Initial Map: * * * 6,10,7,8,9,11,13,12,14,33,1,2,3,4,5, 20,24,21,22,23,25,27,26,28,32,15,16,17,18,19 * * */]]> >8)<<2); currval = ((currval<4)?0:((currval<10)?1:((currval<20)?2:((currval<28)?3:((currval<32)?4:((currval<40)?5:((currval<48)?6:((currval<56)?7:((currval<60)?8:9))))))))); if (currval!=val[i]){ val[i] = currval; PatchMidiInHandler(MIDI_DEVICE_INTERNAL,0,MIDI_CONTROL_CHANGE,map[i+offset],__USAT(currval<<1,7));// write to midi cc //LogTextMessage("Selector Switch (%d) goes to %d",map[i+offset],currval); } } else{ currval = adcvalues[i]<<15; // read one analog input per circ if (i+offset==active){ //LogTextMessage("%d is active",map[active]); timer -= 1<<15; if (waitforpickup == 0){ if (abs(currval-val[i])>(1<<17)){ // ignore mini-changes val[i] = currval; if (timer<(1<<23)) timer += 1<<17;//abs(currval-val[ioff]); // small change give you active time if (lastact!=active){ lastact = active; // outlet_ccchg = 1; } PatchMidiInHandler(MIDI_DEVICE_INTERNAL,0,MIDI_CONTROL_CHANGE,map[i+offset],__USAT(currval>>20,7));// write to midi cc //outlet_val = currval>>20; //outlet_cc = map[i+offset]; } } else if (waitforpickup > 1){ waitforpickup--; if (waitforpickup == 2){ val[i] = inlet_pval; //LogTextMessage("received pval for %d: %d",map[i+offset],val[i]); PatchMidiInHandler(MIDI_DEVICE_INTERNAL,0,MIDI_CONTROL_CHANGE,map[i+offset],__USAT(val[i]>>20,7));// write to midi cc waitforpickup--; } } else if (waitforpickup == 1){ if (abs(val[i]-currval)<(1<<19)){ // we got pickup //LogTextMessage("Gleich!!!"); waitforpickup = 0; } } } else{ if (abs(currval-val[i])>(1<<22)){ // to become active, larger chg required //LogTextMessage("Requesting pval for %d (so far: %d)",map[i+offset],map[active]); active = i+offset; //LogTextMessage("active now set to %d",map[active]); disp_on = map[active]; if (attr_pickup&&(active!=lastact)) waitforpickup = 3; // how many cycles do you need to wait before actually waiting for pickup else waitforpickup = 0; timer = 1<<23; // for a little while, this is active } } if (timer < 0&&active>=0){//...but as time passes, it become inactive again //LogTextMessage("Left %1D at %3D",map[i+offset],currval>>21); val[i]=currval; active=-1; } } disp_active = (active >= 0); outlet_activity = (active >= 0); outlet_ccsoon = map[active]; outlet_selector = val[9]*15; { int act = ((active>=0)?active:lastact); outlet_val = val[act-offset]; outlet_ccNo = map[act]; } i++;]]> if there is any midi cc activity, "write" triggers after that activity is over for a little while, or whenever the cc number changes; when triggered by cc change, "val" and "cc" still deliver the value and cc number from *before* the change. This is meant to be used for writing midi cc data to a table without writing every minute change. burek GPL 0) active -= 1<<20; if ((active<=0)&&pending){ outlet_write = 1; pending = 0; } if (outlet_write) { //LogTextMessage("Writing to table: cc %d: %d",cc,val); } outlet_value = val; outlet_cc = cc;]]> write to table Johannes Taelman BSD table.axh 0) && !ntrig) { //LogTextMessage("Writing to table"); ntrig=1; if (inlet_a>attr_table.GAIN; } if (!(inlet_trig>0)) ntrig=0;]]> no 338 34 1097 692