Skip to content

State Functions and Variables

BitwigBuddy provides a set of functions to retrieve state information from Bitwig Studio. These functions can be used in macros to access information about the current track, device, clip, transport, and more.

Overview of State Functions

State functions allow you to:

  • Get information about the current track (name, number, color, etc.)
  • Retrieve details about the current device
  • Access clip properties and status
  • Check transport settings (BPM, time signature, etc.)
  • Get project information

These values can be used in your macros for conditional logic, displaying information, or creating dynamic behaviors.

Function List

Track Information

FunctionReturn TypeDescription
getCurrentTrackName()StringGets the name of the currently selected track
getCurrentTrackNumber()IntegerGets the position of the current track (1-based index)
getCurrentTrackColor()StringGets the color of the current track as hex code (without #)
isCurrentTrackMuted()BooleanChecks if the current track is muted
isCurrentTrackSoloed()BooleanChecks if the current track is soloed
isCurrentTrackArmed()BooleanChecks if the current track is armed for recording
getCurrentTrackVolume()DoubleGets the current track volume (0.0 to 1.0)
getCurrentTrackPan()DoubleGets the current track pan position (-1.0 to 1.0)
getTrackCount()IntegerGets the total number of tracks in the current project

Device Information

FunctionReturn TypeDescription
getCurrentDeviceName()StringGets the name of the currently selected device
isCurrentDeviceEnabled()BooleanChecks if the current device is enabled
isCurrentDeviceWindowOpen()BooleanChecks if the current device window is open
getDeviceCount()IntegerGets the total number of devices in the current track

Clip Information

FunctionReturn TypeDescription
getCurrentClipName()StringGets the name of the currently selected clip
getCurrentClipColor()StringGets the color of the current clip as hex code (without #)
isCurrentClipLooping()BooleanChecks if the current clip is set to loop
getCurrentClipLength()DoubleGets the length of the current clip in beats
isCurrentClipPlaying()BooleanChecks if the current clip is playing
isCurrentClipRecording()BooleanChecks if the current clip is recording
isCurrentClipSelected()BooleanChecks if the current clip is selected

Transport Information

FunctionReturn TypeDescription
getCurrentBpm()DoubleGets the current project tempo in BPM
getTimeSignatureNumerator()IntegerGets the numerator of the current time signature
getTimeSignatureDenominator()IntegerGets the denominator of the current time signature
isPlaying()BooleanChecks if transport is currently playing
isRecording()BooleanChecks if transport is currently recording
getPlayPosition()DoubleGets the current play position in beats
isMetronomeEnabled()BooleanChecks if the metronome is enabled
isArrangerLoopEnabled()BooleanChecks if the arranger loop is enabled

Project Information

FunctionReturn TypeDescription
getProjectName()StringGets the name of the current project

Scene Information

FunctionReturn TypeDescription
getCurrentSceneIndex()IntegerGets the index of the current scene
getCurrentSceneName()StringGets the name of the current scene

Using State Functions in Macros

Here's an example of how to use these functions in a macro:

Macro: "Get Functions and Variables"
Description: "Examples of get functions."
Author: "Centomila"

// Track and project information example

// Assign the current track name to a variable
var trackName = getCurrentTrackName()

Wait (1500)
// Show the track name in a message popup
Message(Current track name is: ${trackName})

Wait (1500)
// Get track position (number)
var trackNumber = getCurrentTrackNumber()
Message(Track position: ${trackNumber})

Wait (1500)
// Get device information
var deviceName = getCurrentDeviceName()
Message(Current device: ${deviceName})

Wait (1500)
// Get transport information
var bpm = getCurrentBpm()
Message("Project tempo: ${bpm} BPM")

Wait (1500)
// Time signature information
var num = getTimeSignatureNumerator()
var denom = getTimeSignatureDenominator() 
Message("Time signature: ${num}/${denom}")

// Send information to the console for logging
Console("== Bitwig State Information ==")
Console("Track: ${trackName} (#${trackNumber})")
Console("Device: ${deviceName}")
Console("Tempo: ${bpm} BPM")
Console("Time signature: ${num}/${denom}")

Using Variables in Expressions

You can use these functions directly in expressions or assign them to variables:

// Direct use in expressions
Message("Current project: ${getProjectName()}")

// Using variables
var trackName = getCurrentTrackName()
var deviceName = getCurrentDeviceName()
var isArmed = isCurrentTrackArmed()
Message("Track: ${trackName}, Device: ${deviceName}")

// Using in conditional statements
if (${isArmed}) {
    Message("Track is armed for recording!")
}

if (!${isArmed}) {
    Message("Track is NOT armed for recording!")
}

Notes for Using State Functions

  • These functions provide read-only access to Bitwig Studio's state
  • Values are retrieved at the moment the function is called
  • For real-time monitoring, you may need to call these functions periodically