Last few days I've tried to create clips in Bitwig using Controller Scripting Api, but without success. The Api has maybe changed, because I made some clips few years ago. My code launches, but clip is not created.
Can someone please give short example how to create (a launcher) clip and put few notes there. There is something very obvious, which I can not understand.
Thank you very much in advance!
Latest News: Bitwig updates Bitwig Studio to 5.2
Creating clips?
-
christianvogel christianvogel https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=687015
- KVRer
- 3 posts since 29 Dec, 2023
Hey there, I don't know how to add notes yet (I'm currently in the process of figuring these things out), but I found that Bitwig's API wants you to use banks for everything. If you call createEmptyClip() on a track directly, nothing happens.
Also, I found that you cannot test creating a clip from the init function. It has to be triggered afterwards. An easy testing method is just creating a function, eg: function test() { ...your test code...} and then calling that from the scripting console.
Here is an example that works:
const ext = { }
function init() {
// your init code to setup midi etc here
ext.transport = host.createTransport()
ext.trackBank = host.createMainTrackBank(4, 0, 0)
ext.trackCursor = host.createCursorTrack('CURSOR', 'Cursor', 0, 2, true)
ext.trackCursor.arm().markInterested()
for (let i = 0; i < ext.trackBank.getSizeOfBank(); i++) {
const track = ext.trackBank.getItemAt(i)
const p = track.pan()
p.markInterested()
p.setIndication(true)
const v = track.volume()
v.markInterested()
v.setIndication(true)
}
ext.trackBank.followCursorTrack(ext.trackCursor)
}
function newClip(slot: number) {
// ext.trackCursor.createNewLauncherClip(16)
const slotBank = ext.trackCursor.clipLauncherSlotBank()
slotBank.createEmptyClip(slot, 16)
}
function deleteClip(slot: number) {
const slotBank = ext.trackCursor.clipLauncherSlotBank()
slotBank.getItemAt(slot).deleteObject()
}
function recordClip(slot: number) {
const slotBank = ext.trackCursor.clipLauncherSlotBank()
slotBank.getItemAt(slot).record()
ext.transport.play()
}
function playClip(slot: number) {
const slotBank = ext.trackCursor.clipLauncherSlotBank()
slotBank.getItemAt(slot).launch()
ext.transport.play()
}
function stop() {
ext.transport.stop()
}
Of course you need to set up the init function as normal and add the flush and stop functions.
Now you should be able to start your plugin, open the script console in bitwig, and be able to type newClip(0) to add a new clip in the first clip slot of the current track.
Also, I found that you cannot test creating a clip from the init function. It has to be triggered afterwards. An easy testing method is just creating a function, eg: function test() { ...your test code...} and then calling that from the scripting console.
Here is an example that works:
const ext = { }
function init() {
// your init code to setup midi etc here
ext.transport = host.createTransport()
ext.trackBank = host.createMainTrackBank(4, 0, 0)
ext.trackCursor = host.createCursorTrack('CURSOR', 'Cursor', 0, 2, true)
ext.trackCursor.arm().markInterested()
for (let i = 0; i < ext.trackBank.getSizeOfBank(); i++) {
const track = ext.trackBank.getItemAt(i)
const p = track.pan()
p.markInterested()
p.setIndication(true)
const v = track.volume()
v.markInterested()
v.setIndication(true)
}
ext.trackBank.followCursorTrack(ext.trackCursor)
}
function newClip(slot: number) {
// ext.trackCursor.createNewLauncherClip(16)
const slotBank = ext.trackCursor.clipLauncherSlotBank()
slotBank.createEmptyClip(slot, 16)
}
function deleteClip(slot: number) {
const slotBank = ext.trackCursor.clipLauncherSlotBank()
slotBank.getItemAt(slot).deleteObject()
}
function recordClip(slot: number) {
const slotBank = ext.trackCursor.clipLauncherSlotBank()
slotBank.getItemAt(slot).record()
ext.transport.play()
}
function playClip(slot: number) {
const slotBank = ext.trackCursor.clipLauncherSlotBank()
slotBank.getItemAt(slot).launch()
ext.transport.play()
}
function stop() {
ext.transport.stop()
}
Of course you need to set up the init function as normal and add the flush and stop functions.
Now you should be able to start your plugin, open the script console in bitwig, and be able to type newClip(0) to add a new clip in the first clip slot of the current track.
-
christianvogel christianvogel https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=687015
- KVRer
- 3 posts since 29 Dec, 2023
(note that I use typescript, so you may have to remove the types if you use play JS)