asked May 13 '16 at 09:00 by Blindekinder (91)


I'm writing a script that deal with scenes, since I work in theater, it makes sense...

It seems difficult and buggy:

  • I don't understand why addSceneCountObserver() is called from sceneBank, one might want to create a Bank with all scenes in session, isn't it?
  • selectInEditor seems to do nothing... I found the way to play next scene, which is what I mostly need: a bank of 1 scene, scrolling down every time a key is pressed, and play scene 0. But there are no visual control, I would need a highlight on current scene playing. Selection would be ok, color is better...

    myScenes = host.createSceneBank(1) ;


    case CC.FF:

    mesScenes.scrollDown() ;

    myScene = myScenes.getScene(0) ;

    myScene.selectInEditor() ;

    mesScenes.launchScene(0) ;


  • I need to get selected scene: if I select a scene by hand, then the script has to follow from that one. The only way I imagine to do that is placing an observer isSelected on each scenes, and find a way to place on each time a scene is created.

any suggestion how to manage with that?

Suggestions in order:

  • Sure, you can create a bank with all the scenes in it. addSceneCountObserver doesn't affect or have anything to do with that. addSceneCountObserver simply lets you pass in a callback function that is called any time your scene count changes. It doesn't actually do anything to a bank or scenes or anything else. It is used, for example, if your controller has a bunch of LEDs and you want to light up one LED per scene. You'd write a function, say, lightLEDs() that sends the # of LEDs it should light, then give that function to Bitwig via addSceneCountObserver. Then, any time your # of scenes changed, your controller's LEDs would change accordingly because Bitwig would call lightLEDs when the scene count change happened. If you don't want anything on your controller to change based on # of scenes, you don't even have to use addSceneCountObserver at all.
  • SelectInEditor should be doing what I think you want. Try calling myScene.showInEditor() first to make sure it's visible in Bitwig before you try selecting. You can also use displayNotification with Observer callbacks to display scene information
  • Yes, there is an observer function for that exact thing. void Scene.addIsSelectedInEditorObserver(), just hand it a callback function that updates your script in whatever way you need! Exactly what you need to write in that function depends on what your script is doing to "follow from that one", but you can effectively make it do anything you want

Hope this helped!


answered May 24 '16 at 00:57 by SonicZentropy (11)

thank you SonicZentropy,

did you try selectInEditor? If you have a working code which select any scene, i'll take it, because I tried all possibilities but it doesn't select anything...

and I don't get how to use addIsSelectedInEditor for that. Do I have to make a for loop and put one on each scene? What I really need is a callback when selected scene changes...


answered May 29 '16 at 21:21 by Blindekinder (91)

Yup, selectInEditor works fine here. Here's some examples from a (working) APC40 script. You should actually download the APC4Bitwig framework script in its entirety to use as a reference, don't need an APC40. It's absurdly thorough and very well done, has multiple examples of nearly everything the API can offer. selectInEditor example: = function (index) { var t = this.trackBank.getChannel (index); if (t != null) t.selectInEditor (); }; = function () { this.masterTrack.selectInEditor (); };

/* * Selects the scene in Bitwig Studio. * * @param index scene bank index. / SceneBankProxy.prototype.selectScene = function (index) { this.sceneBank.getScene (index).selectInEditor (); };

addIsSelectedInEditor - yes, you would add an observer for each scene inside your bank constructor. Then when your selected scene changes, you get the callback inside the scene. Inside that callback, you'd update whatever needs updating to make your script follow properly (this is entirely up to you to write since it's application specific). Here's a working example that adds an observer via for loop during bank construction:

function SceneBankProxy (numScenes) { this.numScenes = numScenes;

this.sceneBank = host.createSceneBank (numScenes);

this.canScrollUp = false; 
this.canScrollDown = false; 
this.sceneCount = -1; 
this.scrollPosition = -1;

this.sceneBank.addScrollPositionObserver (doObject (this, SceneBankProxy.prototype.handleScrollPosition), -1); 
this.sceneBank.addCanScrollUpObserver (doObject (this, SceneBankProxy.prototype.handleCanScrollUp)); 
this.sceneBank.addCanScrollDownObserver (doObject (this, SceneBankProxy.prototype.handleCanScrollDown)); 
this.sceneBank.addSceneCountObserver (doObject (this, SceneBankProxy.prototype.handleSceneCount));

this.scenes = this.createScenes (this.numScenes);

for (var i = 0; i < numScenes; i++) 
    var scene = this.sceneBank.getScene (i); 
    scene.getName().addValueObserver (doObjectIndex (this, i, SceneBankProxy.prototype.handleSceneName)); 
    scene.exists ().addValueObserver (doObjectIndex (this, i, SceneBankProxy.prototype.handleSceneExists)); 
    scene.addIsSelectedInEditorObserver (doObjectIndex (this, i, SceneBankProxy.prototype.handleSceneSelected)); 
    scene.addPositionObserver (doObjectIndex (this, i, SceneBankProxy.prototype.handleScenePosition)); 



answered May 29 '16 at 21:47 by SonicZentropy (11)

ok, for selectInEditor: I saw the example in the FW you said, but It doesn't work for me. Whats wrong in this code?

 function init() {
    mesScenes = host.createSceneBank(100) ;
    mesScenes.getScene(3).selectInEditor() ;

answered May 29 '16 at 22:30 by Blindekinder (91)

edited May 29 '16 at 22:31

nobody can help me? I need it very soon now...


answered Jun 13 '16 at 21:21 by Blindekinder (91)

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: May 13 '16 at 09:00

Seen: 2,240 times

Last updated: Jun 13 '16 at 21:21