Author Topic: Help Monitoring State Within Sonar  (Read 6123 times)

Offline SonarHatesMe

  • Newbie
  • *
  • Posts: 23
Help Monitoring State Within Sonar
« on: March 14, 2015, 09:12:00 PM »
First, let me thank you, AZ, for putting the time into this controller and all the documentation.  Superb job!  That said, you undoubtedly know I'm here for your (or anyone else's) help with a problem I'm having...

I have read all of the documentation and performed all the tutorials.  I have my bank switches, shifts, rotors, sliders, and others buttons working to my liking.  What I'm hoping to accomplish could be somewhat tricky, though.

Ahem...

As per your ACT MIDI tutorial (I owe you forty clams by the way!), I have set up my controller with four rotors being used per switch.  Underneath those rotors, I have four buttons (one per channel) that I am using to mute the corresponding track. These buttons are configured as "pad," and I am using a "Value: Toggle" action configuration to switch between the "Mute:On" and "Mute:Off" modes.  I am using "Strip: Track: Mute" and the corresponding logic for busses and mains in the action configuration, but I am not convinced that "Value: Toggle" was the proper logic choice here.  Was I on the right track? I also created a software state set "Muted" with states "On" and "Off."  Back to the point, I am sending a SysEx message to my controller when I change the state of "Muted" between "On" and "Off."  The purpose of this message is to change the color of the LED on the hardware to reflect the Mute state of the software.

Now, the main problem...

Let's pretend I am controlling tracks 1-4 in WAI.  If tracks 1-4 are not muted, I want the corresponding buttons on the controller to be green to reflect this state.  Muted tracks would be reflected by a yellow colored LED for my purposes. In this example, tracks 1-4 are not muted, and tracks 5-8 are all muted in Sonar.  On my control surface, all four pads are currently green.  If I switch the WAI to control tracks 5-8, I would like the pads to all change to yellow (by delivering a SysEx message to the controller) to correspond with the mute state (all muted) of each of the tracks.  However, this seems like it would only be possible if there was some way to actually set up a monitor of Sonar's internal software state for the track, and have it be constantly monitored by AZC and send feedback. As it stands, I can make buttons switch colors when I change states, but if I change the bank, unless all of the mute buttons correspond perfectly to the prior bank, the LEDs no longer show anything meaningful.  Is there any way to get this working properly?  Am I just missing the programming logic?  I really feel like this has to come down to a way to constantly monitor Sonar's actual software mute state, but maybe I'm missing something.

Thanks for any help with this!   ;) 

Offline azslow3

  • Administrator
  • Hero Member
  • *****
  • Posts: 1679
Re: Help Monitoring State Within Sonar
« Reply #1 on: March 15, 2015, 11:21:53 AM »
You are right in all assumptions! It is just my inability to explain thing well.

So, the configuration for Pad1, in the Actions list:
  • - (Strip) WAI Track Mute
  • - (Value) Toggle, timeout touch
  • - (Monitor) Parameter Value Monitor (Ultra speed)
In the Feedback (for Pad1, it will be called "Pad1 : : Parameter Value Monitor"):
  • 'Value: 0' - SysEx (send green to pad 1)
  • 'Value: 127' - SysEx (send yellow to pad 2)

For Pad2-Pad4, it is different in "WAI Track +1...+3 Mute" and corresponding SysEx. I have just tested it with my MPK-Mini and it works as expected.

And a bit of "theory" now. We want that the control is toggling mute and its color is changed taking current Mute value from SONAR. These are 2 independent wishes since we can change Mute or WAI in Sonar. So, we first select "the parameter", Mute from some WAI dependent track. Here can be some state dependent logic, for example strip type, shift and so on processing. We use selected parameter (Mute from particular track) 2 ways: "Value" Action will work when we really engage the control and Monitor will periodically (Ultra means 13 times per second) check that the value is still the same. Once the parameter or its value is changed (by parameter I mean you change WAI and so the strip), the Feedback section will change the color.

In SONAR API, all parameter have values between 0 and 1. "Pad center" for example has value 0.5. Binary parameter like Mute have either 0 or 1 exactly. I map the range to MIDI standard range 0...127 inside system "Value" State Set. That is why you see "Value:0"/"Value:127" conditions in the feedback section.

Caution. On my MPK-mini, in case I press the pad it is highlighted and when I depress it, LED is switched off. So I had to prepend
  • 'Note:Off' - (Monitor) Reset "Pad1 : : Parameter Value Monitor" (Now)

to the list of actions. That means, once I depress the pad, the monitor is triggered, setting the color.
In case your surface is also changing colors by itself, you also need that. I still have some flickering since there is 1/13 of second between LED is off and the command to switch it on again. In real life I add corresponding MIDI sending (in addition to monitoring) directly into the logic list to avoid that flickering.

Offline azslow3

  • Administrator
  • Hero Member
  • *****
  • Posts: 1679
Re: Help Monitoring State Within Sonar
« Reply #2 on: March 15, 2015, 11:43:46 AM »
And a bit more to the topic subject.

There are System States and User states.

System states are changed by AZC internally, monitoring corresponding SONAR conditions. For example, monitoring "Loop" state it is possible to indicate either SONAR is in the Loop mode. Even if we have some pad changing the mode, "Loop" is not a parameter. So we can not "Monitor Parameter Value" in this case and need State monitoring instead.

User states are under User control. These states are not updated automatically, but in some situations it is still handy to monitor them. For example, you want Bank indication. And you have defined "Previous"/"Next"/"First"/"Last" Bank pads (the action is just corresponding Bank State change). Instead of replicating SysEx into all these controls, you can define (one) state monitor for the Bank Set.

The latest Test AZC version you can find in the Downloads has build-in Mack.. Control preset (activated inside "Tweak configuration" option, do not forget to save your current preset before doing that!). It shows the bleeding edge of AZC complexity, with almost all available tricks. The preset is imitating quite complex Mack... logic, in case you like something there (read the original SONAR Mack.. Control plug-in Help file) you can borrow the implementation from that preset (just ask me which part is relevant).

Offline SonarHatesMe

  • Newbie
  • *
  • Posts: 23
Re: Help Monitoring State Within Sonar
« Reply #3 on: March 16, 2015, 11:17:05 PM »
Thanks, AZ!  There are definitely no problems with your explanations.  Everything is working just as you said it should.  Your explanation of the logic behind the scenes of Cakewalk and AZC has left me wondering about the possibility of monitoring a state "instantaneously" as you do a parameter.  Specifically, I'm looking for a rapid monitoring solution for my bank states so that the bank number is reflected on my control surface as soon as a project is loaded in Sonar.  This currently works perfectly with the mute logic you provided above, but I must be missing something when it comes to my bank and shift states.  For the moment, my setup has a bank state monitor on the "shift" key (since I'm using it to shift banks as per your ACT Tutorial) which delivers SysEx messages to light up a row of keys on my control surface.  Also, my "shift" key has another state monitor, shift state, which sends SysEx to keep the shift key dimly lit when shift state is "Off" and brighten it when I'm actually holding it down.  In both of these cases, the keys are behaving appropriately but only after the shift key has initially been pressed.  I'd like the shift key to immediately (and always be) dimly lit every time I open a file, and I would like my bank state LEDs to all be lit up appropriately, but my current state monitoring logic is still limiting me.

Thanks again for all your help.  You've really brought my controller to life!  And to think I was pondering switching DAWs  :D


Offline azslow3

  • Administrator
  • Hero Member
  • *****
  • Posts: 1679
Re: Help Monitoring State Within Sonar
« Reply #4 on: March 17, 2015, 11:12:06 AM »
I have understood now. And congratulations, you have found a logical bug in my system! Please download the latest test version (build 151) which includes the fix.

State Monitoring is triggered on the state changes and on monitoring reset. It is logical that it should also be triggered right at the beginning, when the preset is loaded. Thanks for asking!

Offline SonarHatesMe

  • Newbie
  • *
  • Posts: 23
Re: Help Monitoring State Within Sonar
« Reply #5 on: March 17, 2015, 04:37:29 PM »
Installed 151.  Logic worked as expected upon startup.  You are the man, Alexey!