Cursor Track Position

Post Reply New Topic
RELATED
PRODUCTS

Post

hey all

I'm trying to get the position of the current cursor track. I have the following code.

Code: Select all

cursorTrack = host.createCursorTrack("ct", "ct", 2, 0, true)
cursorTrack.position().addValueObserver(getCursorTrackPositionObserver, 0);

function getCursorTrackPositionObserver(value){
	cursorTrackPositionObserver = value;
}
println('cursorTrackPosition = ' + cursorTrackPositionObserver);
my script output is always 0. I would expect it to change as I select different tracks in the interface. I'm using the same function logic and value observer calls to find the position of a cursorDevice, and I am able to register things like color() and volume() to cursorTrack with success, just not position.

any ideas?

Post

dplduffy wrote: Sat Jun 13, 2020 11:54 pm hey all

I'm trying to get the position of the current cursor track. I have the following code.

Code: Select all

cursorTrack = host.createCursorTrack("ct", "ct", 2, 0, true)
cursorTrack.position().addValueObserver(getCursorTrackPositionObserver, 0);

function getCursorTrackPositionObserver(value){
	cursorTrackPositionObserver = value;
}
println('cursorTrackPosition = ' + cursorTrackPositionObserver);
my script output is always 0. I would expect it to change as I select different tracks in the interface. I'm using the same function logic and value observer calls to find the position of a cursorDevice, and I am able to register things like color() and volume() to cursorTrack with success, just not position.

any ideas?
Your println needs to be inside of the callback function if you want to see the change.

Post

hey thanks for the response Moss. So my code is actually a bit more complicated than what I posted, I cut stuff out for brevity. I'm still cutting out stuff below but here is a better overview.

Code: Select all

function init() {
	
	var cursorTrackVolume = initArray(0, 0);
	var cursorTrackPan = initArray(0, 0);
	var cursorTrackPosition = initArray(0, 0);
	var cursorTrackPositionObserver = 0;

	cursorTrack = host.createCursorTrack("ct", "ct", 2, 0, true)
	cursorTrack.volume().addValueObserver(127, getCursorTrackVar(0, cursorTrackVolume));
	cursorTrack.pan().addValueObserver(127, getCursorTrackVar(0, cursorTrackPan));
	cursorTrack.position().addValueObserver(getCursorTrackPositionObserver);
	cursorDevice = cursorTrack.createCursorDevice("cd","cd",2,CursorDeviceFollowMode.FOLLOW_SELECTION);
	cursorDevice.position().addValueObserver(getDevicePositionObserver);
	deviceBank1 = cursorTrack.createDeviceBank(32);
	
	function getCursorTrackVar (i, varToStore) {
		return function(value){
			varToStore[i] = value;
		}
	}
	
	function getCursorTrackPositionObserver(value){
		cursorTrackPositionObserver = value;
	}
	
	function getDevicePositionObserver(value){
		devicePositionObserver = value;
	}
	
	function flush(){
		println(cursorTrackPositionObserver);
		println(cursorTrackVolume);
		println(devicePositionObserver);
	}

}
So on the "flush" function everything in my script gets updated. Using this code I can get cursorTrackVolume and devicePositionObserver to update properly, but cursorTrackPositionObserver stays at 0.

If I throw a wild guess out there, I'm thinking I need to create a "bank" for my cursorTrack? the API says that position() will return the position of the track within the list of Bitwig Studio tracks, do I need to initialize a bank of these tracks to return a viable position?

Post

dplduffy wrote: Sun Jun 14, 2020 1:52 pm If I throw a wild guess out there, I'm thinking I need to create a "bank" for my cursorTrack? the API says that position() will return the position of the track within the list of Bitwig Studio tracks, do I need to initialize a bank of these tracks to return a viable position?
Out of curiosity I tried that but that dids not change anything. It seems position() is only returned for tracks from the bank. Looks to me like a bug.

Post

Well thanks for trying. I will send support an email detailing the issue and see what they say.

Post Reply

Return to “Controller Scripting”