Jump to content

Help with Script of CC 7 value (+1) and (-1)


mackenzie
 Share

Recommended Posts

Please if someone could help me with a Script, because i'm already tried with the environment and with all the scripts on logic and i can't figure out a way to do this task.

i want increment a CC 7 value by (+1) and by (-1) with 2 buttons on my keyboard, but i don't want to reset the whole value of the current volume its already on.

For example a have 20 instruments inside a bank on Kontakt, and sometimes i need just to turn down 0,5db on a instrument, but when i grab a fader with CC 7 and move that fadder, it reset the volume to the position of that fadder.

Link to comment
Share on other sites

This can be done in scripter, but a few things you should consider before spending any time on it

 

  1. Scripter runs AFTER the sequence in the midi signal chain..which means you can't record to the track the adjusted CC values. You will hear the changes in the instrument, but its post-recording to the track. If you need to be able to record the new CC7 values, then you must use environment.
     
     
  2. I think this is possible to do with the environment but would be very advanced environment stuff which I can't help with.
     
     
  3. Scripter does not have access to QWERTY keyboard commands, so you have a few options, like you can use a smart control....and/or midi controller buttons.. It could be possible to use external programs such as Keyboard Maestro to convert QWERTY into midi perhaps, I'm not a guru on that

 

In the case of Scripter, the solution would be to first write a script that keeps track of the current running CC7 value for each midi channel it is listening to, so that it knows where the value currently is. Then listen for the buttons you mention and adjust the CC7 value.

 

A quick simple example you can expand on might be something like this (sorry I don't have time to test it right now, I'm just typing it right into this message). This assumes C-2 = DOWN and D-2 = UP. Something like that....you might have to fiddle with it to get it working...

 


var tracker = new Array(17);
var DOWN = 0;
var UP = 2;

var cc = new ControlChange;
cc.number = 7;

function HandleMIDI(event) {

   if( event instanceof ControlChange && event.number == 7) {
       tracker[event.channel] = event.value;
       event.send();
       return;
   }
   
   if (event instanceof NoteOn && event.pitch == DOWN) {
       cc.channel = event.channel;
       tracker[event.channel] -= 1;
       cc.value = tracker[event.channel];
       cc.send();
       return;
   }
   
   if (event instanceof NoteOn && event.pitch == UP) {
       cc.channel = event.channel;
       tracker[event.channel] += 1;
       cc.value = tracker[event.channel];
       cc.send();
       return;
   }
       
   event.send();
}

 

if you want to involve smart controls it gets more complicated.

OSX 12.x (Monterey) on OpenCore - Logic Pro 10.7.4, VePro7, Mainstage3 - 5,1 MacPro 3.46ghz x 12 96gb ram

Link to comment
Share on other sites

It would be very cumbersome to do in the Environment, because yes, there are Meta Events which allow you to increment or decrement a MIDI Fader, but no, this does not work directly on an Audio fader, you'd have to increment the MIDI fader which then can control the Audio fader. And this in turn means that MIDI fader would need a track which you need to select so it receives the incoming button press events. This doubles your number of tracks with very little gain in functionality.

 

Since I personally don't think you'll be happy with controlling your levels by inc/dec buttons anyway, have you thought of a reasonably cheap control box with but one motorized fader ? This would automatically reflect the fader of every selected channel so you can make fine adjustments without level jumps, and you can write dynamic level automation with it too.

Christian Obermaier
Contact me for private Logic Consulting, Training, Troubleshooting via Skype or Zoom
1 x MacPro 6core 2010 24Gb RAM, 2 x MacBookPro i7 2012 16Gb RAM, OSX.14.6. Mojave, Logic X.5.1

Link to comment
Share on other sites

he didn't mention the audio fader.

 

The issue that I don't know how to do in the environment is keep track of the current running CC7 value. I don't have any knowledge about storing values..I guess you just have some env fader that holds the value...and when the INC/DEC events come in, you use the value from that fader to send CC7.

OSX 12.x (Monterey) on OpenCore - Logic Pro 10.7.4, VePro7, Mainstage3 - 5,1 MacPro 3.46ghz x 12 96gb ram

Link to comment
Share on other sites

i tried the script and worked in some way, but only if you have some automation of CC 7 on the track, the script increment a value of CC 7 on the last position of the playhead stopped

but the problem with that is to have a midi region for every Instrument.

the idea was to use on large banks of instruments inside kontakt or trillian to fine tune the volume

i have a motorized fader but i can manage to work on the volume of the track in logic, not on the volume of a instrument in kontakt

the motorized fader can read the value if its automate on the region or the track.

Link to comment
Share on other sites

you'll have to figure it out yourself from here, sorry I don't have time to go deeper on this. You logically can't use and UP/DOWN button to. inc/dec the CC7 value unless you start with some value to begin with eh? That would have to be at least once at the start of your tracks. Otherwise it is going to assume the first value is zero...or you might have to init that tracker array at the start to some initial value, etc..there are various things you could do, but you'll have to figure it out from here. good luck.

 

I think maybe an easier option would be to buy a midi controller that has endless rotors on it, like a used BCR2000 or something similar.

 

you are not alone, this is unfortunately how midi works and there is no perfect easy solution. Good luck.

OSX 12.x (Monterey) on OpenCore - Logic Pro 10.7.4, VePro7, Mainstage3 - 5,1 MacPro 3.46ghz x 12 96gb ram

Link to comment
Share on other sites

I wonder if that could be solved by using the proper value mode in the controller assignment window?

LogicPro 10.7.4, MainStage 3.6,
MBPro 17", Core2Duo, 8G, OSX 10.12.6, MacPro, Xeon 6Cores, 64GB, OSX 10.16.1,
ULN8, MOTU MIDI TP-AV, C4, MCU Pro, KorgNano, Novation SLMkII, Several vintage gear
AAS, NI, Celemony, Spectrasonics, Korg, Arturia, etc..., PC, iPadPro 5th gen 12.9”(Duet D., V-Control & LogicRemote), AtariST(Notator SL),

Link to comment
Share on other sites

but when i grab a fader with CC 7 and move that fadder, it reset the volume to the position of that fadder.

That's because it's working at absolute positions, not relative to where it's at.

First of all, a Kontakt bank is not going to solve your issue.

The Kontakt bank is there so you can load 20 instruments and once everything is loaded, then using a Program Change CC, you can switch to the instrument without having to wait for the loading of the instrument.

Only one bank can be active at anytime with a Kontakt Bank.

You usually use a Kontakt Bank in a live performance.

 

I've see hardware mixers with motorized faders handle what you're looking for.

Let's say you assigned values to the first 16 tracks, then switch to the second bank (17-32) on the hardware mixer, the motorized faders would adjust to it's known last fader values for tracks 17-32.

When you switch back to the first bank of 1-16, the motorized faders resets back to it's known fader values for each of the 1-16 tracks.

 

The reason this doesn't make sense to do in Scripter or The Environment is, the current MIDI controller you have can't motorize back to know values so you can't really know an approximate let only the absolute fader value you're at on a single track.

MacBook Pro 10.8.5 2.2 GHz Intel Core 2 Duo 6GB Ram - Logic Pro X (10.2) - MacMini 10.13.6 2GHz Intel Core i7 16GB Ram - GarageBand 10.4.5 Logic Pro X (10.4.8) - iPad Mini iOS 12 - iOS GarageBand 2.0.1 - Qosimo X70-A 10.13.6 Intel® Core™ i7-4700MQ Processor 32GB DDR3L 1600MHz memory, 2-500GB 7200rpm hard drives - Logic Pro X (10.4.8) - MacMini M1 11.6.1 Apple M1 16GB Ram 1TB SSD Logic Pro X (10.7.1) Rosetta 2 not installed

Link to comment
Share on other sites

lol, I forgot about this and I have this.

If you have an iPad get this.

 

LP Touch from Delora

MacBook Pro 10.8.5 2.2 GHz Intel Core 2 Duo 6GB Ram - Logic Pro X (10.2) - MacMini 10.13.6 2GHz Intel Core i7 16GB Ram - GarageBand 10.4.5 Logic Pro X (10.4.8) - iPad Mini iOS 12 - iOS GarageBand 2.0.1 - Qosimo X70-A 10.13.6 Intel® Core™ i7-4700MQ Processor 32GB DDR3L 1600MHz memory, 2-500GB 7200rpm hard drives - Logic Pro X (10.4.8) - MacMini M1 11.6.1 Apple M1 16GB Ram 1TB SSD Logic Pro X (10.7.1) Rosetta 2 not installed

Link to comment
Share on other sites

lol, I forgot about this and I have this.

If you have an iPad get this.

 

LP Touch from Delora

That doesn't seem to be available anymore...

LogicPro 10.7.4, MainStage 3.6,
MBPro 17", Core2Duo, 8G, OSX 10.12.6, MacPro, Xeon 6Cores, 64GB, OSX 10.16.1,
ULN8, MOTU MIDI TP-AV, C4, MCU Pro, KorgNano, Novation SLMkII, Several vintage gear
AAS, NI, Celemony, Spectrasonics, Korg, Arturia, etc..., PC, iPadPro 5th gen 12.9”(Duet D., V-Control & LogicRemote), AtariST(Notator SL),

Link to comment
Share on other sites

lol, I forgot about this and I have this.

If you have an iPad get this.

 

LP Touch from Delora

That doesn't seem to be available anymore...

Hmm, next time maybe I should read what I post. :mrgreen:

 

Well, the next best thing is Logic Remote.

MacBook Pro 10.8.5 2.2 GHz Intel Core 2 Duo 6GB Ram - Logic Pro X (10.2) - MacMini 10.13.6 2GHz Intel Core i7 16GB Ram - GarageBand 10.4.5 Logic Pro X (10.4.8) - iPad Mini iOS 12 - iOS GarageBand 2.0.1 - Qosimo X70-A 10.13.6 Intel® Core™ i7-4700MQ Processor 32GB DDR3L 1600MHz memory, 2-500GB 7200rpm hard drives - Logic Pro X (10.4.8) - MacMini M1 11.6.1 Apple M1 16GB Ram 1TB SSD Logic Pro X (10.7.1) Rosetta 2 not installed

Link to comment
Share on other sites

There are lots of iPad solutions, using OSC. A surface controller of some kind will provide the two-directional feedback that is needed in order to keep a fader or rotary dial in sync with the the software, via OSC communication. But that is not trivial to setup, and particularly when the desire is to map it to some kind of midi CC, most of the prefabbed solutions are simply focused on mixer faders and stuff like that.

 

The advantage of and UP/DOWN button approach is that its not necessary for the hardware controller to be kept in sync with the software. its always a relative bump up or down. Though I also question how easy it would be to adjust things with up down buttons. A fader is obviously much easier.

 

The OP has to specify a starting point for that, however, on a per midi channel basis. There are a number of ways that can be achieved with both Environment and Scripter, but its not a quick task so the OP will have to figure it out...The script I provided earlier is a head start. I would suggest he play with that for a while.

 

if he is going to need to be able to have each region on its own curve of whatever CC he is trying to manipulate, then I would plan to add automation to at least start the level at the start of every region. This could be a single midi event added in the event list. Scripter can respond to that and use UP/DOWN to adjust the value after that. Its not that hard, but there is no solution that can figure out automatically where the buttons were last at...for example.

 

With a control surface, the fader is at some position, this position can be transmitted to the App via OSC so that the software assumes the same current value of the fader. But with UP/DOWN buttons, there is no current position. They are simply relative bumpers that can bump the value up or down from wherever the software thinks it currently is. That would have to be established by at least one midi event at the start of every track or every region to specify the first known current value. After that, UP/DOWN buttons can be used to drive the value up or down relatively...via environment if you want to record the results to a track, or via scripter if you don't care about recording the results.

OSX 12.x (Monterey) on OpenCore - Logic Pro 10.7.4, VePro7, Mainstage3 - 5,1 MacPro 3.46ghz x 12 96gb ram

Link to comment
Share on other sites

Here's a much more sophisticated version of the script I posted earlier..I will not have much more time to work on this, so if it doesn't meet your needs please work with others to resolve it or figure it out... This has a GUI which might make it easier for you to figure out how it works.

 

777073692_ScreenShot2021-08-02at3_41_57PM.thumb.jpg.1061d6e8c3f9e8e2bfd82dd97d62bfa8.jpg

 

/* 
* CC bumper
*
* Script which can be used to bump a given CC value using midi pitches.
*
*/

// Defaults on script init first time
var DOWN = MIDI.noteNumber("C-2");;
var UP = MIDI.noteNumber("D-2");
var INITIAL = 63;
var CONTROLLER = 1;
var STEP = 5;




var PluginParameters = [];

PluginParameters.push({
   name: "Controller",
   type: "lin",
   minValue: 0,
   maxValue: 127,
   numberOfSteps: 127,
   defaultValue: CONTROLLER
});


PluginParameters.push({
   name: "Step",
   type: "lin",
   minValue: 0,
   maxValue: 127,
   numberOfSteps: 127,
   defaultValue: STEP,
   
});

PluginParameters.push({
   name: "UP midi pitch",
   type: "menu",
   valueStrings: MIDI._noteNames,
   defaultValue: UP
});

PluginParameters.push({
   name: "DOWN midi pitch",
   type: "menu",
   valueStrings: MIDI._noteNames,
   defaultValue: DOWN
});

PluginParameters.push({
   name: "-- Current Values --",
   type: "text"
});

for(let chan=1; chan<=16; chan++) {
   PluginParameters.push({
       name: "Current chan " + chan,
       type: "lin",
       minValue: 0,
       maxValue: 127,
       numberOfSteps: 127,
       defaultValue: INITIAL
   });
}

var idxCONTROLLER = 0;
var idxSTEP = 1;
var idxUP = 2;
var idxDOWN = 3;
var idxVal = [];

for(let i=0;i<=16;i++) {
   idxVal[i] = 4+i;
}




var GuiParameters = {
   data: [],
   set: function(id, val) {
       this.data[id] = val;
       SetParameter(id, val);
   },
   get: function(id) {
       if(this.data[id] == undefined) {
           this.data[id] = GetParameter(id);
       }
       return this.data[id];
   }
};

function ParameterChanged(id, val) {
   GuiParameters.set(id, val);
}

var cc = new ControlChange;

function HandleMIDI(event) {

   if( event instanceof ControlChange 
           && event.number == GuiParameters.get(idxCONTROLLER) ) {
           
       let idx = idxVal[event.channel];
       GuiParameters.set(idx, event.value);
       
       event.send();
       return;
   }
   
   if (event instanceof NoteOn && event.pitch == GuiParameters.get(4)) {
   
       let idx = idxVal[event.channel];
       cc.channel = event.channel;
       cc.number = GuiParameters.get(idxCONTROLLER);

       let oldVal = GuiParameters.get(idx);           
       let newVal = oldVal -= GuiParameters.get(idxSTEP);
       if (newVal < 0) newVal = 0;
       GuiParameters.set(idx, newVal);

       cc.value = newVal;
       cc.send();
       return;
   }
   
   if (event instanceof NoteOn && event.pitch == UP) {
       let idx = idxVal[event.channel];
       cc.channel = event.channel;
       cc.number = GuiParameters.get(idxCONTROLLER);
       
       let oldVal = GuiParameters.get(idx);        
       let newVal = oldVal += GuiParameters.get(idxSTEP);
       if (newVal > 127) newVal = 127;
       GuiParameters.set(idx, newVal);

       cc.value = newVal;
       cc.send();
       return;
   }
       
   if(event instanceof NoteOff && 
             (event.pitch == GuiParameters.get(idxUP) 
           || event.pitch == GuiParameters.get(idxDOWN))) {
       // eat these NoteOff
       return;
   }
   event.send();
}

OSX 12.x (Monterey) on OpenCore - Logic Pro 10.7.4, VePro7, Mainstage3 - 5,1 MacPro 3.46ghz x 12 96gb ram

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...