No internet connection
  1. Home
  2. Ideas
  3. Logic

Adjusting Clip Gain Using Stream Deck Plus Knobs

By Gabriel Levi @Gabriel_Levi
    2024-09-09 01:33:44.838Z

    I would LOVE to be able to adjust the gain of a selected clip using the gain control in the region dropdown menu (where I've applied +7.3dB of gain) using the Stream Deck knobs. I searched for this command but couldn't find what I was looking for. Let me know if you think this is possible!

    • 9 replies
    1. G
      In reply toGabriel_Levi:
      Gabriel Levi @Gabriel_Levi
        2024-09-09 02:13:12.371Z

        Update: I actually created my own macro for this. I created a key command inside Logic for "Region Gain +0.1" and "Region Gain -0.1" and assigned those key commands to the Generic Knob Commands preset. To my surprise it actually works! This is gonna be so handy when doing some manual clip gaining.

        Gabe

        1. cc @Kitch

          1. In reply toGabriel_Levi:
            Kitch Membery @Kitch2024-09-09 16:34:44.552Z

            Nice work, Gabriel. :-)

          2. G
            In reply toGabriel_Levi:
            Gabriel Levi @Gabriel_Levi
              2024-09-09 14:33:08.168Z

              If you happen to implement this in the SoundFlow Logic package, the one thing that would make this a million times better is being able to make the +/- values variable. 0.1 dB is a little too fine for my tastes but 1.0 dB (the only other available option) is a little too extreme. Let me know :) Thanks!

              1. Kitch Membery @Kitch2024-09-09 16:39:48.031Z

                I've added this request for consideration... Hopefully, I can make this work, I can see how handy this would be. :-)

                1. In reply toGabriel_Levi:
                  Kitch Membery @Kitch2024-11-16 00:35:52.863Z

                  Hi @Gabriel_Levi,

                  I finally got around to creating a function for setting and adjusting selected region gain in Logic Pro.

                  Right now it requires the Region inspector "Gain:" slider/entry field to be visible.

                  Here is the function...

                  /**
                   * Adjusts or sets selected region gain in a Logic Pro.
                   * 
                   * @param {Object} args
                   * @param {'Set'|'Adjust'} [args.mode] - The mode of operation. Use "Set" to set an exact gain value, or "Adjust" to adjust the gain by a delta.
                   * @param {number|null} [args.targetGain=null] - The target gain in dB. Required for "Set" mode. Ignored in "Adjust" mode.
                   * @param {number|null} [args.delta=null] - The amount to adjust the gain by in dB. Required for "Adjust" mode. Ignored in "Set" mode.
                   */
                  function setRegionGain({ mode = "Set", targetGain = null, delta = null }) {
                      const logic = sf.ui.logic;
                      const inspector = logic.mainWindow.inspector;
                  
                      const regionGroup = inspector.children.whoseRole.is("AXList").first.groups.find(g =>
                          g.children.whoseRole.is("AXStaticText").whoseValue.is("Region:").first.exists
                      );
                  
                      if (!regionGroup) {
                          log(`Could not find the tracks region panel`);
                          throw 0;
                      }
                  
                      const rows = regionGroup.scrollAreas.first.children.whoseRole.is("AXOutline").first.children.whoseRole.is("AXRow");
                      const gainRow = rows.find(e => e.children.first.value.value === "Gain:");
                  
                      if (!gainRow) {
                          log(`Could not find the region gain slider.`);
                          throw 0;
                      }
                  
                      const slider = gainRow.sliders.first;
                  
                      let newGainValue;
                  
                      if (mode === "Set" && targetGain !== null) {
                          // Calculate target gain value
                          newGainValue = targetGain * 10;
                      } else if (mode === "Adjust" && delta !== null) {
                          // Calculate new gain value based on adjustment
                          const currentGainValue = slider.value.doubleValue; // Already multiplied x10
                          newGainValue = currentGainValue + (delta * 10);
                      } else {
                          log(`Invalid mode: ${mode}. Use "Set" or "Adjust".`);
                          throw 0;
                      }
                  
                      // Set the slider to the calculated new value
                      slider.value.doubleValue = newGainValue;
                  }
                  

                  Example use cases for the function...

                  // Set to target gain +10.2
                  setRegionGain({ targetGain: +10.2 });
                  
                  // Set to target gain -5.5
                  setRegionGain({ targetGain: -5.5 });
                  
                  // Increase by 0.1 dB
                  setRegionGain({ mode: "Adjust", delta: +0.1 });
                  
                  // Decrease by 0.1 dB
                  setRegionGain({ mode: "Adjust", delta: -0.1 });
                  
                  // Increase by 1 dB
                  setRegionGain({ mode: "Adjust", delta: +1 });
                  
                  // Decrease by 1 dB
                  setRegionGain({ mode: "Adjust", delta: -1 });
                  

                  I plan on adding this to the Logic Pro package at some point but I thought I'd share it in case you want to use it till then.

                  I also plan on making this into a Meta Command for smooth control with the Stream Deck+ knobs.

                  Have a great weekend.

                  1. GGabriel Levi @Gabriel_Levi
                      2024-11-16 00:42:43.382Z

                      DUDE! Incredible!! Thank you for keeping this idea in mind, will be so handy. I'm not 100% how to use this code. I see an option to convert a macro to script, but not how to convert a script into a macro. Let me know where I should look! You rock.

                      Gabe

                      1. Kitch Membery @Kitch2024-11-16 00:58:30.053Z

                        You could make a command template out of it. But for simple use follow these steps.

                        Create a new script and name it "Increase Region Gain by 1 dB". Then add the following code.

                        /**
                         * Adjusts or sets selected region gain in a Logic Pro.
                         * 
                         * @param {Object} args
                         * @param {'Set'|'Adjust'} [args.mode] - The mode of operation. Use "Set" to set an exact gain value, or "Adjust" to adjust the gain by a delta.
                         * @param {number|null} [args.targetGain=null] - The target gain in dB. Required for "Set" mode. Ignored in "Adjust" mode.
                         * @param {number|null} [args.delta=null] - The amount to adjust the gain by in dB. Required for "Adjust" mode. Ignored in "Set" mode.
                         */
                        function setRegionGain({ mode = "Set", targetGain = null, delta = null }) {
                            const logic = sf.ui.logic;
                            const inspector = logic.mainWindow.inspector;
                        
                            const regionGroup = inspector.children.whoseRole.is("AXList").first.groups.find(g =>
                                g.children.whoseRole.is("AXStaticText").whoseValue.is("Region:").first.exists
                            );
                        
                            if (!regionGroup) {
                                log(`Could not find the tracks region panel`);
                                throw 0;
                            }
                        
                            const rows = regionGroup.scrollAreas.first.children.whoseRole.is("AXOutline").first.children.whoseRole.is("AXRow");
                            const gainRow = rows.find(e => e.children.first.value.value === "Gain:");
                        
                            if (!gainRow) {
                                log(`Could not find the region gain slider.`);
                                throw 0;
                            }
                        
                            const slider = gainRow.sliders.first;
                        
                            let newGainValue;
                        
                            if (mode === "Set" && targetGain !== null) {
                                // Calculate target gain value
                                newGainValue = targetGain * 10;
                            } else if (mode === "Adjust" && delta !== null) {
                                // Calculate new gain value based on adjustment
                                const currentGainValue = slider.value.doubleValue; // Already multiplied x10
                                newGainValue = currentGainValue + (delta * 10);
                            } else {
                                log(`Invalid mode: ${mode}. Use "Set" or "Adjust".`);
                                throw 0;
                            }
                        
                            // Set the slider to the calculated new value
                            slider.value.doubleValue = newGainValue;
                        }
                        
                        // Increase by 1 dB
                        setRegionGain({ mode: "Adjust", delta: +1 });
                        

                        Create a second script and name it "Decrease Region Gain by 1 dB". Then ad the following code.

                        /**
                         * Adjusts or sets selected region gain in a Logic Pro.
                         * 
                         * @param {Object} args
                         * @param {'Set'|'Adjust'} [args.mode] - The mode of operation. Use "Set" to set an exact gain value, or "Adjust" to adjust the gain by a delta.
                         * @param {number|null} [args.targetGain=null] - The target gain in dB. Required for "Set" mode. Ignored in "Adjust" mode.
                         * @param {number|null} [args.delta=null] - The amount to adjust the gain by in dB. Required for "Adjust" mode. Ignored in "Set" mode.
                         */
                        function setRegionGain({ mode = "Set", targetGain = null, delta = null }) {
                            const logic = sf.ui.logic;
                            const inspector = logic.mainWindow.inspector;
                        
                            const regionGroup = inspector.children.whoseRole.is("AXList").first.groups.find(g =>
                                g.children.whoseRole.is("AXStaticText").whoseValue.is("Region:").first.exists
                            );
                        
                            if (!regionGroup) {
                                log(`Could not find the tracks region panel`);
                                throw 0;
                            }
                        
                            const rows = regionGroup.scrollAreas.first.children.whoseRole.is("AXOutline").first.children.whoseRole.is("AXRow");
                            const gainRow = rows.find(e => e.children.first.value.value === "Gain:");
                        
                            if (!gainRow) {
                                log(`Could not find the region gain slider.`);
                                throw 0;
                            }
                        
                            const slider = gainRow.sliders.first;
                        
                            let newGainValue;
                        
                            if (mode === "Set" && targetGain !== null) {
                                // Calculate target gain value
                                newGainValue = targetGain * 10;
                            } else if (mode === "Adjust" && delta !== null) {
                                // Calculate new gain value based on adjustment
                                const currentGainValue = slider.value.doubleValue; // Already multiplied x10
                                newGainValue = currentGainValue + (delta * 10);
                            } else {
                                log(`Invalid mode: ${mode}. Use "Set" or "Adjust".`);
                                throw 0;
                            }
                        
                            // Set the slider to the calculated new value
                            slider.value.doubleValue = newGainValue;
                        }
                        
                        // Decrease by 1 dB
                        setRegionGain({ mode: "Adjust", delta: -1 });
                        
                  2. S
                    In reply toGabriel_Levi:
                    SoundFlow Bot @soundflowbot
                      2024-09-09 16:35:33.401Z

                      This issue is now tracked internally by SoundFlow as SF-1440