No internet connection
  1. Home
  2. Ideas

MIDI triggers made to be more simple

By Erik Groysman @Erik_Groysman
    2020-02-27 06:37:06.706Z

    Currently I get 'b0,64,*' instead of 'CC 100, 127, 0' or something like that.

    Additionally, I can't edit it - I can only re-record the trigger.

    Essentially, triggering with MIDI would be very useful if it was more configurable!

    • 18 replies

    There are 18 replies. Estimated reading time: 12 minutes

    1. I completely agree. This is leftover from an old implementation where we couldn't augment the MIDI triggers, but we should have the infrastructure in place now to do it.
      We're releasing 3.5 shortly so I don't think we can fit this into 3.5, but it's likely going to be included in 3.6.

      1. EErik Groysman @Erik_Groysman
          2020-02-27 18:53:59.374Z

          That's excellent news!

          I am using an NI Maschine to perform a lot of triggering (I have it on my desk and since it's always in MIDI mode, I figured why not make it work for me for things like Quantize, Duration, Window Configs, etc.)
          With Controllermate, I used to use 'Gate' mode but with SF that would trigger twice (once on press, once on release). I found that switching to 'Trigger' fixes that.

          What I am now having an issue with is replicating my volume control using the knob encoder on my Maschine. I use a UAD Apollo so the volume/mute shortcuts are CMD+ the apple keys for volume: F10 is mute, F11 is down and F12 is up.

          In CM, I was able to achieve this using this:

          And respectively, on NI's Controller Editor, this is what the encoder is spitting out.

          Is there any way I can achieve this in SF? I would like to completely replace CM with SF, and this is one of the last frontiers.

          The last two things I can't figure out (so far) is creating a toggle so that one button can trigger 2 things - for example I have F14 toggle between scrolling following playback and no scrolling

          And lastly, triggering MMC to I can hit play and stop from my keyboard without always double tapping the space bar - not as important but, again, I am trying to integrate everything

          Thank you again for all your support! Hoping to be able to shed CM soon as it has not been updated since October 2018!

          1. Hi @Erik_Groysman.

            Yes this is possible with SoundFlow.
            You're quite right the visual ways to edit MIDI triggers is pretty limited, but the stuff you can do in scripts in practically limitless.

            See this post for an example on how to filter on relative knobs:
            https://forum.soundflow.org/-1407#post-18

            SoundFlow also has built in support for controlling volume, so no need to simulate keystrokes.

            1. Combining those things you'd end up with something like this:

              
              var DELTA = 0.05;
              
              var m = event.trigger.midiBytes;
              var m0 = m[0], m1 = m[1], m2 = m[2];
              
              if (m0 == 0xB1) {
                  //Match CC on channel 2
              
                  if (m1 == 112) {
                      //Match CC 112
              
                      if (m2 < 64) {
                          //Turned down
                          sf.system.volumeSet({ volume: sf.system.volumeGet().volume - DELTA });
              
                      } else if (m2 >= 65) {
                          //Turned up
                          sf.system.volumeSet({ volume: sf.system.volumeGet().volume + DELTA });
                      }
              
                  }
              
              }
              

              Make sure to use a MIDI trigger in "ALL EVENTS" mode.

              1. EErik Groysman @Erik_Groysman
                  2020-02-28 19:02:10.022Z

                  Thanks, Christian.
                  I want to wrap my head around the scripting using my limited experience scripting Kontakt.

                  I will try this but is this just for system volume? I cannot control the UAD volume using system volume - I need to use CMD + F10-12.

                  1. Yea this is just for system volume.
                    To simulate keystrokes Cmd+F10, or Cmd+F12, you'd do:

                    //First, get the 3 midiBytes into an array called 'm'
                    var m = event.trigger.midiBytes;
                    
                    //Now get the first byte in m0, the second byte in m1 and the third byte in m2:
                    var m0 = m[0], m1 = m[1], m2 = m[2];
                    
                    //Check the first MIDI byte (holds type and channel)
                    if (m0 == 0xB1) {
                        //Match CC on channel 2
                    
                        if (m1 == 112) {
                            //Match CC 112
                    
                            if (m2 < 64) {
                                //Turned down
                                sf.keyboard.press({ keys: 'cmd+f10' });
                    
                            } else if (m2 >= 65) {
                                //Turned up
                                sf.keyboard.press({ keys: 'cmd+f12' });
                            }
                    
                        }
                    
                    }
                    
                    1. EErik Groysman @Erik_Groysman
                        2020-02-28 19:07:58.983Z

                        You rock, Christian! I will give this a shot. I really appreciate you guiding me with the scripting!

                        1. :)
                          Here's a link that will help you understand the different MIDI bytes in a message:
                          https://ccrma.stanford.edu/~craig/articles/linuxmidi/misc/essenmidi.html

            2. E
              In reply toErik_Groysman:
              Erik Groysman @Erik_Groysman
                2020-08-15 19:35:00.321Z

                I'm finally getting around to trying to implement this, Christian, and I am getting errors.
                Something about setting keyboard commands from MIDI is still not intuitive for me.

                I've tried the script you wrote for me and I get 'type error m is null' and I can only trigger the command by hitting 'Run Command' and not from the MIDI trigger.

                I also am trying to set UAD mute which is CMD+F10 and triggered by CC 112 channel 1 and it just simply does not trigger.
                Am I missing something?

                Thank you

                1. Hi Erik,

                  Can you share a screenshot of the MIDI trigger you've set up in SoundFlow and copy/paste your script here? That will help me see where it goes wrong.

                  1. EErik Groysman @Erik_Groysman
                      2020-08-27 17:40:21.297Z2020-09-16 19:07:29.322Z

                      Thanks, Christian.
                      Seems to be issues triggering CMD+ F12, F11, F10.

                      I am trying to upload screen shots but it's not allowing me to. "Error 413 Request Entity Too Large"
                      Just a regular macOS screen shot

                      I am happy to change the way the encoder is programmed on the MASCHINE side.

                      Here is the code that I grabbed from you.

                      //First, get the 3 midiBytes into an array called 'm'
                      var m = event.trigger.midiBytes;
                      
                      //Now get the first byte in m0, the second byte in m1 and the third byte in m2:
                      var m0 = m[0], m1 = m[1], m2 = m[2];
                      
                      //Check the first MIDI byte (holds type and channel)
                      if (m0 == 0xB1) {
                          //Match CC on channel 2
                      
                          if (m1 == 112) {
                              //Match CC 112
                      
                              if (m2 < 64) {
                                  //Turned down
                                  sf.keyboard.press({ keys: 'cmd+f11' });
                      
                              } else if (m2 >= 65) {
                                  //Turned up
                                  sf.keyboard.press({ keys: 'cmd+f12' });
                              }
                      
                          }
                      
                      }
                      
                      1. Hi Erik,

                        Thanks for reminding me about this old topic.

                        So, just to make sure I understand what you're doing:

                        • NI Maschine is sending MIDI messages to SoundFlow
                        • In SoundFlow the script you quoted above is set up like this (albeit with NI Maschine instead of USB MIDI Device Port 1):
                        • UAD doesn't seem to register the key presses.

                        The first step to troubleshoot this would be to see if the script is correctly receiving the MIDI input (if it's not we need to fix your trigger).
                        To test that, add a simple line like this in the beginning of your script:

                        log('Received MIDI');
                        
                        1. You mentioned you couldn't post screenshots. Likely the images were just a bit too large for the forum server. It should be possible if you try again using just a portion of your screen instead.

                          It would be interesting if we could also get rid of even having to simulate keyboard strokes in the first place. I don't have access to the UAD app - but is there a chance that they have a menu item for the volume control that we could invoke instead? Menu items in apps are generally much more stable to automate than keyboard simulation.
                          If you could share a screenshot just of the UAD app's menus regarding volume then I could help you with that part.

                          1. EErik Groysman @Erik_Groysman
                              2020-09-16 19:39:30.495Z

                              Thanks, Christian. I wish they did but its only GUI

                              or keystrokes. There is a UAD package in the store but no volume control.

                              There are no app menus regarding volume. I just re-skimmed the manual.

                              1. Ugh... Gotcha, that sucks. What's the name of the UAD app?

                                1. What I meant with that was - if I click to download this on their website would I get what you're running?
                                  "UAD SOFTWARE v9.12.2"

                                  1. EErik Groysman @Erik_Groysman
                                      2020-09-16 22:01:05.448Z

                                      yes! and the console app in the package will be the one

                                      1. Thanks. Ok got it installed. It definitely is a very non-standard UI that does not appear to be friendly to being remote controlled.
                                        If simulated keystrokes don't correctly trigger the monitor change, it may be because they're registering a global keyboard hook through the same mechanisms as SoundFlow is. Since SoundFlow sends keyboard events to macOS not as a virtual device but directly to the event handling API, most apps would receive those keystrokes, except for any app that wants to register global hooks. I could see UAD doing that for their monitor control.
                                        ControllerMate has the benefit here of having a virtual device driver (kext), so their keyboard events appear more native (one level deeper you could say).
                                        So far, we've tried to stay clear of developing kexts due to the engineering complexity and cost of maintenance.

                      2. Progress
                        with handling this problem
                      3. E@Erik_Groysman closed this topic 2020-08-27 05:54:29.065Z.
                      4. E@Erik_Groysman reopened this topic 2020-08-27 05:54:40.561Z.