No internet connection
  1. Home
  2. How to

How to create a HUI command for PLAY, STOP, REWIND etc

By Fokke van Saane @Fokke
    2018-10-20 13:38:58.893Z

    I'd like to create a command for play, stop, rewind that is also works when PT is in the background.
    In Keyboard Maestro i use MIDI commands, as PT recieves this also when it is not in focus. But there is a bug in PT on this so i like to use SF using HUI instead. How do i make a (HUI) command for

    • PLAY
    • STOP
    • REWIND

    The nice thing about a separate play and stop command is that when PT is playing and you press "PLAY" it will play again for the insert point. Using a STOP/PLAY (like the space bar) means i have to press twice. HUI (or midi-transport) has this option.

    Solved in post #2, click to view
    • 16 replies
    1. Hi @Fokke.

      We should create built in actions for this, but for now you can do it like this:

      
      function huiClick(zone, port) {
          sf.midi.huiSend({
              midiBytes: [
                  0xb0, 0x0f, zone, /* Select zone */
                  0xb0, 0x2f, 0x40 + port, /* Port on */
                  0xb0, 0x0f, zone, /* Select zone */
                  0xb0, 0x2f, 0x00 + port, /* Port off */
              ]
          });
      }
      
      //huiClick(0x0e, 0x04); //play
      //huiClick(0x0e, 0x03); //stop
      //huiClick(0x0e, 0x02); //forward
      //huiClick(0x0e, 0x01); //rewind
      

      Simply uncomment the call you want to make at the bottom

      Reply2 LikesSolution
      1. I think I'll make a HUI package actually. That would be a nice concept for a package.

        1. Haha and now I have published a package with those 4 scripts, including documentation. From idea to publish - 5 minutes - yay :)

          The package is called "HUI Commands"

          1. Fokke van Saane @Fokke
              2018-10-21 15:23:45.553Z

              You are ridiculously fast

              1. Fokke van Saane @Fokke
                  2018-10-21 15:38:36.878Z

                  Question.
                  I use my stream deck for these play and stop and rewind buttons. I launch the web trigger. But for rewind i have a downside, the web trigger is a single-fire button. It does not see that i keep pressing it, so it rewinds a single frame. I would like to keep rewinding it until i let it go.
                  I read that you are working on stream deck integration. Is that already in function?

                  1. @Fokke still working on it! The Elgato people say they will open up the beta later this fall but the SF integration is still under way and the Stream Deck beta is still under wraps. I am working on being allowed to invite some of you beta testers from here to help beta test the integrations / the new SD version, but it's gonna be at least a few more weeks I think

                    1. Fokke van Saane @Fokke
                        2018-10-21 17:43:41.944Z

                        OK thanks.

                        When i assign functionkey20 to it in stream Deck and use F20 as trigger it works. But rewind is very slow. Compare it to the keypad1 key!
                        I think it does a key press-key release in the command itself that makes it slow.
                        Any other way to work around this?

                        1. You could experiment with using two different triggers/commands (for now until it all is fully supported).

                          function huiClickDown(zone, port) {
                              sf.midi.huiSend({
                                  midiBytes: [
                                      0xb0, 0x0f, zone, /* Select zone */
                                      0xb0, 0x2f, 0x40 + port /* Port on */
                                  ]
                              });
                          }
                          function huiClickUp(zone, port) {
                              sf.midi.huiSend({
                                  midiBytes: [
                                      0xb0, 0x0f, zone, /* Select zone */
                                      0xb0, 0x2f, 0x00 + port /* Port off */
                                  ]
                              });
                          }
                          
                          //To start rewinding:
                          huiClickDown(0x0e, 0x01);
                          
                          //To stop rewinding:
                          huiClickUp(0x0e, 0x01);
                          
                          1. Fokke van Saane @Fokke
                              2018-10-21 18:02:01.145Z

                              Thanks.
                              With the help of Keyboard Maestro for Key Up and key Down actions this should be possible, let me try.

                              1. Fokke van Saane @Fokke
                                  2018-10-21 18:49:49.019Z

                                  works. But gee, it needs a long way! Streamdeck sending key to KM, two KM macro's that send midi to two SF macro's. Hahaha! But it works.

                                  1. Hahaha... Nice. That's proof of concept.
                                    With the SD -> SF integration you'll be good to go :p

                                    1. Fokke van Saane @Fokke
                                        2018-10-21 18:54:47.136Z

                                        Make sure that the StreamDeck developers design that SD can differentiate between a key press and and a key up! For all actions like forward-rewind, zooming, scrolling and such this is necessary!

                                        1. I looked through the API, looks like this is built in. I think it will end up being a very neat integration.

                                          1. Fokke van Saane @Fokke
                                              2018-10-22 16:08:08.131Z

                                              I also wonder if their software can work alongside yours.

                                              1. They should work just fine. The integration is very well architected and I've been personally in touch with their lead developer for months now.

                                                1. Fokke van Saane @Fokke
                                                    2018-10-22 16:18:47.001Z

                                                    That's good to hear. Their email support was irritating.