Jump to content

understanding the .ngc code


ssp
 Share

Recommended Posts

Just now, TK. said:

In MBNG it's a soft-option written into the NGC file:

AINSER n=1   enabled=1  cs=0  num_pins=64  resolution=7bit

 

which allows to set the number of pins

Best Regards, Thorsten.

Thank you Thorsten, as soon as the pcbs arrive i will edit the code for this and try it out along with the new revision for NRPN numbers.

Link to comment
Share on other sites

OK question. I want to have to buttons function as an down value and one as an up value rather than using a pot or encoder. 

I have two buttons linked to the din module and in effect they are replacing an encoder for the up and down values but in essence are acting as an encoder.

The buttons work like this, the maximum values needed for this are 0 to 100 not 0 to 127 but in steps of 20 these are for transposing the plugin i am using

values:

-2:= 0 - 20

-1:= 21 - 40

0=: 41 - 60

1=: 61 - 80

2=: 81 - 100

so if the button is in the middle ie:"0" then the button state is at a value between 41 - 60, if i then press the left button once the value changes to 21 - 40 and again to 0 - 20, if i then press the right button it brings the values back up.

 

OK so i have got a din with two buttons conencted to the mb_ng. on the first shift register to replicate an encoder such

ENC n= 1 sr=1 pins=0:1 type=non_detented (an encoder uses two of the sr pins)

each press of the button on sr=1 pin:0 is the left button with a decreasing value of to 0 in steps of 20

pressing button on sr=1 pin:1 increases the value by 20.

would i need to make a value table or meta event for this? to make each button press of either decrease or increase the value of the set range 0-100?

I am looking at the manual as I am typing this but I cant see anything that resembles this.

In other good news more of my bits turned up, also my ainser64 have arrived so I building those as well.

 

Thanks

EDIT:  so the buttons will work as an encoder thats fine, i just need to set the min-max value range of 0-100 instead of 0-127 but it needs to travel in values of 20 at each press. Can i set this value range and steps?

buttons.jpg

Edited by ssp
Link to comment
Share on other sites

this is a good comparison in the manual where a dimmed LED steps in values of 16

 

bullet.gif Dim me!

While previously the LED was only switched between on and off state depending on the incoming MIDI value, now we want to control the brightness level with the received velocity value instead:

EVENT_BUTTON id=1  fwd_id=LED:1 dimmed=1  type=NoteOn key=36  lcd_pos=1:1:1 label="Button #%3i: %3d"

Only the dimmed=1 parameter has been added. The LED will change the brightness over the 0..127 value range in 16 levels.

Just for fun you could also control the brightness from a CC event:

EVENT_LED  id=1  dimmed=1  type=CC cc=16
Link to comment
Share on other sites

In this case would I use either the:  enc_mode= Incxx_Decxx.  Or would i use emu_enc_mode=<mode> Incxx_Decxx function and use the +or- 20 values in hex.

 

This seems logical to me. once this is in place i then have to have each value linked to each led. so if the value is 41-60 (this is the range of the value for the 0 position led to be lit and active and can be any number between that range)

 

so for example for the steps i want:

enc_mode= Inc14_Dec14 (this is the hex value for the decimal value of 20) im sure an event_reciever is needed also but I am not sure where to implement this.

 

I am looking through this page here: https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/cfg/tests/emu_enc.ngc

to see if this can help me.

Edited by ssp
Link to comment
Share on other sites

2 hours ago, FantomXR said:

Isn't that a usecase for MAPs? I haven't tried it but I'd set up an encoder in absolute mode and setup a MAP as range. 

In the NGR you can tell NG to set the encoder to a dedicated value when starting up. 

Thanks for the info

I remember on the MB64e you could change the inc,dec buttons to an encoder with a slight code change. In effect this is the opposite, an encoder function to, two buttons, with a range of 0-100 instead of 0-127. and each button press has a stepped range of 20.  however after pulling  another late night the first press is 0-20 the second press actually starts at 20.5 as this is a marginal step over 20 it changes the plugin transpose position but you can round this to 21.

hopefully i will give it a try today, im not holing out for much success as i cant see any reference to a function for buttons like this on the forum or in the manuals other than the enc_mode or the emu_enc_mode functions.

I am writing test lines of coade as shown in the "First steps" section and trying things as i go.

I have got a few other things working but this and the 3 digit values issue are griefing me.

Edited by ssp
Link to comment
Share on other sites

3 hours ago, FantomXR said:

Isn't that a usecase for MAPs? I haven't tried it but I'd set up an encoder in absolute mode and setup a MAP as range. 

In the NGR you can tell NG to set the encoder to a dedicated value when starting up. 

Is this what you are referring to (by example) and use this as a starting point? this is for a single button, i would need for this to be over two buttons.

https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/cfg/tests/mapbtn.ngc

RESET_HW
 
LCD "%CMap Button Values"
 
# the used map:
MAP1 0 1 2 4 8 16 32 64
 
# define a radio group with a single toggle button but multiple LEDs
EVENT_BUTTON id= 1 fwd_to_lcd=1 type=CC chn=1 cc=16 button_mode=Toggle range=map1 radio_group=1 lcd_pos=1:1:1 label="^std_btn"
 
# Note: the map will only be considered if a button is configured for button_mode=Toggle !
 
# these LEDs are mapped to radio_group1, and therefore will get an "automatic feedback" whenever the toggle button changes the value (or receives a new value)
EVENT_LED id= 1 range=0:0 radio_group=1
EVENT_LED id= 2 range=1:1 radio_group=1
EVENT_LED id= 3 range=2:2 radio_group=1
EVENT_LED id= 4 range=4:4 radio_group=1
EVENT_LED id= 5 range=8:8 radio_group=1
EVENT_LED id= 6 range=16:16 radio_group=1
EVENT_LED id= 7 range=32:32 radio_group=1
EVENT_LED id= 8 range=64:64 radio_group=1
 
 
# a button which doesn't toggle, but just turns on/off
# in this case either the lowest or highest item of a map will be taken

EVENT_BUTTON id= 2 fwd_to_lcd=1 type=CC chn=1 cc=17 button_mode=OnOff range=map1 radio_group=1 lcd_pos=1:1:1 label="^std_btn"

Link to comment
Share on other sites

I am sat here trying a few things out, i have two buttons in the breadboard and I am writing test lines of code as i go along, everything i have already learned i have applied and they are working , I am going to try to work out the code for these two buttons and try it, if i dont get it, then i will post up what i have done and if anyone can help me out then I will ask.

 

thanks

Link to comment
Share on other sites

I didnt manage to get the buttons to step to values i wanted. Everything I tried if i press the increase value it would gotot "2" then back to "1" or "0". It wouldnt go higher than that.

It must be possible for example, the Dimmed=1 command will dim an led by values of 16 so this must be possible for the buttons to send out a cc~ with value steps of 20.

Can anyone point me in the right direction please?

Link to comment
Share on other sites

5 hours ago, FantomXR said:

Again: look at the MAP feature. This exactly what you need. 

Set a map as range with range=Map1 and create a map with the desired values underneath it. 

See this example:

https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/cfg/tests/mapbtn.ngc

I swear I am going nuts you know, i posted this earlier in my thread as well... thanks for the heads up Fantom.

Ok so I managed to grab 5 mins to do this, will test it later

two buttons each with its own #cc by using the button_mode OnOff if the transpose + is all the way to the highest value , pressing the transpose - will take the value lower as it already sees the higher value as stated here:

# a button which doesn't toggle, but just turns on/off
# in this case either the lowest or highest item of a map will be taken
 

 

So I have edited my code to come up with this:

 


LCD "%CMap Button Values"

# the used maps:
MAP1  41 21 0
MAP2  41 61 81

#I can also have a full range but reversed on both:
MAP1 81 61 41 21 0    
MAP2 0 21 41 61 81

# define a radio group with a single toggle button but multiple LEDs

EVENT_BUTTON id=  1  fwd_to_lcd=1  type=CC chn=1 cc=16  button_mode=OnOff  range=map1  radio_group=1  lcd_pos=1:1:1 label="^Transpose-"
EVENT_BUTTON id=  2  fwd_to_lcd=1  type=CC chn=1 cc=16  button_mode=OnOff  range=map2  radio_group=2  lcd_pos=1:1:1 label="^Transpose+"

# Note: the map will only be considered if a button is configured for button_mode=Toggle !

# these LEDs are mapped to radio_group1 and radio_group2, and therefore will get an "automatic feedback" whenever the toggle button changes the value (or receives a new value)

#This is for the transpose minus button

EVENT_LED id=  1  range=41:41    radio_group=1
EVENT_LED id=  2  range=21:21    radio_group=1
EVENT_LED id=  3  range=0:0      radio_group=1

#This is for the transpose plus button

EVENT_LED id=  4  range=41:41    radio_group=2
EVENT_LED id=  5  range=61:61    radio_group=2
EVENT_LED id=  6  range=81:81    radio_group=2

 

looking forward to trying this after work

 

 

Edited by ssp
Link to comment
Share on other sites

ok the code works ;) I havent hooked up the leds yet, will do shortly. This is the code I used.

RESET_HW

 

# the used maps:
MAP1 81 61 41 21 0
MAP2 0 21 41 61 81

# define a radio group with a single toggle button but multiple LEDs

EVENT_BUTTON id=  1  fwd_to_lcd=1  type=CC chn=1 cc=16  button_mode=Toggle  range=map1  radio_group=1  lcd_pos=1:1:1 label="Transpose-  %3d"
EVENT_BUTTON id=  2  fwd_to_lcd=1  type=CC chn=1 cc=16  button_mode=Toggle  range=map2  radio_group=2  lcd_pos=1:1:1 label="Transpose+  %3d"

# Note: the map will only be considered if a button is configured for button_mode=Toggle !

# these LEDs are mapped to radio_group1 and radio_group2, and therefore will get an "automatic feedback" whenever the toggle button changes the value (or receives a new value)

#This is for the transpose minus button

EVENT_LED id=  1  range=41:41    radio_group=1
EVENT_LED id=  2  range=21:21    radio_group=1
EVENT_LED id=  3  range=0:0      radio_group=1

#This is for the transpose plus button

EVENT_LED id=  4  range=41:41    radio_group=2
EVENT_LED id=  5  range=61:61    radio_group=2
EVENT_LED id=  6  range=81:81    radio_group=2

 

 

What I have noticed in Mios is that the 0 repeats itself on a button press after reaching 0 i then press the button to go upto 21, but it gives a 0 then a 21. the same with 81 going back to 0

[1649.779] b0 10 51   Chn# 1  CC# 16 = 81
[1650.606] b0 10 3d   Chn# 1  CC# 16 = 61
[1651.496] b0 10 29   Chn# 1  CC# 16 = 41
[1652.177] b0 10 15   Chn# 1  CC# 16 = 21
[1652.676] b0 10 00   Chn# 1  CC# 16 = 0
[1654.563] b0 10 15   Chn# 1  CC# 16 = 21
[1655.289] b0 10 29   Chn# 1  CC# 16 = 41
[1655.776] b0 10 3d   Chn# 1  CC# 16 = 61
[1656.337] b0 10 51   Chn# 1  CC# 16 = 81
[1656.972] b0 10 51   Chn# 1  CC# 16 = 81
[1657.790] b0 10 3d   Chn# 1  CC# 16 = 61
[1658.428] b0 10 29   Chn# 1  CC# 16 = 41
[1659.089] b0 10 15   Chn# 1  CC# 16 = 21
[1659.853] b0 10 00   Chn# 1  CC# 16 = 0
[1660.565] b0 10 00   Chn# 1  CC# 16 = 0
[1661.122] b0 10 15   Chn# 1  CC# 16 = 21
[1661.623] b0 10 29   Chn# 1  CC# 16 = 41
[1662.162] b0 10 3d   Chn# 1  CC# 16 = 61
[1662.745] b0 10 51   Chn# 1  CC# 16 = 81
[1663.645] b0 10 51   Chn# 1  CC# 16 = 81
[1664.287] b0 10 3d   Chn# 1  CC# 16 = 61
[1664.727] b0 10 29   Chn# 1  CC# 16 = 41
[1665.045] b0 10 15   Chn# 1  CC# 16 = 21
[1665.486] b0 10 00   Chn# 1  CC# 16 = 0
[1666.271] b0 10 00   Chn# 1  CC# 16 = 0
[1666.726] b0 10 15   Chn# 1  CC# 16 = 21
[1667.069] b0 10 29   Chn# 1  CC# 16 = 41
[1667.340] b0 10 3d   Chn# 1  CC# 16 = 61
[1667.821] b0 10 51   Chn# 1  CC# 16 = 81
[1668.394] b0 10 51   Chn# 1  CC# 16 = 81
[1668.832] b0 10 3d   Chn# 1  CC# 16 = 61
[1669.152] b0 10 29   Chn# 1  CC# 16 = 41
[1669.445] b0 10 15   Chn# 1  CC# 16 = 21
[1670.023] b0 10 00   Chn# 1  CC# 16 = 0

 

It also has a a random value jump somtimes as shown here am i missing something to stop this?

[2100.260] b0 10 29   Chn# 1  CC# 16 = 41
[2100.671] b0 10 15   Chn# 1  CC# 16 = 21
[2101.061] b0 10 00   Chn# 1  CC# 16 = 0
[2101.457] b0 10 3d   Chn# 1  CC# 16 = 61
[2101.706] b0 10 51   Chn# 1  CC# 16 = 81
[2101.976] b0 10 00   Chn# 1  CC# 16 = 0

[2102.215] b0 10 15   Chn# 1  CC# 16 = 21
[2102.521] b0 10 29   Chn# 1  CC# 16 = 41
[2102.819] b0 10 3d   Chn# 1  CC# 16 = 61

Edited by ssp
Link to comment
Share on other sites

ok leds working but sometimes two are on at the same time, gotta figure this out ;)

 

ok all sorted, leds working in sequence now, i still have the issue where you get to 81, res the down and it is 81 again then 61 same from 0 upwards.

edited the code

 

RESET_HW


# the used maps:
MAP1 81 61 41 21 0
MAP2 0 21 41 61 81

# define a radio group with a single toggle button but multiple LEDs

EVENT_BUTTON id=  1  fwd_to_lcd=1  type=CC chn=1 cc=16  button_mode=Toggle  range=map1  radio_group=2  lcd_pos=1:1:1 label="Transpose-  %3d"
EVENT_BUTTON id=  2  fwd_to_lcd=1  type=CC chn=1 cc=16  button_mode=Toggle  range=map2  radio_group=1  lcd_pos=1:1:1 label="Transpose+  %3d"

# Note: the map will only be considered if a button is configured for button_mode=Toggle !

# these LEDs are mapped to radio_group1 and radio_group2, and therefore will get an "automatic feedback" whenever the toggle button changes the value (or receives a new value)

#This is for the transpose minus button

EVENT_LED id=  1  range=0:0      radio_group=2
EVENT_LED id=  2  range=21:21    radio_group=2
EVENT_LED id=  3  range=41:41    radio_group=2
EVENT_LED id=  4  range=61:61    radio_group=2
EVENT_LED id=  5  range=81:81    radio_group=2

#This is for the transpose plus button

EVENT_LED id=  5  range=81:81  radio_group=1
EVENT_LED id=  4  range=61:61  radio_group=1
EVENT_LED id=  3  range=41:41  radio_group=1
EVENT_LED id=  2  range=21:21  radio_group=1
EVENT_LED id=  1  range=0:0    radio_group=1

Edited by ssp
Link to comment
Share on other sites

I cant seem to get around the repeated values.

the ranges work with the button presses but once you get to say 81, then press the other button to go back down the values it repeates the value 81 instead of just going to 61. is there something i need to put in to stop this repeat?

 

thanks

Edited by ssp
Link to comment
Share on other sites

Hello

The purpose is to have on up and one down button cycle trigging 0 21 41 61 81 with dedicated led for each steps right ?

Maybe a script(runsection + .NGR) will be better strategy, especially to retrigg/update the "opposit" button value to match actual CC value

Otherwise you push button 1 few time (let say 2, CC val=61) but button 2 stay at 0, and if you push it once you send 21...

Best

Zam

  • Like 1
Link to comment
Share on other sites

14 hours ago, Zam said:

Hello

The purpose is to have on up and one down button cycle trigging 0 21 41 61 81 with dedicated led for each steps right ?

Maybe a script(runsection + .NGR) will be better strategy, especially to retrigg/update the "opposit" button value to match actual CC value

Otherwise you push button 1 few time (let say 2, CC val=61) but button 2 stay at 0, and if you push it once you send 21...

Best

Zam

Thanks Zam I will take a look at this today, the buttons work with the leds, I was able to understand that and get it working after a few changes. I still have a lot to read and learn, having a quiet day to day so I am going to play around with some other code as well.

Thanks again!

Si

Link to comment
Share on other sites

Lets carry on here:

I am ordering a couple of small 6x1 and 8x1 clds tomorrow.

Edit: I remembered the use of conditions from a previous post, reading up on this tomorrow and will give it a shot ;)

Lets carry on here:

I am ordering a couple of small 6x1 and 8x1 clds tomorrow.

Edit: I remembered the use of conditions from a previous post, reading up on this tomorrow and will give it a shot ;)

COND

CONDitional labels are the most powerful purpose of global label definitions - they allow to output different strings based on the EVENT value!

Following example demonstrates the purpose pretty nicely:

COND_LABEL fil_type
COND =0    "Bypass   "
COND =1    "LP 24dB  "
COND =2    "LP 12dB  "
COND =3    "BP 24dB  "
COND =4    "BP 12dB  "
COND =5    "HP 24dB  "
COND =6    "HP 12dB  "
COND =7    "Notch24dB"
COND =8    "Notch12dB"
COND =9    "Comb+    "
COND =10   "Comb-    "
COND =11   "PPG LP   "
COND_ELSE  "Type %3d "

An EVENT_* command can use it this way:

# this command is part of a .NGC file:
EVENT_ENC id=1  type=CC cc=16  lcd_pos=1:1:1 label="Filter Type: ^fil_type"

So: each value can be named, but it's also possible to define value ranges at which a string should be taken, such as:

COND_LABEL test1
COND =0   "Val is 000   %3d"
COND =1   "Val is 001   %3d"
COND =2   "Val is 002   %3d"
COND =3   "Val is 003   %3d"
COND <20  "Val is <20   %3d"
COND <=40 "Val is <=40  %3d"
COND_ELSE "else cond.   %3d"

 

Looking at this i understand the upper and lower condition tables, would you use the two tables individually or would they be combined in one string?

How would i implement this? would you have both condition tables one with labels and the other with the Val statements? or would you make a string with the label name and val syntax combined?

The COND =0 "Val is 000 %3d" I understand for the condition =0 the value is "000" this will display the label name set to this condition "id", in the table above this is "Bypass"

if the "Val is 001" then Cond -1 "LP 24db" becomes active.

both tables seperate or a combined string?

Thanks

 

Edited by ssp
Link to comment
Share on other sites

Had a really good evening learning the code structure for the condition labels, I made a new test .ngc and .ngl file and wrote a small section of code in and it all worked.

I was able to set up a set of conditional lables and also banks and set values for triggering the different lables on the press of a button or an ecoder or pot.

forwarding then to an oled or clcd of choice and also forwarding the value to an lcd matric (7 segment 3 digit display)

Some of the plug-ins i am building my controllers for have in thier gui small 1x6 and 1x8 virtual clcds so i can now replicate them in my hardware and not rely on a recieved input to show them.

Link to comment
Share on other sites

This evening I continued playing with the .NCG code and the various conditional labels code and the assignments in the .NGC file.
Using Thorstens Blofeld templates i altered a few basic things to try them out.

1. The scs encoder was not changing the bank when turned, as i dont have a blofeld to connect it too so my solution was to change a little code

I changed
enc_emu_id=2000 to enc_emu_id=2000 type=detented2 and I also hashed out this line as i didn't need it. #EVENT_LED id=2000 fwd_to_lcd=1 lcd_pos=1:1:1 label="^bank"
I was now able to change the bank.

I also change a few other sections of code and encoder id's to see what would happen if linked to a second din. All has worked and I now have a good understanding of the use of conditional labels, banks and values.
Also the use of the meta command here in this string: EVENT_ENC    id=2000  type=Meta   meta=SetBank   range=1:5.

The .NGC commands and syntax are becoming more clear to me everyday now.

My next challenge is learning NRPN's and applying them to negative values a feature in the latest update. I have also played with the -64..0..+64 today as well.

What I have found helpful is printing out all the manuals, and having them to read when not on the computer, I like to mark things up as I go.

Edited by ssp
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...