Cakewalk A-300 Pro Controller Script

RELATED
PRODUCTS

Post

Well, I guess you broke something new. It's a bit hard to follow your random-copy-paste style of coding ;-)
It being from my script doesn't help much as soon as you tinker around...
Maybe follow my long explanation above and see if that works first?
Otherwise this whole exercise will become a bit absurd and nobody will learn much in the end...

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post

Ok, now everything works with your help. Midi learn, Play, Stop and Record works. :tu:

Now i have to press the play button on the conntroller twice to get an action, but thats a minor thing.

Next thing i will try to setup the pause button for loop cycle active/inactive, few/rwd for track up and down and one of the sliders for master volume.

But probaply not right now.. :)

here is the script: http://pastebin.com/vqLJ80HA

thx Tom!
JamWide - a cross-platform Ninjam client for DAWs

Post

hehehe - cool! :tu:

Pressing twice sounds like your buttons toggle already internally and only send one value when pressing and releasing, not two?
In that case you wouldn't need to test for "pressed" - the API play() command toggles between play and pause anyway.
Depending on your controller this could be true for record and stop as well.

Loop is simple as well:

Code: Select all

transport.toggleLoop();
Track up and down needs a cursor track created in init()

Code: Select all

cursorTrack = host.createCursorTrack(0,0);
The numbers represent how many sends and scenes it should hold, but I guess you only want the track itself.

Moving it up and down is done with:

Code: Select all

cursorTrack.selectNext();
//or
cursorTrack.selectPrevious();
In reaction to your button-CCs.

Master Volume is a quick one too:

Code: Select all

masterTrack = host.createMasterTrack(0);
in init(). The number is the number of scenes but irrelevant for your use I guess.

Then in reaction to the CC your controller sends from the fader in question:

Code: Select all

masterTrack.getVolume().set(data2, 128);
Cheers,

Tom

Edit: Fixed the master volume code.
Last edited by ThomasHelzle on Mon Aug 25, 2014 3:29 pm, edited 1 time in total.
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post

Ok, nice! Getting there slowly.. :hyper:

I removed the "pressed" condition and now i only need to hit button once..great one.
Also the track selection works as expected, wich is really cool. First it was always jumping in steps of two tracks, then i set the controller to latch mode and now it works perfect.

Also the cycle button gets triggered perfectly fine now. ;)

Only the Master Volume needs some attention, it doesn`t react on the Master Fader yet, and i do get an error.
Image

I also got that in the function onMIDI. But it shouldn`t be there right?
What do you mean by setting it in question? With an "if" constuction? Would be cool if you could help me there.

This is the script: http://pastebin.com/HCYMcJTs

cheers
JamWide - a cross-platform Ninjam client for DAWs

Post

I guess that for the tracks you would have needed the pressed condition. Always check what the controller is sending. Either it sends a value both when you press down and when you release the button, or it does not.
When it sends two values, depending on what you want to do you may want to only react to one, which is where the pressed condition comes into play...

Your posted script doesn't contain the master fader part. But basically you just add a case with the fader variable like you did before and then put

Code: Select all

masterTrack.getVolume().set(data2, 128); 
in there, 128 being the resolution of your fader (forgot that before, sorry).

"The fader in question" is a figure of speech, similar to "Der gewünschte Controller" in german. You already put that in with var _mastervolume = 7; ;-)

Code: Select all

case _mastervolume:
...
should work.

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post

Oh, i`m sorry, i forgot to add this.. :dog:

It works now also perfectly fine, thx! :party: :tu:

Next thing i thought about, it would be cool if i could define a button to open the vst instrument of the selected track.

Also it would be nice to be able to midi learn a few parameters to knobs or sliders, then select another track and midi learn other parameters with the same knobs and sliders, and when i then switch inbetween those tracks, the learned parameters should be still available. But i guess that would only be possible if i split the tracks to react on different midi channels right?

btw: it starts to make some fun with the code :wink:

edit: ah, just saw the other thread with the same question. Hm well, this would be over my head i fear, will check the manual again to see if there is something like device maps. I do have controler maps tho, but they change all Midi CC on the controller.
JamWide - a cross-platform Ninjam client for DAWs

Post

Open/Close VSTs: Not possible ATM via the API.

Midi learn is always static, so your second idea isn't possible in the way you want it. But with a cursor track and a cursor device you would be able to use the parameter pages mappings and/or macros which could server in similar ways.

I guess closest and easiest would be to put everything in your tracks into a group and assign it's macros to the parameters you want to control.

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post

Okay, so i guess i would also need this in the function init(); ?

Code: Select all

cursorDevice  = host.createCursorDevice();
primaryDevice = cursorTrack.getPrimaryDevice();
then define all my knobs as variables and somehow link them to the macros in onMIDI?

Or do i not need the primary device, do you know a script where its done like this?
JamWide - a cross-platform Ninjam client for DAWs

Post

Progress little skywalker ;-) :tu:

Almost. There are basically two kinds of cursor devices in the API (which I personally would like to combine but that it another story), the first you created is a cursor device that basically represents what you select in the GUI. This acts a bit funny for controller scripts since it's not always defined (you can have nothing selected).
I generally prefer to go with the second one you defined. This one always exists and can be fully selected with a controller. It represents the primary device, which has that little dot with the two lines next to it in the GUI (also rightclick "Set as Primary Device". It's bound to the cursor track so it always is located on the track you select with your controller.
For the time being you can comment out the first one and only use the primaryDevice.

And yes, you define all your knobs as variables and then add them all as cases in onMidi...

Try if you can find out how to access macros and set them from the API docs... ;-)

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post

Ok, now i`m not coming further right now.

I created the variables and bundled them into one big variable.

Added the primary instrument view in the function init(); and what i think is the observer for calling the macros and added a case in the function onMidi.

Now i do get this error

Image

Well yes, and i`m not sure if this is the right direction but at least its something to talk about. :D

here is the script: http://pastebin.com/TXU1WHUw

Also it somehow breaks all other onMidi cases.. :(

cheers
JamWide - a cross-platform Ninjam client for DAWs

Post

Well, that's copy-pasting syndrome again.
Try to understand what you do and it should work.

Several things:
1.) You use a list of values as a switch.
Switch compares the value in the main variable you give it (in this case "data1") to each case and if they are equal it applies that case.
So if data1 contains the same value as for instance _play, the code following that case is executed until the break statement, which exits the switch structure (and makes the break very important, since without it the execution would simply continue with the next line of code - very easy error to make).
Now you gave it an object (since you created it with curly braces it's an object) containing 8 variables with values, but data1 will never become an object containing 8 variables...
Since switch can only compare one value at a time (or the whole object), you can't work like this.
You need to either compare each of your variables separately (basically like you did before) with the correct syntax (if you want to use such a combined variable/object it would be the dot-notation) or you would need a different kind of test to find out if the variable is in a certain range.
But since your knob CCs aren't continuous, that is not worth the trouble (you can't check if for instance the CC is between 20 and 27 like in a keyboard which has a linear structure in it's knobs CCs).
So you will have to do it like you did it with all the other variables, one by one.

2.)
primaryInstrument.getMacro(cIndex).getAmount().set(value, 128);
Where do you get cIndex from? You define it nowhere so it doesn't exist. In the script you copied it from I guess it was a number that defined what macro to set, but you don't have that...
Better start out simple for the moment and just put the number of the macro in there you want to manipulate. There are eight macros and the numbering starts from 0... ;-)

In the error message above it expects a : in line 28 - I guess that is from another script from what you posted? Makes no sense in that context...

Here's a great JavaScript resource where the whole language is explained in easy to understand bits and pieces:
http://www.w3schools.com/js/default.asp
Great for looking things like switch or objects up.

Good luck,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post

Ok, thanks a lot Tom..really, i appreciate your patience with me!

I know copy&pasting in this context is not very much of a help, and i will go thrue that tutorial you posted to be a bit more able to do such stuff. I wanted to do such a course in a long time already, also for websites.

And well, it works now! :party:

Here is the script: http://pastebin.com/y9sXgh8p

This has now covered already a lot of the controller, so if you think its right, i could put it up on github for the library.

thx!
Mark
JamWide - a cross-platform Ninjam client for DAWs

Post

Cool! Congratulations! :party: :tu:

We could add some bells and whistles now, like macro indication in the gui etc.
Wanna try?

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post

Sure why not ;)
JamWide - a cross-platform Ninjam client for DAWs

Post

Ok - cool.

The indications are the coloured markings on the controls in the GUI that show the user what's controlled by what and that it is controlled by something. ;-)

For the masterTrack volume this would be:

Code: Select all

masterTrack.getVolume().setIndication(true);
in init()

For the macros I would suggest a loop, also in init() :

Code: Select all

for (var i = 0; i < 8; i++) {
   primaryDevice.getMacro(i).getAmount().setIndication(true);
}
This means: Create a variable "i", set it to zero, then repeat the code in the curly braces as long as i is smaller than 8 and on each step increase i by one - i++ is shorthand for adding one to the value of i.
This is the most used form of loops which is great whenever you have several things to do where only something minor changes (in this case only the number of the macro).

Another question would be, if you use all 16 Midi Channels? If your keyboard basically only sends on Channel 1, you could remove all but the first channel so the dropdown in BWS wouldn't be cluttered with 16 Midi inputs. The script would become easier to read as well.

Also, I created that script originally to send feedback back to the controller, but I am not sure if your controller benefits from that? Has it motor faders or LED rings around the knobs? Otherwise a lot of code could be removed...

Finally, if you are done with the script, remove or comment-out all println and printMidi commands so that the console isn't uselessly filled with data nobody is looking at or interested in.

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." · Rumi
UrbanFlow.art · Instagram · YouTube

Post Reply

Return to “Controller Scripting”