Jump to content

NRPN issues - can't go past NRPN #256


weasel
 Share

Recommended Posts

hello friends,

i have a problem with my rotary encoders sending several banks of midi NRPN data - i can't go past NRPN number 256! the second byte of the midi nrpn number message (ie. midi CC 99) midibox sends only goes from 0 to 1, as shown on the mios studio output monitor.

it says in the manual that the nrpn number is also 14bit range as per the midi standard

nrpn=<0..16383> 	Specifies the NRPN number (0..16383) for type=NRPN events 

is this a known issue? am i doing something wrong (presumably...)

this is an EVENT ENC definition that shows:

EVENT_ENC    id=  55 hw_id=7 bank=3  type=nrpn nrpn=261     chn= 1    range=  4095:0  enc_speed_mode=fast:6   offset=  0  ports=10001000000010000000  lcd_pos=1:1:1  label="^std_enc" value= 0
Quote

 

so, this give me CC99 = 1 CC98 = 5, NRPN = 133

instead of CC99 = 2 cc98 = 5, NRPN = 261

that i wanted. only the first bit of CC99 seems to be changed, effectively giving me 8bit range.

 

Edited by weasel
Link to comment
Share on other sites

on the receiver side i am monitoring the midi incoming from the midibox with the axoxloti serial monitor, which shows the same value that mios studio shows sending.

so, mios studio seems to display the "correct" values that are actually being sent. just CC99 only ranges from 0-1 instead 0-127.

Link to comment
Share on other sites

Anyway we will do a small debug test...
For that you will need to recompile the MBNG app after modification...

in mbng_file_c.c at line 812

replace this:

    ////////////////////////////////////////////////////////////////////////////////////////////////
    } else if( strcasecmp(parameter, "nrpn") == 0 ) {
      int value;

      if( (value=get_dec(value_str)) < 0 || value >= 16384 ) {
#if DEBUG_VERBOSE_LEVEL >= 1
	DEBUG_MSG("[MBNG_FILE_C:%d] ERROR: invalid NRPN number in EVENT_%s ... %s=%s\n", line, event, parameter, value_str);
#endif
	return -1;
      } else {
	if( item.flags.type != MBNG_EVENT_TYPE_NRPN ) {
#if DEBUG_VERBOSE_LEVEL >= 1
	  DEBUG_MSG("[MBNG_FILE_C:%d] WARNING: no NRPN number expected for EVENT_%s due to type: %s\n", line, event, MBNG_EVENT_ItemTypeStrGet(&item));
#endif
	} else {
	  // no extra check if event_type already defined...
	  stream[1] = value & 0xff;
	  stream[2] = value >> 8;
	  item.secondary_value = stream[1];
	}
      }

    ////////////////////////////////////////////////////////////////////////////////////////////////


by

    ////////////////////////////////////////////////////////////////////////////////////////////////
    } else if( strcasecmp(parameter, "nrpn") == 0 ) {
      int value;

      if( (value=get_dec(value_str)) < 0 || value >= 16384 ) {
#if DEBUG_VERBOSE_LEVEL >= 1
	DEBUG_MSG("[MBNG_FILE_C:%d] ERROR: invalid NRPN number in EVENT_%s ... %s=%s\n", line, event, parameter, value_str);
#endif
	return -1;
      } else {
	if( item.flags.type != MBNG_EVENT_TYPE_NRPN ) {
#if DEBUG_VERBOSE_LEVEL >= 1
	  DEBUG_MSG("[MBNG_FILE_C:%d] WARNING: no NRPN number expected for EVENT_%s due to type: %s\n", line, event, MBNG_EVENT_ItemTypeStrGet(&item));
#endif
	} else {
	  // no extra check if event_type already defined...
	  stream[1] = value & 0x7f;
	  stream[2] = value >> 7;
	  item.secondary_value = stream[1];
	}
      }

    ////////////////////////////////////////////////////////////////////////////////////////////////



Cause !
In this part of the parser there's something strange which is disturbing me at the end when the address is store in the item->stream we've got:

	  // no extra check if event_type already defined...
	  stream[1] = value & 0xff;
	  stream[2] = value >> 8;
	  item.secondary_value = stream[1];

but in the MBNG_EVENT_TYPE_NRPN part of the MBNG_EVENT_ItemSend function we've got:

    u16 nrpn_address = item->stream[1] | ((u16)item->stream[2] << 7);

if I make the calculation like it is I find exactly your problem:

In parser
stream[1] = 261 & 0xff = 5
stream[2] = 261 >> 8 = 1

then in MBNG_EVENT_ItemSend
u16 nrpn_address = item->stream[1] | ((u16)item->stream[2] << 7) = 5 | (1<<7) = 133

Address msb is not limited to 0 or 1, I think it's a masking and shifting error and bit 7 is lost, so make the test with

	  // no extra check if event_type already defined...
	  stream[1] = value & 0x7f;
	  stream[2] = value >> 7;
	  item.secondary_value = stream[1];

Please

 

Edited by Antichambre
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...