Marxon
December 29, 2013, 5:10pm
1
Hi all,
i use this script to change the function of enc=2 via button=1371 and button=1372.
.ngc
EVENT_BUTTON id= 70 hw_id= 70 type=Meta meta=SetBank range=1:2 meta=RunSection:2
EVENT_BUTTON id=1371 hw_id=1024 button_mode=toggle range=0:127 Bank=2 type=NoteOn chn=3 key=41
EVENT_BUTTON id=1372 hw_id=1017 button_mode=toggle range=0:127 Bank=2 type=NoteOn chn=3 key=42
EVENT_ENC id= 2 hw_id= 2 type=cc chn= 2 cc=111 range= 0:127
EVENT_ENC id=1371 hw_id= 2 type=cc chn=11 cc= 41 Bank=2 range= 0:127
EVENT_ENC id=1372 hw_id= 2 type=cc chn=11 cc= 42 Bank=2 range= 0:127
.ngr
if ^section == 2
if (iD)BUTTON:1371 < 1
set_active (id)Enc:1371 0
else set_active (id)Enc:1371 1
endif
if (iD)BUTTON:1372 < 1
set_active (id)Enc:1372 0
else set_active (id)Enc:1372 1
endif
endif
exit
Now the problem:
i have to push button=70 a second time before
enc=1371 and enc=1372 get updated but i like them to update allready
during hold down button=70 for the first time.
How can i achieve this?
Best regards
Marxon
T.K
December 29, 2013, 6:44pm
2
What do you mean with:
enc=1371 and enc=1372 get updated but i like them to update allready
what kind of update do you expect?
If you mean, that they should be handled by the .NGR script, then I would say that this is unexpected.
Could you please add some debug messages (via the “LOG” command) to the script and doublecheck, which parts are executed?
Best Regards, Thorsten.
Marxon
December 30, 2013, 2:02pm
3
Hi Thorsten,
somehow i killed the code, yesterday.
Now i allways get this error:
[385453.834] [MBNG_FILE_C:143] ERROR: '(iD)BUTTON' not found in event pool by 'if' command!
[385453.835] [MBNG_FILE_C:143] ERROR: invalid left value '(iD)BUTTON' in 'if' command!
[385453.836] [MBNG_FILE_R:143] stopped script execution due to previous error!
No matter what button i use in line 143. Strange…
Would you please take a look at the code?
It happens at .ngc line 10
Thank you very much!
[M³.zip](< base_url >/applications/core/interface/file/attachment.php?id=11084)
T.K
December 30, 2013, 3:25pm
4
Hi,
the .zip file contains a M3.ngc and default.ngr file.
But M3.ngc will use M3.ngr
So: could it be that you edited the wrong .ngr file (default.ngr instead of M3.ngr)?
Best Regards, Thorsten.
Marxon
December 30, 2013, 3:38pm
5
No I just forgot to rename both “M3”.*
T.K
December 30, 2013, 3:52pm
6
The button can’t be found because it has an invalid fwd_id argument, and therefore was rejected:
[79761.466] [MBNG_FILE_C:651] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.469] [MBNG_FILE_C:653] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.469] [MBNG_FILE_C:655] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.472] [MBNG_FILE_C:657] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.473] [MBNG_FILE_C:659] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.477] [MBNG_FILE_C:661] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.477] [MBNG_FILE_C:663] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.480] [MBNG_FILE_C:665] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.480] [MBNG_FILE_C:669] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.484] [MBNG_FILE_C:671] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.484] [MBNG_FILE_C:673] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.487] [MBNG_FILE_C:675] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.487] [MBNG_FILE_C:677] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.491] [MBNG_FILE_C:679] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.491] [MBNG_FILE_C:681] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.554] [MBNG_FILE_C:683] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.554] [MBNG_FILE_C:813] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.557] [MBNG_FILE_C:815] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.557] [MBNG_FILE_C:817] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.561] [MBNG_FILE_C:819] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.561] [MBNG_FILE_C:821] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.564] [MBNG_FILE_C:823] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.564] [MBNG_FILE_C:825] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.568] [MBNG_FILE_C:827] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.568] [MBNG_FILE_C:831] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.571] [MBNG_FILE_C:833] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.571] [MBNG_FILE_C:835] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.575] [MBNG_FILE_C:837] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.575] [MBNG_FILE_C:839] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.578] [MBNG_FILE_C:841] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.578] [MBNG_FILE_C:843] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
[79761.846] [MBNG_FILE_C:845] ERROR: invalid fwd_id controller name in EVENT_BUTTON ... fwd_id=<LED
It seems that the displayed line numbers are not correct (I’ve to fix this)
But if you search for “fwd_id=<”, you will find the wrong definitions.
After correcting the syntax, “run 2” is executed without error
Best Regards, Thorsten.
Marxon
December 30, 2013, 4:02pm
7
Aha! I totally overlooked those"<" and “>”, damn!
Marxon
December 30, 2013, 5:38pm
8
Ok i changed the .ngr
if ^section == 2
log "Section is 2"
if (iD)BUTTON:1371 < 1
set_active (id)Enc:1371 0
log "deactivated"
else
set_active (id)Enc:1371 1
log "activated"
endif
endif
This the output:
Hold button 70 pressed
“Section is 2”
“de/activated” (depending on actually status)
Press button1371
“nothing”
Release button 70
“de/activated” (status toggled)
It seems Set_active is executed to late.
It should be executed after pressing button 1371.
T.K
December 30, 2013, 6:05pm
9
Well, in your .ngc setup the section is only executed with button id=70
You could execute it with id=1371 as well (just configure it as a meta event); the CC event could be sent with the “send <midi-event>” command from the .ngr script.
Best Regards, Thorsten.
Marxon
December 30, 2013, 6:31pm
10
Do i need the CC midi out event at all, because i want to use the button only for the “if” condition to /deactivate Enc1371?
T.K
January 1, 2014, 9:10pm
11
No, you don’t need it.
I don’t know why you assigned a CC to this event… if not necessary, why not triggering RunSection:2 with this button?
Best Regards, Thorsten.
Marxon
January 4, 2014, 12:50am
12
Ok thank you again Thorsten!
Its working without the CC too.
I also managed the refresh problem.
To sum up:
I have
-one “shift” button button id=26
-two “encoder on/off” buttons hw_id=1024, hw_id=1017
-one multi porpose encoder hw_id=1
Pressing the “shift” button together with one “encoder on/off” button
de/activates a function of the multi porpose encoder.
.ngc
EVENT_BUTTON id=1371 hw_id=1024 button_mode=toggle range=0:127 Bank=2 type=meta meta=runsection:101
EVENT_BUTTON id=1381 hw_id=1024 bank=2 chn=3 label="^std_btn" fwd_id=LED:1217
#Encoder 1 on/off
EVENT_BUTTON id=1372 hw_id=1017 button_mode=toggle range=0:127 Bank=2 type=meta meta=runsection:102
EVENT_BUTTON id=1382 hw_id=1017 bank=2 chn=3 label="^std_btn" fwd_id=LED:1218
#Encoder 2 on/off
EVENT_ENC id=1371 hw_id=1 type=cc chn= 11 cc= 71 Bank=2 range= 0:127 enc_mode=Inc00Speed_Dec40Speed enc_speed_mode=fast:4 lcd_pos=1:1:1 label="^std_enc"
#Multi porpose encoder function 1
EVENT_ENC id=1372 hw_id=1 type=cc chn= 11 cc= 72 Bank=2 range= 0:127 enc_mode=Inc00Speed_Dec40Speed enc_speed_mode=fast:4 lcd_pos=1:1:1 label="^std_enc"
#Multi porpose encoder function 2
EVENT_BUTTON id= 26 hw_id= 26 type=Meta meta=SetBank range=1:2 lcd_pos=1:1:1 label="^std_btn"
# Shift Button
.ngr
if ^section == 101
LOG "Volume 1"
if (iD)BUTTON:1371 < 1
set_active (id)Enc:1371 0
LOG "VolumeENC 1 off"
else set_active (id)Enc:1371 1
LOG "VolumeENC 1 on"
endif
endif
if ^section == 102
LOG "Volume 2"
if (iD)BUTTON:1372 < 1
set_active (id)Enc:1372 0
LOG "VolumeENC 2 off"
else set_active (id)Enc:1372 1
LOG "VolumeENC 2 on"
endif
endif
Everything is working except that after release the shift button and press it again, then all encoders are “activated” again, regardless their previous state.
I hope my problem is understandable if not i can write it in german again
Best regards
Marxon
T.K
January 4, 2014, 6:38pm
13
Good progress!
Everything is working except that after release the shift button and press it again, then all encoders are “activated” again, regardless their previous state.
This shouldn’t happen if you remove “Bank=2” from the EVENT_ENC statements which should be controlled from the .NGR script.
Because with “Bank=2” the encoders will be part of the bank, and therefore automatically activated on each bank switching.
Best Regards, Thorsten.
Marxon
January 5, 2014, 7:57am
14
Thanks for your patience, Thorsten!
This is the new code:
EVENT_BUTTON id=1371 hw_id=1024 range=0:127 Bank=2 type=meta meta=runsection:101 button_mode=toggle
#Encoder 1 on/off
EVENT_ENC id=1371 hw_id=1 range=0:127 chn=11 cc=71 type=cc enc_mode=Inc00Speed_Dec40Speed enc_speed_mode=fast:4
#Multi porpose encoder function 1
EVENT_BUTTON id= 26 hw_id= 26 range=1:2 type=Meta meta=SetBank lcd_pos=1:1:1
# Shift Button
if ^section == 101
LOG "Volume 1"
if (iD)BUTTON:1371 < 1
set_active (id)Enc:1371 0
set_active (id)LED:1217 0
LOG "VolumeENC 1 off"
else set_active (id)Enc:1371 1
set_active (id)LED:1217 1
LOG "VolumeENC 1 on"
endif
endif
New code, new problem:
Disabling the encoder works but it does not get reactivated after pressing button id=1371 again.
Although i receive “VolumeENC 1 on”, nothing is sent when the encoder is moved.
But why?
T.K
January 5, 2014, 10:19pm
15
I will try this out tomorrow.
Best Regards, Thorsten.
Marxon
January 9, 2014, 10:56am
16
Hi again,
have you tried it Thorsten?
EDIT:
It works with an additional
set_active (id)Enc:1371 1
in the first condition.
Although it should not be necessary, right?
if ^section == 101
LOG "Volume 1"
set_active (id)Enc:1371 1
if (iD)BUTTON:1371 < 1
set_active (id)Enc:1371 0
set_active (id)LED:1217 0
LOG "VolumeENC 1 off"
else set_active (id)Enc:1371 1
set_active (id)LED:1217 1
LOG "VolumeENC 1 on"
endif
endif
Best regards
Marxon
T.K
January 11, 2014, 9:35pm
17
Ok, now it’s clear to me what is going wrong here:
else set_active (id)Enc:1371 1
The parser doesn’t read commands after an ELSE statement.
On the other hand, it didn’t complain about the command - and this caused the confusion at your side.
Here a new version which prints an error message whenever a command is detected after ELSE or ENDIF
-> http://www.ucapps.de/mios32/midibox_ng_v1_029_pre3.zip
Best Regards, Thorsten.
Marxon
January 11, 2014, 10:35pm
18
Good to know!
I often use commands after ELSE statements.
This maybe also explain one or other strange behavior…
Thanks Thorsten!
Best regards
Marxon