Map midi controller to photoshop

jandara

2010-12-31 00:06:00

Hello, I'm wondering if someone knows how to create a preset to control brush size in Photoshop using a knob on Korg Nano Kontrol. The keystroke to decrease brush size is ] and to increase it [ How do I create this preset in Midi translator? Thanks

Attigo

2011-01-04 17:59:14

Sure, but I have couple of questions for you!

What kind of knob is it? Encoder?

How many brush sizes to do you want to be able to select from/between?

Scott

jandara

2011-01-04 23:14:52

Hi Scott,

I'm not sure what knob it is but my midi controller looks like this
Image
http://www.amazon.com/Korg-nanoKONTROL- ... 229&sr=8-6
In photoshop you can adjust brush sizes from 1-2500 pixels. The min brush size is 1 pix, each time you press the ] key the brush size increases. It takes 50 ] strokes to go from the smallest 1 pix size to 2500 pix the largest brush size.

Thanks
Alain

Attigo

2011-01-05 16:18:23

Ok, they are just normal, absolute position control knobs. So you want to be able to scroll through the entire brush size range, as in smallest when the knob is all the way left and largest when all the way right?

So basically you need to track and output 2 main variables, you need to know which direction the knob is being turned, clockwise or anti-clockwise and you need to downsample the value message from the knob to 50 steps.

I've had it working, and it can be done like this:

Code: Select all

Translator 0: Knob Input Clockwise
Incoming: MIDI B0 00 oo
Rules:
  if oo>=ga then Goto "Forward"
  ga=oo
  exit rules, skip Outgoing Action
  Label "Forward"
  ga=oo
  oo=oo*20
  pp=oo/51
  if gb==pp then exit rules, skip Outgoing Action
  gb=pp
Outgoing: Keystroke: ] 

Translator 1: Knob Input Counter Clockwise
Incoming: MIDI B0 00 oo
Rules:
  if oo<=gc then Goto "Back"
  gc=oo
  exit rules, skip Outgoing Action
  Label "Back"
  gc=oo
  oo=oo*20
  pp=oo/51
  if gd==pp then exit rules, skip Outgoing Action
  gd=pp
Outgoing: Keystroke: [ 

Knob message B0 00 oo is just for example, replace this with your knob message...

I have written a translator per direction of the knob, so each tracks if it is going the direction that translator 'wants' to see and if so, then downsamples the velocity from 128 steps to 50 steps and outputs the correct keystroke for that direction.

Obviously there is no output from photoshop to tell us which brush size is selected and and we are controlling the size with a relative message (up or down), and because 50 key-presses is a LOT in one quick sweep of a knob, things can slip out of sync. If you turn tooooo fast, then when you finally reach the furthest right on the knob (100%) then sometimes photoshop will not have caught up and won't have the largest brush selected... My advice is to start with the knob all the way left and the brush size at 1, and play lightly!

I hope this makes sense! If you want/need me to go into more detail, just ask!

Scott

alekos

2012-03-09 18:26:48

Hello there,

I asked the same question on another thread and got wisely fowarded here. First of all, thanks a lot for this script, I just added it and it works perfect! Using a MIDI controller for Photoshop is a great improvement and I'm already recommending it to my photograpy/graphic design colleagues.

Now, I'd like to go a little bit further and try to understand the code. Well, not the code, as it's pretty clear, but the MIDI variables. What's the value of 'oo', 'pp', 'ga', 'gb', 'gc' and 'gd'?

florian

2012-03-10 00:33:55

Midi Translator's variables don't have any predefined values. You need to set them yourself.

One easy way is to use the rules:
Rule: pp=1
This will set pp to 1. The rules section of a translation entry is only executed if the Incoming Action is triggered.

An incoming action is triggered if the condition is met. E.g. for this incoming action:

Incoming: MIDI B0 00 09

This incoming action is triggered only when this specific controller message -- controller #0 ("00") on MIDI channel 1 ("B0), with value 9 ("09") -- is received.

So now the other way to set a variable is in the MIDI Incoming Action: instead of a fixed number, use a variable. Then the incoming action will trigger for all values that occur. And the variable is set to the corresponding value:

Incoming: MIDI B0 00 oo

Will trigger the same controller, but because you've replaced a specific value with a variable, it triggers for all values (or positions) of this controller. Additionally, the variable "oo" is set to the value of the controller. So if this is a knob, and you turn it, it will first be triggered with oo=0, then triggered again with oo=1, etc. until you stop turning or you reach the max, oo=127. Each time the Incoming Action is triggered, the rules are executed, and then the Outgoing Action is executed.

So much for now :)
Florian

whitetree

2012-03-10 01:22:30

it would be a lot more useful if photoshop sent data out, so when you change brushes it will register on your midi controller. The korg isn't very useful for this, but anything with motorized faders or knobs with LED indicators would be fantastic. The way you have it set up will ultimately be glitchy if you have your brush size set large and then switch to a small brush and want to enlarge it, as your knobs and sliders are static.

you can interface with photoshop through java, and then easily work through midi with Bome's

here is some code on PS brush from here
http://ps-scripts.com/bb/viewtopic.php? ... e20103f3a8

Code: Select all

/////////////////////////////////////////////////////////////////////////////
//Usage:-
// selectBrush("Airbrush Pen Opacity Flow" );
// selectBrush("Soft Round 21 pixels" );
/////////////////////////////////////////////////////////////////////////////
function selectBrush(brushName) {
  function cTID(s) { return app.charIDToTypeID(s); };
  function sTID(s) { return app.stringIDToTypeID(s); };
var idslct = charIDToTypeID( "slct" );
    var desc4 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref2 = new ActionReference();
        var idBrsh = charIDToTypeID( "Brsh" );
        ref2.putName( idBrsh, brushName);
    desc4.putReference( idnull, ref2 );
    executeAction( idslct, desc4, DialogModes.NO );
};

/////////////////////////////////////////////////////////////////////////////
//Usage:-
// brushSize(29);
/////////////////////////////////////////////////////////////////////////////
function brushSize(size) {
  function cTID(s) { return app.charIDToTypeID(s); };
  function sTID(s) { return app.stringIDToTypeID(s); };
var idsetd = charIDToTypeID( "setd" );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref1 = new ActionReference();
        var idBrsh = charIDToTypeID( "Brsh" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref1.putEnumerated( idBrsh, idOrdn, idTrgt );
    desc5.putReference( idnull, ref1 );
    var idT = charIDToTypeID( "T   " );
        var desc6 = new ActionDescriptor();
        var idmasterDiameter = stringIDToTypeID( "masterDiameter" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc6.putUnitDouble( idmasterDiameter, idPxl, size );
    var idBrsh = charIDToTypeID( "Brsh" );
    desc5.putObject( idT, idBrsh, desc6 );
    executeAction( idsetd, desc5, DialogModes.NO );
};

/////////////////////////////////////////////////////////////////////////////
//Usage:-
// brushHardness (66);
/////////////////////////////////////////////////////////////////////////////
function brushHardness(size){
   if(parseInt(size) > 100) size = 100;
var idsetd = charIDToTypeID( "setd" );
    var desc15 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref7 = new ActionReference();
        var idBrsh = charIDToTypeID( "Brsh" );
        var idOrdn = charIDToTypeID( "Ordn" );
        var idTrgt = charIDToTypeID( "Trgt" );
        ref7.putEnumerated( idBrsh, idOrdn, idTrgt );
    desc15.putReference( idnull, ref7 );
    var idT = charIDToTypeID( "T   " );
        var desc16 = new ActionDescriptor();
        var idhardness = stringIDToTypeID( "hardness" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc16.putUnitDouble( idhardness, idPxl, size );
    var idBrsh = charIDToTypeID( "Brsh" );
    desc15.putObject( idT, idBrsh, desc16 );
executeAction( idsetd, desc15, DialogModes.NO );
};

florian

2012-03-11 22:29:50

interesting stuff! we don't have the bandwidth here to implement a solution right now. If anyone wants to, we will provide support as much as we can.
Florian

entillandersson

2013-03-24 11:20:22

Hi! im trying to get my Korg Nanokontroller 2 to work with photoshop. To program the buttons to work is not a problem at all. But as described in this thread i also, just as the op, want the knobs to work so i can adjust brushsizes and opacity.

I tried to use the script but could not make it work. I got so far that i could wiggle the knob and it would make the brush smaller but not proggresivly.

I think the problem i have is that i dont understand the coding of the midi trigger.

Any help is greatly apreciated.

entillandersson

2013-03-24 11:54:41

I own a Nanokontroller 2. But for the life of me i cant get it to work. I can NOT make the knob turning translate it into making a brush larger.

I tried to use the script but to no avail. I think the problem is that i dont know what im doing and what im supposed to do with it.