Jump to content

Send program change with keypad / numpad


FantomXR

Recommended Posts

Hey people,

 

I wonder if somebody managed to send a program change command with a simple keypad. May I overlooked something but I didn't find something which is related to midibox. 

I wish to type in a number and after pressing an "enter"-button it sends the program change number.

 

Is there something out there? :)

Thanks,

Chris

Link to comment
Share on other sites

It doesn't matter if buttons are directly connected to DINs, or buttons of a keypad matrix would be used - some special routines are required which are not part of the firmware yet.

 

I need some time to find a generic solution for this.

E.g. if the .NGR language would allow arithmetic operations, such as the modification of BCD-code digits of an element, then this would satisfy your request and could also be used for other purposes.

 

Best Regards, Thorsten.

Link to comment
Share on other sites

This is probably the most tricky script that I ever wrote so far ;-)

 

Try this version: http://www.ucapps.de/mios32/midibox_ng_v1_032_pre1.zip

 

It supports math operations in a .NGR script!  :shifty:

 

Configuration example:

.NGC: http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr5.ngc

.NGR: http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr5.ngr

.NGL: http://svnmios.midibox.org/filedetails.php?repname=svn.mios32&path=%2Ftrunk%2Fapps%2Fcontrollers%2Fmidibox_ng_v1%2Fcfg%2Ftests%2Frunscr5.ngl

 

You can either use buttons connected to DIN shift registers, or you could use a real keypad connected to DIN/DOUT in a suitable DIN_MATRIX configuration (not shown in this example, but it shouldn't be so difficult to configure this...)

 

Best Regards, Thorsten.

Link to comment
Share on other sites

Yes, you can now add similar commands for any other value, just store them into different LED:xxx numbers (the LED event actually acts as some kind of memory, resp. variables).

 

Then you could also use another LED:yyy to switch the keyboard between the different selection modes.

 

It will result into a lot of "spaghetti code" (.NGR is no elegant programming language, but just a dumb command interpreter), but you will be able to implement this with the given functions.

 

Best Regards, Thorsten.

Link to comment
Share on other sites

Hey Thorsten!

 

Great! I figured out how to send a CC which contains the bank select and after that the program change. It works great!

 

 

# EXEC button
if ^section == 11
  # valid number?
  if LED:2001 == 1
    send CC USB1 1 32 0 // the last value shows the bank which is selected by this CC - in this case 0
    send ProgramChange USB1 1 LED:2000
 
    # next entry will reset the number
    set LED:2001 2
  endif

 

 

So, what I could do is, adding two buttons. Those two buttons change between bank select 1 and 2. But I think this is a complicated solution. Here is an idea:
Is it possible, that NG generates the correct program change (including bank select) automatically? So, for example: I enter number 128 and NG sends Program Change 1 on Channel 1 on Bank 2 because it's the first program change in the new bank. 

 

What do you think?

 

A friend of mine uses Mainstage and he has a very large setup running, which contains up to 200 songs. Mainstage (meanwhile) supports bank select. So this would be a great feature.

 

This feature is already awesome anyways :)

Link to comment
Share on other sites

First you have to change the value limitation to allow a value entry in the range of 0..255.

 

In the different sections you will find "if" conditions which check for certain numbers, e.g. in section 1..7 it's checked that the value is <= 12

Why? because we want to ensure that it isn't possible to enter a value > 127.

A program change ranges from 0..127, values above this range are invalid.

Example: If somebody would enter '1', and then a '3' (-> 13), an additional '1' would result into 131 -> invalid value!

Therefore only <= 12 is allowed.

 

Now you've to change it in a way that value between 0..255 can be entered, and all other values are blocked.

To give you some hints: for ^section 1 it will be <= 25 ;-)

 

Once you are able to enter values between 0..255, replace the MIDI event sending code by:

# EXEC button
if ^section == 11
  # valid number?
  if LED:2001 == 1
    if LED:2000 < 128
      # Bank 1
      send CC USB1 1 32 0

      # Program Change
      send ProgramChange USB1 1 LED:2000
    else
      # Bank 2
      send CC USB1 1 32 1

      # Program Change
      # modulo operation: ensure that PC value is in range between 0..127
      send ProgramChange USB1 1 [LED:2000 % 128]
    endif

    # next entry will reset the number
    set LED:2001 2
  endif

  exit
endif

 

This could also be simplified with:

# EXEC button
if ^section == 11
  # valid number?
  if LED:2001 == 1
    # Bank = value / 128
    send CC USB1 1 32 [LED:2000 / 128]

    # Program Change
    # modulo operation: ensure that PC value is in range between 0..127
    send ProgramChange USB1 1 [LED:2000 % 128]

    # next entry will reset the number
    set LED:2001 2
  endif

  exit
endif

 

This code is untested - in case of errors, please first try to debug this by yourself!

 

Best Regards, Thorsten.

Link to comment
Share on other sites

I've improved the math calculation handling a bit.

It's not relevant for that what you are doing, but could be helpful for others in future.

 

Update to v1.032_pre2: http://www.ucapps.de/mios32/midibox_ng_v1_032_pre2.zip

 

Now you can add spaces between operands and operator, such as: [LED:2000 / 128] to make the code more readable.

And even nested operations are possible, such as: [LED:2000 + [LED:2001 + [LED:2002 + LED:2003]]]

 

 

Something that could be even more interesting for you is the new "SRIO num_sr=<1..32>" parameter.

It allows to reduce the number of scanned shift registers.

 

E.g. let's say you've connected 4 DIN SRs and 2 DOUT SRs. The longest chain are the 4 DIN SRs

Accordingly you can set:

SRIO num_sr=4

Now your keyboard will be scanned 8 times faster than before! :smile:

 

Best Regards, Thorsten.

Link to comment
Share on other sites

Hey TK!

Thanks for all that!
I at first need to understand the code in the NGR. That takes a bit of time :) 

The new features you added... could you do an example for what this could be useful?

 

I don't know, what you meant by the SRIO. Where do I have to put this parameter into? It would be great to scan it faster :)

 

I'm out of DIO-modules... so I can not test it at the moment...

Link to comment
Share on other sites

The new features you added... could you do an example for what this could be useful?

 

E.g. let's say somebody wants to construct an unusual NRPN value format for a certain synth, the nested operations will help you to do this.

Or somebody needs an IF condition depending on a certain bit of a value such as [^value & 0x40] == 0x40 -> now possible.

 

Of course, I will give more examples in the documentation sooner or later, but I guess that most users need a direct specification from my side to solve a configuration issue. My advantage: I don't need to enhance the firmware anymore for such special cases.

 

 

SRIO: Serial Register Input/Output -> MBHP_DIN, MBHP_DOUT, MBHP_DRIO

 

You don't need new hardware to test this...

Some time ago you complained that the scan latency of a keyboard is worse when using MBNG compared to MBKB.

By reducing the number of scanned shift registers you will get the same performance.

 

Best Regards, Thorsten.

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...
×
×
  • Create New...