View Single Post
Old 01-18-2017, 06:41 AM   #9
sonicowl
Human being with feelings
 
sonicowl's Avatar
 
Join Date: Oct 2015
Posts: 359
Default

OK, I got basic functionality with below code. It is 7 bit only (still need to figure 14bit part). But it works both ways. Fader 1 (ch1/CC0)on BCF moves volume on any selected track in Reaper. And if i move any track volume in Reaper, it moves Fader 1 in BCF. Switching tracks in Reaper also updates fader in on BCF.So it works exactly as I wanted. Only not 14 bits.

====
Code:
// REAPER<-->BCF2000 OSC, for REAPER's Default.ReaperOSC

@input osc_in OSC "*:9000"
@output osc_out OSC "localhost:8000"

@output midi_out MIDI "B-CONTROL"
@input midi_in MIDI "B-CONTROL"

@init

track_index = 1;

track_voltab = 1024;

@timer


@oscmsg

function set_vol_fader(vol) (
  vol *= 16383;
  msg1=176;
  msg2=0;
  msg3=vol/128;
  midisend(midi_out);
);

//  printf(sprintf(#,"%02x %02x %02x",msg1,msg2,msg3));
//  printf("\n");
//  printf(oscstr);
//  printf("\n");

oscmatch("/track/%d/*") ? (
  // fmt0 will have the affected track index


  oscmatch("/track/%d/select") ? (
    oscparm(0,0)>0 ? (
      track_index=fmt0;
      set_vol_fader(track_voltab[fmt0]);
    );
  ) : oscmatch("/track/%d/volume") ? (
    track_voltab[fmt0] = oscparm(0,0);
    fmt0 == track_index ? set_vol_fader(track_voltab[fmt0]);
  );
);


@midimsg

msg1 == 176 ? (
//  vol = (msg2 + msg3*128) / 16383;
  vol = msg3/127;
  track_voltab[track_index] = vol;
  fmt0 = track_index;
//  oscsend(osc_out,"/track/%d/volume", vol);
  oscsend(osc_out,"n/track/%d/volume", vol); //forum
  set_vol_fader(vol);
);

//  printf(sprintf(#,"%02x %02x %02x %f",msg1,msg2,msg3,vol));
//  printf("\n");

Last edited by sonicowl; 02-11-2017 at 05:07 AM.
sonicowl is offline   Reply With Quote