Cakewalk A-300 Pro Controller Script

RELATED
PRODUCTS

Post

Updated the script and controler map, see GitHub Repo:

https://github.com/Suloo/Cakewalk-A-300-PRO

cheers and have fun! :tu:


===============================================
===============================================



Hello,

i`m trying to get my head around the scripting API, but i`m afraid i do not get it. :?

I`ll show you what i got so far and wonder about.

First of all, these are the available MIDI ports:

This setup at least lets me play the keyboard, but midi learn for other parameters is not possible:

Image

These are the available Inputs:

Image

These are the available outputs:

Image

I used the controller script that dsan provided me in the resources thread, wich is this one:

Cakewalk A-300 Pro Controller Script

and what i try to achieve is something like tor.helge.skei did for the Edirol PCR 300

Edirol PCR 300 Controller Script

related post:

http://www.kvraudio.com/forum/viewtopic ... 0#p5771462

==================================================

The Edirol PCR 300 and the Cakewalk A-300 Pro are very similar in the setup, since the A-300 Pro is basicaly the next edition of this controller.
However, there are maybe a few differences i`m also maybe not totally aware of, but for example the A-300 Pro has 9 rotary knobs.

In the end i would like to have a controller script, wich lets me use all midi channels seperately, like in the Controller Script by Tom here:

TomsGenericMultiControl

Then i would like to have transport control and one of the sliders mapped to the master volume. Everything else should be free for midi learn.

==================================================

Right now, when i load the script by dsan, i can play the keys but midi learn doesn`t work.
When i open up the script in the Controller Script Console, i get this error messages:

Image

Then i wonder why i cannot get the controller automatically detected. I wrote the names from the Midi Input list in the script, but couldn`t get it to work. I commented the related code out in the script for now.

I would really be happy to get this thing further to make use of my controller.
If anybody could help me out it would be much appreciated.

thx!
Mark
Last edited by llze on Sat Feb 28, 2015 1:57 pm, edited 1 time in total.

Post

Ok, now i got the controller recognized correctly by using this new Generic script by Tom from this post.

http://www.kvraudio.com/forum/viewtopic ... 1#p5704951

No error messages in the Console anymore.
Now, i only need midi learn to work properly and the transport, and maybe one slider fix to master out volume.

So the new script is here: A-300 Controler Script

When i just add all the content of the Edirol PCR 300 to the end of this file, the keyboard is not working anymore. I changed the midi input from pcr300 to A-PRO 1 wich is my midi input, but still no luck.

Probaply i would first need to define all variables according to my controller right, and then see how to use them for my needs. I`m really not much of a coding guy, so this is producing some headache. :hihi:

Edit: Ok, i now contacted Roland and Cakewalk via support mails and in there forums, and maybe someone could help out in this matter from official site as well.

Post

Hi Suloo,
Yeah, that script was from the early days of the API and had limited functionality.

Now they have added a lot to it giving the API much more it can do.

Unfortunately I'm in the same boat as you - unable to work with coding so my efforts have basically failed since those early days. I have tried to take bits and pieces from other scripts to create one for my controllers, but without a complete understanding of the code I'm mainly lost.

I don't know I would put much faith into Roland or Cakewalk developing scripts for Bitwig. Early on M-Audio was approached and they immediately declined.

You may want to ask Moss or Teotigraphix. They have successfully created several working scripts. With Tor-helge's and Tom's scripts you should be able to modify the controll messages (MIDI CC's) to match the controller. Yes, you are correct, the variables have to match your device.

Oh, BTW, I'm not sure how far you will get with being able to use the controller to edit VST's. I don't think that functionality is fully available in the API yet. I'm speaking of something like Automap.

As I understand them the scripts are mainly to give you control of maneuvering around the BWS GUI....tracks, volume, pan, etc. So you definitley should have "Learn" in your script. Even the early scripts had this ability so I'm not quite sure why you cannot do the learn function.

Sorry I can't be more helpful to you.

Happy Musiking!
dsan
My DAW System:
W7, i5, x64, 8Gb Ram, Edirol FA-101

Post

yea, currently i`m reading the manual of my controller to see if there is a general controller map. I think its mapped to match with cubase right now.

edit: yep, that was the problem, i had a different mapping selected in the editor of my controller. Now midi learn works fine.. :party: :D :D

Ok, now only this transport stuff left basically, cool..

Post

Kul :tu:

It sounds like you know what you're doing with the script so I think you can likely take some hints from some other scripts to get the transport working.

Tom's scripts has it working so maybe you can do copy and paste, change a couple of variables and get there.

I have confindence in your abilities Suloo :D

Happy Musiking!
dsan
My DAW System:
W7, i5, x64, 8Gb Ram, Edirol FA-101

Post

Hehe, well i couldn`t find a script by Tom with transport settings. But this from the graphite 49 has some.

What i first would like to know is this..

Image

are that Midi CC ?


edit: seriously i got no idea anymore for now.
I added some variables, some observers and functions from the scripting guide but right now, not even the folder wich contains the js file gets recognized by bitwig.

here is the code: http://pastebin.com/D9z1Re9T

kinda lost.. :?

Thomas in for some help maybe?
Last edited by llze on Sun Aug 24, 2014 1:35 pm, edited 1 time in total.

Post

Yes, those are the MIDI CC that when sent cause the action to perform.

However, there are call backs that have to take place so the action gets performed.

You should find those call backs later in that script but they may or may not be relevant to your device.

That's the point I always got lost when trying to develop a script for my controllers. Changing the cc's was not a problem but gluing all together was beyond my capabilities :hihi:

You can find what cc is being sent when you press or move a control by using the API monitor. You will need to add this to your script (at the bottom) to view the data, and select the corresponding script:

host.println("Default: "+ data1)
print MIDI(status, data1, data2)

This way, in case you do not know the MIDI CC required, BWS will tell you which it is. ;) I don't think the data 2 statement is necessary but it is what is in another script I use so I just left it for you to decide.

HTH

Happy Musiking!
dsan
My DAW System:
W7, i5, x64, 8Gb Ram, Edirol FA-101

Post

host.println("Default: "+ data1)
print MIDI(status, data1, data2)
does this have to be inside the function init() ?

when i add this below or right above the function exit() the whole folder containing the script doesn`t show up after a Bitwig restart.

generaly i got this to define the Note Numbers (MIDI CC) for the controler.

Image

I don`t know really, all scripts i viewd got these transport controls and variables used in an If...Else construction wich is too advanced for my simple needs i think. They combine other stuff as well into these constructions, like here in the Edirol PCR 300 script, wich is supposed to be the closest controller to mine.

http://pastebin.com/V73TCZTY

maybe i`ll ask him if he can help me to build just this..

Post

ooopppsss....sorry, it has to be inside a function;

function onMidi(status, data1, data2)
printMidi(status, data1, data2)

Yes, I think you should ask. You know the expression "the sight impaired leading the sight impaired" :hihi:

I think you should be taking from those that actually got a controller to work :tu:

These guys are friendly and will help you as much as they can.

I'm afraid all I'm gonna be able to do is get you more frustrated. And I really don't want that ;)

Happy Musiking!
dsan
My DAW System:
W7, i5, x64, 8Gb Ram, Edirol FA-101

Post

printMidi(status, data1, data2); goes into the onMidi(status, data1, data2) {} function as the first command after the opening curly braces. It will then show you what your script is receiving when you press a button or key on the controller (show it in the Controller Script Console I mean).

Transport can also be sent as midi machine control MMC which is sysex. In that case you need to have a
onSysex(data) {} function as well in which you can put the println(data); or printSysex(data); to see what comes in;
If it doesn't exist, you need to create it and also create a sysex callback in init() similar to the onMidi one:

Code: Select all

host.getMidiInPort(0).setSysexCallback(onSysex);
That is always the first step, finding out what your controller is actually sending and making sure it's using a sensible preset.

The second step is creating variables to hold those CCs or Sysex or whatever so you can then in the third step refer to them in the code you use to react to those things sent to you.

Transport is very simple:
In init() you create a transport object like this:

Code: Select all

transport = host.createTransport();
In onMidi you can then later react to the correct incoming CC to start playback like this:

Code: Select all

transport.play();
What I see from your screenshots is that the A-300 Pro seems to have two Midi Inputs and Outputs. In that case you need to find out what they do. Some keyboards send the normal note stuff through one and the controller stuff through the other or some such fancy things.

In your case the host.defineMidiPorts(1, 1); line should maybe become host.defineMidiPorts(2, 2); and the detection something like:

Code: Select all

host.addDeviceNameBasedDiscoveryPair(["A-PRO 1", "A-PRO 2"], ["A-PRO MIDI OUT", "A-PRO"]);
So both are detected and connected. But you then also need to handle both of them in the code...

Maybe try first to find out if both are sending stuff you need with your existing code by selecting first one and then the other as inputs, maybe only one is actually of relevance for you.

I don't think we have the controller so I can be only of limited help.

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream Instagram Mastodon

Post

Ok lets see..

I checked the midi ports before as well yes.

This is what is stated in the manual:

Image

So i think when just using MIDI the A-PRO 1 port should be fine. For SysEx bulk messages i would need to use A-PRO 2 input.

When checking the MIDI CC in the API console i can see

MIDI CC for stop = 25
MIDI CC for play = 26
MIDI CC for record = 28

Image


Ok, so now i define the variables in the script and put the

Code: Select all

transport = host.createTransport();
in the function ini();

Image

Next step is to call the variables in the onMidi function, like this?

Image

Sadly this didn`t work yet.

@Tom, i used your script as a base: TomsGenericMultiControl.control.js
Maybe i need to adjust something there?

This is my script right now: http://pastebin.com/8riAgBk4

hope this helps. I also contacted tor.helge.skei , who did the script for the PCR 300. Maybe he can also help.

cheers
Mark

Post

Ok, this gave me all kinds of errors in the API console.

So how do i link transport.play for example to the var _play = 26 then?

like this maybe?

Code: Select all

transport.stop(_stop);
        transport.play(_play);
        transport.record(_record);

Post

Got it working :party: :phew: :hyper:

I copied the stuff out of the graphite controler script, changed the MIDI CC according to mine, and now it works..

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

Now its just the MIDI learn that doesn`t work anymore lol.
Will investigate further..

Post

Maybe check out some tutorials on general programming so you don't tap around in the dark as much?
There are many interesting things one can do with a basic understanding of code so it's really worthwhile these days.
I'm self-tought as well...

As for your (previous) script (just saw your update):
The transport commands were correct, I just don't know where you got the {var control = find_control(ctrl,chan); from. Since "find_control" and the two variables you give to it aren't defined, you will get errors.

The nice thing about the onMidi function is, that it gives you the incoming midi data already broken down into it's main components. "status" is a bit complicated since it contains the midi channel as well as the type of message you get, but data 1 is for instance the note number for notes and the CC number for CCs, so you can directly switch over data1 here. (data 2 is the velocity in case of notes and the actual controller value in case of CCs.

The api contains a lot of helpers for this area in your installation folder\resources\controllers\api All functions in these scripts can be directly used in your own scripts and this is were "isChannelController(status)" comes from - it returns true if the current midi message is a CC and false if not.
A lot of other such helpers to determine the midi channel, message type etc. are available there.
But find_control is not one of those and I guess you copied that from somewhere else?
You also use var pressed = (value>=64); which again I assume you copied from somewhere.
Since "value" isn't defined, it can't work.

So what you need to change is:

Code: Select all

var pressed = (data2 > 64);
This means that if the value of data2, which in the case of a CC contains the actual value between 0 and 127, is bigger than 64, the variable "pressed" will contain "true" and if it's smaller than 64 it will contain "false". The reason is, that most controllers send 127 when you press a button and 0 when you release it. Since later in the script you only want to start playback when you press the button, you check there if pressed is true...

The other thing to change is deleting the "var control = find_control(ctrl,chan);" line but leave the curly brace in there. Instead of "switch(control)" you want to use "switch(data1)" then it should work since you already tested that it is a CC, so data1 will contain the controller number which you then compare to the CC numbers you stored in your variables for the transport controls.

I can't try it here since I don't have the controller though.

So if you copy code, make sure if it is a function like "find_control" that you also copy the function itself (which can be anywhere in the code).
If there are variables used, make sure you track down where they come from and what they contain so you can recreate their content in your own code.

Just blindly copy-pasting pieces will be rather frustrating I fear...

Cheers,

Tom
"Out beyond the ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there." - Rumi
ScreenDream Instagram Mastodon

Post

Ok thanks, i will try that as well, in case i do not get the MIDI learn function back right now. Since the transport is working fine now with the new script.

I do get an error tho.

Image

Wich is supposed to be in line 64 it says right?

But line 64 is:

Code: Select all

MultiBi5  = host.getMidiInPort(0).createNoteInput("MultiBi - Ch 5", "?4????");
Its from your generic multi control script Tom.

cheers

Post Reply

Return to “Controller Scripting”