View Single Post
Old 01-18-2017, 11:33 AM   #10
sonicowl
Human being with feelings
 
sonicowl's Avatar
 
Join Date: Oct 2015
Posts: 354
Default

Now I got it working at 14 bit for one fader. (EDIT: Works now.) But it oly works for first 8 tracks. If I select track 9, BCF still stay connected to previously selected track (any track 1-8 that was selected before.

For tracks above 8 (9 and on) connection is broken.

I tried increasing "DEVICE_TRACK_COUNT 8" in Default.ReaperOSC to "DEVICE_TRACK_COUNT 999", but no change.)

Any idea why below script works only on first 8 tracks?

EDIT: I changed ""DEVICE_TRACK_COUNT" to 256, and now it works. With 999 there was a long delay before it updated all faders. Now with 256 it is fine.

=======

Code:
// REAPER<-->BCF2000 OSC, for REAPER's Default.ReaperOSC
// only Fader 1 (Ch 1, CC 0, 14bit) to selected channel in Reaper

@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) (
//  printf(oscstr);
//  printf("\n");
  
  vol *= 16383;
  msg1 = $xb0;
  msg2 = $x00;
  msg3 = vol >> 7; // Get MSB from 14 bit value
  midisend(midi_out);
//  printf(sprintf(#,"%02x %02x %02x",msg1,msg2,msg3));
//  printf("\n");
  msg2 = $x20;
  msg3 = vol & $x7F; // Get LSB from 14 bit value
  midisend(midi_out);
//  printf(sprintf(#,"%02x %02x %02x",msg1,msg2,msg3));
//  printf("\n");
  
);

//  printf(sprintf(#,"%02x %02x %02x",msg1,msg2,msg3));
//  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 == $xb0 && msg2 == $x00 ? (
 count += 1;
 count % 2 ? (
	 msb=msg3;
 ) : (
  vol = (msb*128 + msg3) / 16383;
  track_voltab[track_index] = vol;
  fmt0 = track_index;
  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:05 AM.
sonicowl is online now   Reply With Quote