tago

Please help me to understand how the NG app works internally

29 posts in this topic

Hi,

i'm too dump to understand how the NG apps works internally.

I want to change the keyboard transpose parameter within the NG app, but can't figure out how to do it.

There seems to be an event system where the kb_transpose parameter is used, but i've no idea where its value comes from and how i can change that value.

It looks like this parameter can be changed via .ngr script (set_kb_transpose) though. But that doesn't help me i suppose.

I'm simply lost.

 

Thanks in advance

 

Edit. i've already posted about it here:

 

Edited by tago

Share this post


Link to post
Share on other sites

Hi,

you don't need to change the existing code to do this, just use the "set_kb_transpose" command in a NGR script.

Following example demonstrates this: https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/cfg/tests/kb_6.ngr

And here the corresponding events which trigger the ^sections: https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/cfg/tests/kb_6.ngc

Best Regards, Thorsten.

Share this post


Link to post
Share on other sites
1 hour ago, TK. said:

Hi,

you don't need to change the existing code to do this, just use the "set_kb_transpose" command in a NGR script.

Following example demonstrates this: https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/cfg/tests/kb_6.ngr

And here the corresponding events which trigger the ^sections: https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/cfg/tests/kb_6.ngc

Best Regards, Thorsten.

Hi Thorsten,

thank you for your reply.

I want to trigger transpose changes via hardware switches connected to J5a/b core ports. As i understand it, it is not possible to assign these switches in ngr/ngc scripts. Or is this still possible?

Here is my original post about it:

 

 

 

Edited by tago

Share this post


Link to post
Share on other sites
20 minutes ago, TK. said:

This should be possible, just configure the analog inputs and trigger the NGR function via an EVENT_AIN

You could change the value range and enable the filter function to avoid unintended triggers, a demo can be found here: https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/cfg/tests/ain_fsr.ngc

Best Regards, Thorsten.

As i use tact switches: will this also work for tact switches or toggle switches only? Does the ain_fsr.gc example take care of the tact switch issue using " filter delay of 20 mS " ?

Sorry, i'm a little overwhelmed by all of this.

 

Edit: i also need to enable/disable two status LEDs connected to J5a/b.

 

 

Edited by tago

Share this post


Link to post
Share on other sites

This example should also work with tact switches.

For LEDs you could just use J10B

Best Regards, Thorsten.

Share this post


Link to post
Share on other sites

Thanks @TK.

i already made a board that connects to a single J5 port. It has two LEDs and two tact switches on it.

If i understand correctly the LEDs can't be controlled via NGR.

So i need to do that via custom code? Maybe using the 006_rtos_tasks tutorial as implementation guide.

I've already written some pseudo code here:

If this is the correct way of doing it, i'd need to know how to the get kb_transpose value.

Share this post


Link to post
Share on other sites

IO Pins are not initialized in your pseudo code.

But regardless of this, it will result into the problem that the MBNG application will overwrite IO configurations from different places - and even if we find quick&dirty hacks which avoid such overwrites, you would have to re-do the changes whenever a new firmware version is released.

Therefore I recommend to go the common way and to use the existing app like it was intended.

Alternatively I could consider to natively support J5 as digital IO in a proper way (which will require changes at many places that I've to work out by myself...)

Best Regards, Thorsten.

Share this post


Link to post
Share on other sites
Just now, TK. said:

IO Pins are not initialized in your pseudo code.

That's true. I omitted that part in my example. But i already got the two LEDs working following the 008_j5_outputs tutorial. But this was only to test if its working at all.

 

If there is no better solution i suppose i have to use two different strategies at the same time. One for the switches using NGR scripts and another for the LEDs using custom code. The LED handler would only read (get) kb_transpose, not alter it. But yeah, sounds like some dirty hack in the end.

If you could add digital IO support that would be very nice. I assume others would like that addition too.

Do you think you could do it?

Share this post


Link to post
Share on other sites

Yes, for me it will be straightforward - I'm just a bit worried that than more options I'm adding, than more complicated for others to understand the configuration... ;-)

Tomorrow I'm planning a change for CV handling anyhow, if nothing else happens, I will add J5 IOs as well

Best Regards, Thorsten.

Share this post


Link to post
Share on other sites

I very much appreciate your help @TK.

It would be very nice of you if you would add these new options. I mean, it can't get any more complicated ;)

Will i be able to change kb_transpose and enable/disable indicator LEDs reflecting the current value of kb_transpose if you are ready? It looks like If-else statements are supported in NGR.

Share this post


Link to post
Share on other sites

Yes, this will be possible - it's exactly the intention behind NGR to allow users such customizations without touching the application code.

Best Regards, Thorsten.

Share this post


Link to post
Share on other sites

New version can now be found here: http://www.ucapps.de/mios32/midibox_ng_v1_037_pre4.zip

It's now possible to mix input and outputs on a single port as shown in this example: https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/cfg/tests/diocfg_3.ngc

And J5 is supported as well (called J5AB) - it's even possible to mix digital with analog functions -> https://github.com/midibox/mios32/blob/master/apps/controllers/midibox_ng_v1/cfg/tests/diocfg_4.ngc

In your case, please keep the analog pins disabled

Best Regards, Thorsten.

Share this post


Link to post
Share on other sites

Just tried it.

Both LEDs are lit up and look dimmed. Does the dimming occure due to emulated SR?

Otherwise i think the LEDs should be off and only light up when a button is pressed with my config. Maybe i'm wrong.

Here is my config

# J5A PORT SETUP
# J5.A0 -> octave up switch
# J5.A1 -> octave up LED
# J5.A2 -> octave down switch
# J5.A3 -> octave down LED

# now enable DIOs (0 = input / 1 = output)
DIO  port=J5AB  emu_din_sr=1  emu_dout_sr=1  output_mask=01010000

# button events (DIN SR1 pins are assigned to hw_id=1/3)
EVENT_BUTTON id=1  hw_id=1  type=CC chn=1 cc=16 range=0:127  fwd_id=LED:3
EVENT_BUTTON id=2  hw_id=3  type=CC chn=1 cc=17 range=0:127  fwd_id=LED:4

# LED events (DOUT SR1 pins are assigned to hw_id=2/4)
EVENT_LED    id=3  hw_id=2  type=CC chn=1 cc=16 range=0:127
EVENT_LED    id=4  hw_id=4  type=CC chn=1 cc=17 range=0:127

 

 

Share this post


Link to post
Share on other sites

I'm afraid pressing one of the switches to test them. I fear something will short and the core explodes. Can that happen or is it save?

Edited by tago

Share this post


Link to post
Share on other sites

No, don't worry, outputs are protected against shorts internally.

Just tried your configuration, it works after changing fwd_id=LED:3 to fwd_id=LED:2 (we always forward to a hw_id)

RESET_HW

# J5A PORT SETUP
# J5.A0 -> octave up switch
# J5.A1 -> octave up LED
# J5.A2 -> octave down switch
# J5.A3 -> octave down LED

# now enable DIOs (0 = input / 1 = output)
DIO  port=J5AB  emu_din_sr=1  emu_dout_sr=1  output_mask=01010000

# button events (DIN SR1 pins are assigned to hw_id=1/3)
EVENT_BUTTON id=1  hw_id=1  type=CC chn=1 cc=16 range=0:127  fwd_id=LED:2
EVENT_BUTTON id=2  hw_id=3  type=CC chn=1 cc=17 range=0:127  fwd_id=LED:4

# LED events (DOUT SR1 pins are assigned to hw_id=2/4)
EVENT_LED    id=3  hw_id=2  type=CC chn=1 cc=16 range=0:127
EVENT_LED    id=4  hw_id=4  type=CC chn=1 cc=17 range=0:127

As you can see, I also added "RESET_HW" to ensure that previous settings are undone.

The LEDs shouldn't be dimmed.

Best Regards, Thorsten.

Share this post


Link to post
Share on other sites

Thanks Thorsten.

When i uncomment all events, the LEDs are still lit. It's strange.

Share this post


Link to post
Share on other sites

Since i already have configurations for DIO Matrix (keyboard) and AINSER8 modules (these modules are currently not connected to the core), could it be that there are conflicts related to emu_din_sr/emu_dout_sr? When i press the buttons connected to J5A note on/off events are triggered.

Edit: uncommenting EVENT_KB stops those random note triggers.. really strange

Edited by tago

Share this post


Link to post
Share on other sites

I removed all other configs and tried to link the buttons to NGR scripts for testing purposes, which was not successful.

NGC

EVENT_BUTTON id=1  hw_id=1  type=Meta  meta=RunSection:1  button_mode=OnOnly
EVENT_BUTTON id=2  hw_id=3  type=Meta  meta=RunSection:2  button_mode=OnOnly

NGR

if ^section == 0
  LOG "NGR script running..."
endif

if ^section == 1
  LOG "NGR section 1"
endif

if ^section == 2
  LOG "NGR section 2"
endif

 

The RunSections are not triggered.

Edited by tago

Share this post


Link to post
Share on other sites

Could you please post your complete .NGC and .NGR file? I will check it tomorrow...

Best Regards, Thorsten.

Share this post


Link to post
Share on other sites

Ok, i got it working. I just quit MIOS Studio, disconnected the core and than restarted everything.

There is some strange stuff going when i edit and save NGC/NGR scripts in MIOS Studio. It looks like sometimes the core is not restarted/refreshed correctly. I've no idea what the problem is.

 

 

Share this post


Link to post
Share on other sites

Here is my simplified NGC. (NGR posted above)

I removed everything not related to the remaining problem (enabled and dimmed LEDs).

If upload this config both LEDs are lit and dimmed. But when i uncomment KEYBOARD n=1 ... all J5A related scripts work as expected.

Could there be a conflict regarding the shift registers?

# Reset to default
RESET_HW

# KEYBOARD hardware
KEYBOARD n=1   rows=8  dout_sr1=1  dout_sr2=2  din_sr1=1  din_sr2=2  din_inverted=1  break_inverted=0  din_key_offset=32 \
               scan_velocity=1  scan_optimized=0  note_offset=36 \
               delay_fastest=5  delay_fastest_black_keys=0  delay_slowest=100

EVENT_KB id=1  type=NoteOn chn=1 key=any use_key_number=1 range=0:127  lcd_pos=1:1:1 label="Note %n"

# J5A PORT SETUP
# J5.A0 -> octave up switch
# J5.A1 -> octave up LED
# J5.A2 -> octave down switch
# J5.A3 -> octave down LED

# now enable DIOs (0 = input / 1 = output)
DIO  port=J5AB  emu_din_sr=1  emu_dout_sr=1  output_mask=01010000

# button events (DIN SR1 pins are assigned to hw_id=1/3)
EVENT_BUTTON id=1  hw_id=1  type=CC chn=1 cc=16 range=0:127  fwd_id=LED:2
EVENT_BUTTON id=2  hw_id=3  type=CC chn=1 cc=17 range=0:127  fwd_id=LED:4
#EVENT_BUTTON id=1  hw_id=1  type=Meta  meta=RunSection:1  button_mode=OnOnly
#EVENT_BUTTON id=2  hw_id=3  type=Meta  meta=RunSection:2  button_mode=OnOnly

# LED events (DOUT SR1 pins are assigned to hw_id=2/4)
EVENT_LED    id=3  hw_id=2  type=CC chn=1 cc=16 range=0:127
EVENT_LED    id=4  hw_id=4  type=CC chn=1 cc=17 range=0:127

 

 

Share this post


Link to post
Share on other sites

Yes, there is a conflict with the shift register assignments.

Try this one:

# now enable DIOs (0 = input / 1 = output)
DIO  port=J5AB  emu_din_sr=9  emu_dout_sr=9  output_mask=01010000

# button events (DIN SR1 pins are assigned to hw_id=65/67)
EVENT_BUTTON id=65  hw_id=65 type=CC chn=1 cc=16 range=0:127  fwd_id=LED:66
EVENT_BUTTON id=67  hw_id=67 type=CC chn=1 cc=17 range=0:127  fwd_id=LED:68
#EVENT_BUTTON id=65  hw_id=65 type=Meta  meta=RunSection:1  button_mode=OnOnly
#EVENT_BUTTON id=67  hw_id=67 type=Meta  meta=RunSection:2  button_mode=OnOnly

# LED events (DOUT SR1 pins are assigned to hw_id=66/68)
EVENT_LED    id=66  hw_id=66 type=CC chn=1 cc=16 range=0:127
EVENT_LED    id=68  hw_id=68 type=CC chn=1 cc=17 range=0:127

Best Regards, Thorsten.

Share this post


Link to post
Share on other sites

Thank you very much @TK.

I'll give it a try later.

I'm a little baffled how the SRs and IDs relate to each other and would like to understand how you determined that emu_din_sr/emu_dout_sr must be 9 (and the IDs continue at 65). Does the KEYBOARD config occupy 64 IDs somehow?

Is there something to read in the docs about that?

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now