Author Topic: Repeating command  (Read 668 times)

Offline dee3d

  • Newbie
  • *
  • Posts: 8
Repeating command
« on: May 02, 2023, 10:38:07 AM »
Hi! I was wondering if there's a more or less simple way to repeat a certain command after, say, 1 sec of waiting as long as you keep the control pressed, pretty much like keyboard keys work? I've assigned a pad to a zoom level and would like it to work the way so when you keep the pad pressed after a short pause it starts continuously zooming as long as I hold it down?

Offline azslow3

  • Administrator
  • Hero Member
  • *****
  • Posts: 1686
Re: Repeating command
« Reply #1 on: May 02, 2023, 11:29:02 AM »
Simple - no. I mean in practice that is under one minute to configure, but that can't be called "simple"  ;)

An example is attached.

Obviously you need a button/pad which is "momentary", do send different MIDI when pressed and released (assuming 127 and 0 values respectively). You need to re-assign
MIDI to the button in the example to test.

The explanation.
The control has to be "Pad" type (Options Tab). In this case "0" and "127" are automatically set "Note" Software Set into "On"/"Off".
All Actions by default have "Note:On" Condition, so when you assign momentary button/pad and configure it, releasing is completely ignored (no actions executed).
For the purpose we need special processing for release. But let me explain Actions in the example in the order:
* Monitor/Timer Once is something we can call with delay. It will not re-trigger itself, we could make it as such but for repeat action that is more complicated.
Monitor Actions are executed in special environment (there is a good reason for that, but it is too lengthy to explain here). In this particular timer we just
"Loop send" the same MIDI, so imitating the button is pressed again. (In the Feedback tab) note the options "<Use ctrl MIDI>", value "127" and "loop".
* when physical button is releases "Note" will be set to "Off" (as explained previously). So we explicitly set that as the condition for the second Action. We
reset our Timer to "normal", which since it is "once" means just disarm it. Note that is "Final" action (* in the label, related option set). Not really necessary in this
example, later Actions will be ignored in any case (they have implicit "Note:On" condition), but explicitly specify we want stop here.
* In case we press the button for the first time or the Timer has imitated the press, we arm the timer (the first time or again) with ~1 second delay
* the rest is what you want repeat, in this example "Zoom in".

I hope that helps and not too overwhelming to  understand/use.

Offline dee3d

  • Newbie
  • *
  • Posts: 8
Re: Repeating command
« Reply #2 on: May 02, 2023, 11:44:48 AM »
Works nicely, thanks so much for your time, Alexey! Judging by the code though, this is certainly not something I could have come with on my own, this whole Feedback thing is currently way over my head :)

Offline azslow3

  • Administrator
  • Hero Member
  • *****
  • Posts: 1686
Re: Repeating command
« Reply #3 on: May 02, 2023, 02:12:08 PM »
Check tutorials board, there are some examples with explanations.
Originally "Logic" is something executed as the reaction on incoming MIDI messages. "Feedback" in general is something executed for other reasons (timer or some controller independent changes in the project). Here all Surface APIs (I mean in all languages and DAWs) use the same approach. But AZ Controller use environment dependent execution (the same Action works differently in different environments, I personally have learn the approach from FORTH programming language), so "Logic" and "Feedback" and heavily mixed. That makes the "code" way shorter, but understanding how to write it way harder (may be the reason why FORTH is not popular).