Search code examples
clipbitwig

Bitwig: Get specific clip in independent of selection


I want to get a clip object independent of the currently selected object in the mixer view.

I can only get a clipLauncherSlotBank via

host.createTrackBank(1, 0, 1).getItemAt(0).clipLauncherSlotBank()

but not the clip.

I can also get a pinnableCursorClip via

host.createCursorTrack("8dbcc337-9a41-4ab5-9dd9-97cd74c3437f", "Test", 0, 1, false).createLauncherCursorClip(16, 128)

but how can I then set the cursorTrack to a specific track and/or the pinnableCursorClip to a specific clip?


Solution

  • @Override
    public void init() {
      ControllerHost host = getHost();
      host.getMidiInPort(0).setMidiCallback((ShortMidiMessageReceivedCallback) this::onMidi0);
    
      int trackIndex = 6;
      int sceneIndex = 0;
      TrackBank trackBank = host.createTrackBank(trackIndex + 1, 0, sceneIndex + 1);
      Track track = trackBank.getItemAt(trackIndex);
      ClipLauncherSlotBank clipLauncherSlotBank = track.clipLauncherSlotBank();
      ClipLauncherSlot clipLauncherSlot = clipLauncherSlotBank.getItemAt(sceneIndex);
      clipLauncherSlot.select();
      CursorTrack cursorTrack = host.createCursorTrack("8dbcc337-9a41-4ab5-9dd9-97cd74c3437f", "Test", 0, sceneIndex + 1, false);
      this.pinnableCursorClip = cursorTrack.createLauncherCursorClip(16, 128);
    
      host.scheduleTask(() -> {
         cursorTrack.isPinned().set(true);
         pinnableCursorClip.isPinned().set(true);
      }, 1000);
    }
    
    public void onMidi0(ShortMidiMessage msg) {
      pinnableCursorClip.setStep(0, 0, 127, 0.125);
    }