Jump to content

proper use of button type=toggle as dummy


m.str

Recommended Posts

This seems almost too basic inquire about, but I just can't get my head around how the switching of a dummy button's state back to zero can be done after it has been triggered for the first time to switch from zero to one. The code below is my basic approach, which works up to the point that button 1 has been toggled from 0 to 1. Only then does the 2nd receiver react etc. I think this is clear. But the push of the hardware encoder identified by receiver 1 should obviously also be able to toggle the button back to state 0. How do you guys do this?

 

#receiver to accept mackie knob push
EVENT_RECEIVER id= 1 fwd_id=SENDER:1 type=NoteOn chn=1 key= 45 range= 0:127
#letting through only 127 to prevent a double triggering by the note off (vel 0) event
EVENT_SENDER id= 1 hw_id= 1 type=Meta if_equal=RECEIVER:1:127 meta=SendEvent:BUTTON:1:0:1
EVENT_BUTTON id= 1 type=CC button_mode=Toggle range= 0:1

#this receiver will only work after button 1 has been triggered
EVENT_RECEIVER id= 2 fwd_id=SENDER:2 type=NoteOn chn=1 if_equal=BUTTON:1:1 key= 44 range= 127:127
EVENT_SENDER id= 2 type=CC range=0:127

 

It can not be that complicated I'm probably missing something syntax-wise. And I know this could also be handled by an NGR script, but I have a feeling that I am thinking too complicated. Could anyone maybe show an example of how he/she used a dummy button to enable/disable a functionality in his/her project? Any excerpts would be highly appreciated!

 

EDIT: Ok, so I think this example is a bit more tidied up..

#receiver to accept mackie knob push
EVENT_RECEIVER id= 1 bank= 0 fwd_id=SENDER:1 type=NoteOn chn=1 key= 45 range= 0:1
EVENT_SENDER id= 1 hw_id= 1 bank= 0 fwd_id=BUTTON:1 if_equal=RECEIVER:1:1

#dummy button
EVENT_BUTTON id= 1 bank= 0 type=CC button_mode=Toggle range= 0:1


#if the dummy is not highlighted (value=0) select it and set its value to 1
EVENT_SENDER id= 4 hw_id= 2  type=Meta meta=SendEvent:BUTTON:1:1:1

#if the dummy is highlighted (value=1) select it and set its value to 0
EVENT_SENDER id= 5 hw_id= 2  type=Meta meta=SendEvent:BUTTON:1:0:0


EVENT_RECEIVER id= 10 fwd_id=SENDER:10 type=NoteOn chn=1 if_equal=BUTTON:1:1 key= 44 range= 0:127
EVENT_SENDER id= 10 type=CC range=0:127

EVENT_RECEIVER id= 11 fwd_id=SENDER:11 type=NoteOn chn=1 if_equal=BUTTON:1:0 key= 46 range= 0:127
EVENT_SENDER id= 11 type=CC range=0:127

On program startup the Button's value is 0, so key 46 can be triggered (44 is disabled) and after triggering key 45 the button's value is set to 1, as intended.Thus, key 46 is disabled and key 44 now triggerable. But another push on key 45 does not revert the effect! The problem has to lie somewhere in the SENDERs 4&5, but I still do not get how else it should be done.

Edited by m.str
Link to comment
Share on other sites

Hello

I'm not sure to understand what logic/function you want to achieve by reading your NGC code.

Can you describe the user level logic you need ?

(I see CC definitions type=cc, but without number definition: cc= )

Best

Zam

Link to comment
Share on other sites

Hello Zam,

1 hour ago, Zam said:

(I see CC definitions type=cc, but without number definition: cc= )

In BUTTON:1's case I honestly just set it up like that, because from how I understand it has to have "some" type, although it's supposed to be used merely as boolean. For the SENDERs 10&11 it was also chosen rather arbitrarily, in order have something pop up in the MIOS MIDI In monitor, to see which one (or rather which underlying RECEIVER, which receives Note On/Off messages from the hardware controller) is enabled/disabled.

I went on a little with my thinking and tried an approach that omits the toggle idea (although I still firmly believe that this is possible somehow!) and wrote down another idea which is actually closer to what will be required in the actual project:

NGC

RESET_HW

#home button (Control Button on C4)
EVENT_RECEIVER id= 4000 type=NoteOn chn=1 key= 15 fwd_id=SENDER:4000
EVENT_SENDER id= 4000 if_equal_stop_on_match=RECEIVER:4000:127 type=Meta meta=RunSection:0

#pgrm mode select with simultaneous dump request for currently selected program
EVENT_RECEIVER id= 3000 bank= 0 fwd_id=SENDER:3000 type=NoteOn chn=1 key= 32 range= 0:127
EVENT_SENDER id= 3000 type=SysEx stream="0xf0 0x42 0x30 0x24 0x4e 0x04 0x10 0xf7 0xf0 0x42 0x30 0x24 0x10 0xf7" ports=0100010000000000 label="PrgrmMode enter"
EVENT_SENDER id= 3001 hw_id= 3000 if_equal_stop_on_match=RECEIVER:3000:127 type=Meta meta=RunSection:1

#single (currentprogram) dump requester for continuous retriggeration
EVENT_SENDER id= 4001 bank=1 type=SysEx stream="0xf0 0x42 0x30 0x24 0x10 0xf7" ports=0100010000000000 label="Current Prgrm Dump Request"
#current program dump receiver
EVENT_RECEIVER id= 4001 bank=1 type=SysEx stream="0xf0 0x42 0x30 0x24 0x40 ^dump 0xf7" ports=0100010000000000 label="Current Program Dump received"

#prints the "Delay" string on 2nd display 6th slot upper line
#has to be triggered by ngr script
EVENT_SENDER id= 1 bank=1 type=SysEx stream="0xf0 0x00 0x00 0x66 0x17 0x31 0x23 ^label 0xf7" ports=1000100000001000 label="Delay"

#prints Delay value on 2nd display 6th slot lower line
EVENT_SENDER id=101 bank=1 type=SysEx stream="0xf0 0x00 0x00 0x66 0x17 0x31 0x5b ^macdis 0xf7" syxdump_pos=4001:14 ports=1000100000001000

#knob turn on Mackie C4 causing relative and speed dependant value (>64 & <64)
EVENT_RECEIVER id= 1 bank=1 type=CC chn=1 cc=13 range= 0:127 ports=1000100000001000 label="Delay value changer"

#dummy endoder which gets modified by NGR script depending on what comes from CC 13
EVENT_ENC id= 1 bank=1 fwd_id=SENDER:201 type=CC range=0:89 syxdump_pos=4001:14
#Sender to refresh the modified value with a 41paramChange function sysex stream
EVENT_SENDER id= 201 fwd_id=SENDER:4001 bank=1 if_equal=RECEIVER:101:127 type=SysEx stream="0xf0 0x42 0x30 0x24 0x41 0x05 ^val 0x00 0xf7" ports=0100010000000000

#the push of this button finally enables the sending of the sysex stream that changes the parameter's #value
EVENT_RECEIVER id= 101 bank=1 type=NoteOn chn=1 key= 45 range= 0:127

 

NGR

if ^section == 0
 set ^bank 0
 log section 0 running
endif

if ^section == 1
 set ^bank 1
 log section 1 running
 trigger SENDER:1
 if RECEIVER:1 > 0
  if RECEIVER:1 < 63
   log "less than 63"
   set ENC:1 [ENC:1 + 1]
  else
   log "more than 63"
   set ENC:1 [ENC:1 - 1]
  endif
 endif
endif

 

Unfortunately, this does not work either. After section 1 has been entered (and thus, bank was switched to "1" etc.) it should be possible to move the Encoder identified by RECEIVER:1 to change ENC:1's value with the aid of the NGR script. This ENC's value is set to a certain range which matches the range of the synthesizer's parameter that I try to remotely modify here with the Mackie. THE MAIN PROBLEM with all of that, is that the Mackie sends relative, not absolute, values (that's what I tried to cope with the NGR script, and that's why the ENC:1 works as a dummy, that initially gets the current parameter value from the sysex dump). So the Mackie is actually supposed to in-/decrement the dummy Encoder and then after that, SENDER:201 sends out a "Parameter Change"-SysEx stream to the synthesizer with the updated value.This also gets forwarded to SENDER:4001, which then re-requests the dump, that then gets saved into RECEIVER:4001's dump, which will be used for the display values... and so on.

In the beginning of this workaround I did not have last RECEIVER:101, so that led to a terrible loop where the dumpRequest->usingDumpRequestValues->passingItOnToTheParamChangeFunc->dumpRequest was just being retriggered at every cycle of the application, not allowing anything else to happen. That was a logical outcome, unfortunately. Still the introduction of RECEIVER:101 (which equals a push on one of the MAckie's  encoders, which would have been something like a "confirm parameter change" button, if t had worked).

Interestingly enough, the changing of the ENC by the MAckie's relative value messages works TO SOME EXTENT. This is what I get out of it in the MIDI In monitor:

relVal.PNG.8777e2ecbedb79587542a4ac01db0

The CC value (which for whatever reason is CC#48, I did not set ENC:1 to that...) "swings" between 21 and 23 although its range is set to 0:89. Sometimes it takes thevalue of 1, which can not be seen in this picture.

Hopefully the usecase is a bit clearer now and maybe someone has encountered a similar problem and has a nifty idea on how this can be either solved or avoided.

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...