Intro to Controller Scripting - Bitwig Studio 1.0.x

Post Reply New Topic
RELATED
PRODUCTS

Post

hey humanbeingbeing,
yeah, that happens to everybody at least once with github ;-)

Great it works for you.
Yes, only the CCs are bidirectional for now, but you can implement whatever you need in the same way by adding an observer and sending whatever data you need back to your controller via the flush() function to limit the datarate.

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

Thanks again. I think I follow it.... nice one!

Post

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

Post

hey guys,

simple beginner question:
i use a script made by emerah for maschine controller (it uses CC until #48 for its script). it works fine, but there are no free mappable CCs (higher than 49). so i try to use the generic midi too (adress it to maschine virtual in), but than the script dosnt work anymore.

I "coded" a little bit by myself and i guess i have to put this
// Make CCs 49-128 freely mappable
anywhere, (and maybe the line
var LOWEST_CC = 49;
var HIGHEST_CC = 129;

at start, but unfortunatly it isnt so simple.

BTW: how can i analog to this line

if (isChannelController(status) && data1 == 31 && data2 > 0) {
application.toggleBrowserVisibility();

make some similar for toggle Inspector? use another CC and replace Browser with Inspector dosnt work.

and last Q: is all of this stuff (seeing if ctrl+enter) "scriptable"?

Post

Well, I think you have to dig slightly deeper into scripting to make it work ;-)

The two things you put in:

Code: Select all

var LOWEST_CC = 49;
var HIGHEST_CC = 129;
are not doing anything (as you found out), they are two variables that can be used later in the code - and have to be used, otherwise they just sit there twiddling thumbs... ;-)

If you look at the generic scripts, they define these ranges on top, and later in the script they use these variables when creating userControls ( = mappable CCs):

Code: Select all

//from the init function
   userControls = host.createUserControls(HIGHEST_CC - LOWEST_CC + 1);

   for(var i=LOWEST_CC; i<=HIGHEST_CC; i++)
   {
      userControls.getControl(i - LOWEST_CC).setLabel("CC" + i);
   }
So first the required number of userControls is created (using those two variables you created as the range) and then the script iterates through all those controls to give them a name (which you see when you map them to something in Bitwig Studio) - again using those variables.

Then in the "onMidi" callback (wich is "called" and executed each time midi comes in), the script checks if any of the incoming midi is from those CCs (once again using the two variables from the top to define the range) and in case it is, sets the value of that userControl to the value from the incoming CC:
function onMidi(status, data1, data2)

Code: Select all

{
   if (isChannelController(status))
   {
      if (data1 >= LOWEST_CC && data1 <= HIGHEST_CC)
      {
         var index = data1 - LOWEST_CC;
         userControls.getControl(index).set(data2, 128);
      }
   }
}
So just setting the two variables isn't doing anything, they are merely a means to define the desired range, that later on can be used anywhere in the script to take the required actions.

The other problem is, that if you change an existing script, you have to be careful that you don't disturb it's workings (as you found out too ;-) ), so if you are very new to scripting, maybe try to contact the author and see if you can work together on expanding the script?

This will become easier soon, when the new Controller Script Website goes online.

As for the other question: You can't simply put something into a script, you need to check in the API Reference Docs if the command is available (those things are under the "Application" topic), otherwise frustration may occur ;-)

I don't think the Inspector can be toggled yet, but it's a request I have myself.

I don't fully understand the last question about "seeing if ctrl+enter" - do you mean if all commands in the command manager are scriptable? If that is the question, the answer is "no", only selected commands are scriptable at this time, although I guess this will grow over time...

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

There will be links to JavaScript learning resources on the upcoming Controller Script Website, but I thought I should post them here as well:

Websites and Online-Books:
A full online book on JavaScript that does focus on the beginner and explains everything from the ground up, it's quite exhaustive but should get you up and running if you are totally new to this stuff:
http://eloquentjavascript.net/

A great, compact introduction to the ins and outs of JavaScript for people who already know programming but need to brush up on the specifics:
https://developer.mozilla.org/en-US/doc ... JavaScript

Another compact overview for the more scripting savy out there:
http://bonsaiden.github.io/JavaScript-Garden/

A nicely laid out online reference for JavaScript, mainly targeted at web development, but great to look up something quickly:
http://www.w3schools.com/js/default.asp

Videos:
A pretty exhaustive and entertaining overview on JavaScript with backstory on computers, programming and how it all came about from Jacquard weaving and Punchcards:
http://yuiblog.com/crockford/

More from Mr. Crockford:

The JavaScript Programming Language:
http://yui.zenfs.com/theater/crockford-tjpl-1.m4v
http://yui.zenfs.com/theater/crockford-tjpl-2.m4v
http://yui.zenfs.com/theater/crockford-tjpl-3.m4v
http://yui.zenfs.com/theater/crockford-tjpl-4.m4v

Advanced JavaScript:
http://yui.zenfs.com/theater/crockford-advancedjavascript-1.m4v
http://yui.zenfs.com/theater/crockford-advancedjavascript-2.m4v
http://yui.zenfs.com/theater/crockford-advancedjavascript-3.m4v

Enjoy!

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

Post

I've not seen anything in the docs. Does the scripting API support timers?

Post

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

Post

muchas gracias Tom,

i put your code into the old script, now i get the mapping, but lost the deeper script :-)
seems so, i have to get deeper in it, java isnt in 2 hours leraned.

(i make backups before i script).

with API Reference Docs do you mean the *.js in the controlsurface-folder?

yeah, my last Q meaned the commands which are shown in the manager.

kay, for today is enough "coding" - now i make music with the stuff i have;-)

einen schönen tag dir!

Post

Yeah, sounds like a good plan ;-)

Bitwitg Studio -> Help -> Control Surface Scripting API

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

Thank you Thomas! This is really helpful :tu:

Looking forward to the dedicated site. Hope all goes well for you.

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

Post

I'd like to get my Faderport working with BitWig and I made a search on the Internet about the Messages this Controller needs to control his Fader. I found the Information that it has a 10bit resolution fader, which needs two alternating bank select messages: "First 0xB 0x00 vv is sent (MSB) and then 0xB 0x20 vv (LSB)".

I know basic scripting things, but this is a step to high for me. Can anyone help me to get the motorized fader working, the rest will be peanuts I think.

Post

Working on Novation Twitch script. Only basic initialisation and features for now.
But i'm working on it =)

Here is script: https://github.com/jamland/Novation-Twi ... pts-Bitwig

Post

Got my Hands on Touch OSC and, with help from Thomas, get the Mapping and the according Script started.
Whats working so far (Based on Thomas´Bi-Directional Script): Transportcontrol

Actually i have two Pages in the Works:

One is for Transport and Volumes/Pan (Faders/Knobs atm freely mapable for testing purposes, have to change CCs there i guess to avoid conflicts)
Second: A Page with 4 X/Y Pads incl Encoders for Mapping the Axes to CC´s

Planned is another Page for the Mixer with a Larger Fader-Range and some pages for personal needs (Multy-Toggles for Notes on different Midi Channels).

Anything Else you´d like to see implemented?

The Scripting is not really my cup of Tea, so Help at this Point to speed things up and get it to a state where the Mapping can be released to Public is highly apprishiated.
Another Point here: I´m on Android. The Mapping should work on iPad as well but i have noch chance to test it. So if anybody with Scripting knowledge (and maybe an iPad) is willing to cooperate it would be verry helpfull. Just leave ma a note ;-)

Post

Image

And the Controller Script Page is finally online! Yay :-) :party:

https://www.bitwig.com/en/community/con ... ripts.html

Some initial scripts are already there, but everybody is welcome to submit their controller scripts (you need to be logged in to do so), subscribe to updates and comment on the existing ones.

For collaboration with others it's best to host your scripts on Github:
http://www.github.com/
It's free and easy to do and they have tutorials on their site if you should be stuck.

The final niggles are worked on as we speak, but if you find major problems with the site, please report them to support:
http://www.bitwig.com/en/support/tech-support.html

If the authors of the scripts already in the database want to make any changes, please also feel free to contact me or tech-support so we can take care of it!

Happy Scripting and Controlling!

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”