Intro to Controller Scripting - Bitwig Studio 1.0.x

Post Reply New Topic
RELATED
PRODUCTS

Post

You can get the name of scenes, just the colour isn't saved by the scene but the clips it contains, so if you have all the clips in a scene set to a specific colour (which is what setting the colour of a scene does) you can simply get one of those to have the colour.

We recently had a discussion about this - Scenes are somehow funny buggers since they are not very well defined as an entity, other than a track or clip. ATM you can for instance not observe if a scene is playing other than checking all clips it contains and if they all play, the scene can be considered playing. But you can have a scene playing by this definition and still launch other clips beside...
Volker is thinking about it to see what can be done.

Sorry, I can't always remember who did what already with the API, so I may explain things you already know - good there was some meat in it anyway... ;-)

In 1.1 the reference docs will see some nice improvements, although there is so much new stuff and changes that it will be easy to be completely lost again ;-)

Cheers,

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

Post

We now uploaded the API Reference to the Website: http://controller-api.bitwig.com/

This allows for linking to specific pages (use the "no frames" option for that) like this:
http://controller-api.bitwig.com/com/bi ... /Host.html

Later there will be a search option too.

The docs will be substantially updated in 1.1, not only did the API grow tremendously, but the devs also included a lot more information.

Cheers,

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

Post

OMG!!! this is the best thing thats happened since sliced bread!
Cant wait until the weekend to play with this.

Love you bitwig!

Post

After looking through the the API documentation I couldn't find a way: Is it even possible in the host.getMidiInPort().setMidiCallback() function to reinsert MIDI events back into the input chain - possibly so that the createNoteInput() filter can pick them up?

I wrote an Arturia MiniLab controller script and it seems working for the most part. But for some reason in the factory settings the pads 1 to 8 send note events on MIDI channel 10, but once you shift to pads 9 to 16 they send switched control events for CC 22 to 29 on channel 1.

Post

You can either edit the preset of the MiniLab with the Midi Control Centre so it behaves differently or you do what you ask for, but be aware that you will get more latency when the notes go through the script as when they go directly to the note input.
What you look for is:

Code: Select all

NoteInput.sendRawMidiEvent(int status, int data0, int data1);
What you send this way is not filtered since it's assumed that you only send there what you want to send.

Since I'm not totally sure what you are doing, there is another thing you may be interested in:
Normally everything you send to the NoteInput and don't filter out is NOT going to onMidi, but you can put:

Code: Select all

NoteInput.setShouldConsumeEvents(false);
To prevent this. In this case, all events go to the NoteInput (where they are filtered) AND to onMidi (unfiltered).

My Arturia MiniLab script is also basically done, only missing a pad-transpose and docs:
https://github.com/bitwig/arturia-keylab
I used the second bank of pads as controller buttons, the first four pads set modes while the other navigate tracks, devices and presets, set submodes or switch device mappings. No documentation yet though.
This script depends on the default factory layout and settings.

Cheers,

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

Post

ThomasHelzle wrote:You can either edit the preset of the MiniLab with the Midi Control Centre so it behaves differently or you do what you ask for, but be aware that you will get more latency when the notes go through the script as when they go directly to the note input.
Thank you. Somehow I missed the totally obivous. :roll:

I know that you can change the mapping with the Arturia MIDI center, but I thought it would be nice to have a controller script that works out of the box with factory settings--even if they are strange in my opinion as the controls on the shifted pads are gated and lose all velocity information.
ThomasHelzle wrote: I used the second bank of pads as controller buttons, the first four pads set modes while the other navigate tracks, devices and presets, set submodes or switch device mappings. No documentation yet though.
That is a nice idea, but personally I find the big pads on the MiniLab a bit clumsy for these controls. At least compared to my Nektar Panorama ...

I saw in the 1.1 Bitwig beta that there are additional option buttons in the MIDI setup. It looks like there is going to be some kind of support for controller script configuration menus? Is this planned for 1.1, 1.2 or even 2.0?

Also, I am interested if it would be possible to create a controller script for tight integration with a specific VST plugin. For example, if the VST is in the project and the MIDI routing goes to the track where the VST plugin is in, the MIDI in/out goes straight to the VST plugin. If not, the MIDI in/out is translated to be somehow usable without the VST.

That would be really nice for the Arturia SparkLE: Currently you have to unplug the controller from the MIDI controller list inside BitWig if you want to use it with the Spark VST.

Post

Well, in the end all these things are extremely personal. I try to build scripts that are as versatile as possible and then leave everything else to the individual user and the Open Controller API, since we can't hope to cover every style of working and usage anyway. ;-)

Settings are working in 1.1 already: You can create Controller Script Settings both in the Preferences and/or in the I/O Panel:
For preferences you create the basic object for example with something like:

Code: Select all

preferences = host.getPreferences();
And then you can create Number, Enum, String and Signal settings, for instance:

Code: Select all

preferences.getSignalSetting("An Example Signal", "Script Preferences", "Shoot");
The settings in preferences are automatically saved globally and you create an observer for each one to know it's current state in the script. The gear icon in the preferences opens the settings, the circular arrow reloads a script (in case a change in settings requires a reload).

For script settings in the I/O panel it's almost the same, but the settings are saved per document, so you can for instance save/reload your pad transpose or your scale or whatever you do in your script and have it set correctly for each project you open.
You create the object with something like:

Code: Select all

docState = host.getDocumentState();
Creating settings works the same as for preferences.
The little triangle in front of the controller in the I/O panel opens the settings.
Check the Launchpad Script in 1.1 for an example.
Also check the Control Surface Scripting API - it's grown tremendously in 1.1.

Creating that logic for the SparkLE would be up to you. You can go from either relatively simple (create a setting in the I/O panel that switches between two modes for the script) to trying to find out what's in the project/track and switch automatically. The latter could be rather involved, since there isn't something like a "search the whole project for a specific device" kind of command.

Cheers,

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

Post

Hi,
I am hoping this is a good place to ask a question.
I am trying to access that "Semitones" parameter of the "Note Pitch Shifter" (pictured below) and I can't figure out how to do that.

Here are some things I have tried:

Code: Select all

trackBank = host.createMainTrackBankSection(8, 2, 1);
the1 = trackBank.getTrack(1).getPrimaryDevice().setParameterPage(0).getParameter(1);
dump(the1);
the2 = trackBank.getTrack(1).getPrimaryDevice().previousParameterPage().getParameter(1);
dump(the2);
Either way I get
TypeError: Cannot call method "getParameter" of undefined
.
Unless I am getting it all completely wrong I don't understand why I can't get that first page right.

I was hoping to do something like this in onMidi on the right button press

Code: Select all

trackBank.getTrack(SELECTED_TRACK).getPrimaryDevice().previousParameterPage().getParameter(1).whateverItTakesToGetToTheParameter().inc(1, 128);
How do I navigate through the Parameter Pages in a Channel? Please help.

Image
- Jay

Post

jgaura wrote:

Code: Select all

trackBank = host.createMainTrackBankSection(8, 2, 1);
the1 = trackBank.getTrack(1).getPrimaryDevice().setParameterPage(0).getParameter(1);
dump(the1);
the2 = trackBank.getTrack(1).getPrimaryDevice().previousParameterPage().getParameter(1);
dump(the2);
There are several problems in your code:
- Tracks and Parameters are zero based: getTrack(0), also getTrack is deprecated and you should use getChannel
- getPrimaryDevice(): In your screenshot the primary device is the Instrument layer not the pitch shifter
- getParameter is a function of Device: getPrimaryDevice().getParameter(0)

This should work:
trackBank.getChannel (0).getPrimaryDevice ().getParameter(0).inc(1,127)

Post

Thank you, Moss. I still could not get this to work though yet. Actually I seem to fail trying to get any response from any of the parameters even those that are directly on the primary device, let alone any pre or post stuff. I don't get any errors though, which kind of really puzzles me. Usually I get thing either working or I get some sort of feedback that helps me move forward.

So, again (to make sure I did not miss any stuff that might reveal my problem)... I have this in my init():

Code: Select all

trackBank = host.createMainTrackBank(8, 2, 1);
then I tried this sort of stuff in onMidi() on a certain key press, trying to get some sort of indication that I in fact access the intended parameter:

Code: Select all

par = trackBank.getChannel(0).getPrimaryDevice().getParameter(0);
par.inc(1, 127);
par.addValueDisplayObserver(11, 'nothing', function (val) {
       SAYSOMETHING = val;
});
println(SAYSOMETHING);
I did diclare var SAYSOMTHING before.

I definitely know that I am accessing the channel and the primary device right, as I was able to do stuff with them, like access their names, etc. But with parameters, it's been a struggle... I sure played with the index of getParameter(). I am assuming that parameters are indexed in some sort of order more or less like on the GUI, left to right, top to button perhaps. I also tried changing some parameters' values on the GUI side and then trying to see if this will be picked via the observer. Anyway, I have not had much luck with this so far.
- Jay

Post

Adding observers does only work in the init-function. There are a lot of scripts out there where you can look up examples of what you are trying to do, e.g. examine one of the scripts coming with Bitwig and simply search for the functions you are trying to use.

Post

Thank you!
- Jay

Post

billcarroll wrote:FYI ... I've updated the Arturia "The Laboratory" keyboard script to add basic transport control, e.g., play, stop record, and so on.

http://cl.ly/1Q141B2a2i2W/Arturia_The_L ... rol.js.zip

It would be cool to have some central place to share and improve on these control scripts.
Hi,
This script do not work for me.
I'm using Windows 7 32bit and Arturia Analog Experience The Laboratory with Bitwig demo 1.1.6.

Post

Very new to the program and excited to work with Bitwig such an amazing program layout for what i do. (windows 7 64bit)
I recently purchased a Novation ReMote 37SL and im having problems having the program understand the USB1 signals i am sending to the program i manage to get the keyboard operating, but knob functions are not mapping.

i also read in recent post that when importing .JS files into bitwig controller file folder they are not showing up, i also have the same problem.

I mainly focus on beat production, im not very technical in coding other than midi mapping and i am a visual learner. If there is a simple way or process to stepping into the creative process of bitwig controller mapping quickly i am open to growing with the company.

I didnt quite understand the introduction to Controller Scripting b/c of the bugs i am experiencing...

Thank You & glad to be apart of the community :tu: :phones:

Post

Hi Tom, thank you for your Korg nanoKontrol2 script, it works like a breeze for me (BWS 1.3.6 RC2), but I first had to change the if statement in line 192 of the script from
if (status == 0xBF)
to
if (status == 0xB1)

I'm not sure if this is a typo/bug, or if I could/should have set the status sent somewhere else? (Didn't see anything like that in the Korg Control Editor.)
Anyways, thanks for it, other than that it works great! :tu:

Post Reply

Return to “Controller Scripting”