Transport
The transport
module contains functions for controlling FL Studio's
transport, including playback, song position, loop mode and recording.
For example, this code would set FL Studio into song mode, enable recording, then start playback:
isPlaying
Returns True
if playback is currently occurring.
Returns
bool
: whether playback is active.
Included since API version 1.
isRecording
Returns whether recording is enabled.
Returns
bool
: whether recording is enabled.
Included since API version 1.
getLoopMode
Returns the current looping mode.
Returns
-
int
: looping mode:-
0
: Pattern. -
1
: Song.
-
Included since API version 1.
setLoopMode
Toggles the looping mode between pattern and song.
Included since API version 1.
globalTransport
globalTransport(command: int, value: int, pmeflags: int = midi.PME_System, flags=midi.GT_All) -> int
Used as a generic way to run transport commands if a specific function doesn't exist for it.
WARNING
- It is not recommended to use this function if a dedicated function is available for it. Its usage can make code difficult to read and comprehend. Almost all functionality provided by this function can be done more easily and cleanly by using the dedicated functions.
Args
-
command
(int
): command to execute, refer to FL Studio manual. -
value
(int
): ??? -
pmeflags
(int
, optional): current PME Flags. Defaults tomidi.PME_System
. -
flags
(int
, optional): ??? refer to FL Studio manual.
Returns
int
: ???
Included since API version 1.
getSongPos
Returns the playback position.
Note
- This will get the position in the song in song mode, or the position
in the pattern, depending on the state of
transport.getLoopMode()
.
Args
-
mode
(int
, optional): mode for return:-
[default] (
-1
): fractional time. Returns asfloat
. -
SONGLENGTH_MS
(0
): milliseconds (asint
). -
SONGLENGTH_S
(1
): seconds (asint
). -
SONGLENGTH_ABSTICKS
(2
): absolute ticks (asint
). -
SONGLENGTH_BARS
(3
): B:S:T format, bars component (asint
). -
SONGLENGTH_STEPS
(4
): B:S:T format, steps component (asint
). -
SONGLENGTH_TICKS
(5
): B:S:T format, ticks component (asint
).
-
Example Usage
The transport.getSongPosHint()
function (returning time in
B:S:T
(bars-steps-ticks) format) can be emulated through making three calls to
the function as follows:
bars = transport.getSongPosition(3)
steps = transport.getSongPosition(4)
ticks = transport.getSongPosition(5)
overall_str = f"{bars}:{steps}:{ticks}"
Returns
float
orint
: song position.
Included since API version 1, with optional parameter added in API version 3.
setSongPos
Sets the playback position.
This will set the position in the song in song mode, or the position in the pattern.
Args
-
position
(float
orint
): new song position (type depends onmode
). -
mode
(int
, optional): mode forposition
:-
[default] (
-1
): fractional time. Requires position to be passed as typefloat
. -
SONGLENGTH_MS
(0
): milliseconds (asint
) -
SONGLENGTH_S
(1
): seconds (asint
). -
SONGLENGTH_ABSTICKS
(2
): absolute ticks (asint
).
-
Included since API version 1, with optional parameter added in API version 4.
getSongLength
Returns the total length of the song.
This only applies to the full song, not to the currently selected pattern
when in pattern mode. To get the length of the current pattern, use
patterns.getPatternLength()
with the index of the current pattern.
Args
-
mode
(int
): mode for length:-
SONGLENGTH_MS
(0
): milliseconds. -
SONGLENGTH_S
(1
): seconds. -
SONGLENGTH_ABSTICKS
(2
): absolute ticks. -
SONGLENGTH_BARS
(3
): B:S:T format, bars component. -
SONGLENGTH_STEPS
(4
): B:S:T format, steps component. -
SONGLENGTH_TICKS
(5
): B:S:T format, ticks component.
-
Returns
int
: song length.
Included since API version 3.
getSongPosHint
Returns a hint for the current playback position in .
This applies to both pattern mode and song mode.
Note that unlike FL Studio's time panel, this function won't return
positions past the end of a song or pattern, instead returning the position
of the last tick within the song/pattern. If you want to emulate the
behavior of the time panel, consider using
playlist.getVisTimeBar()
, playlist.getVisTimeStep()
and playlist.getVisTimeTick()
instead.
Returns
str
: song position.
Included since API version 1.
markerJumpJog
Jump to a marker position, where value
is an delta (increment) value.
Args
-
value
(int
): delta. -
flags
(int
, optional): ??? refer to the FL Studio manual.
Included since API version 1.
markerSelJog
Select a marker, where value
is an delta (increment) value.
Args
-
value
(int
): delta. -
flags
(int
, optional): ??? refer to the FL Studio manual.
Included since API version 1.
getHWBeatLEDState
Returns the state of the beat indicator.
HELP WANTED
- I couldn't get this to return anything other than zero.
Returns
int
: beat indicator state.
Included since API version 1.
rewind
Rewinds the playback position.
Rewinding should be considered as a toggle. All calls to this function
beginning rewinding with the SS_Start
or SS_StartStep
should have a pair
call where rewinding is stopped using the SS_Stop
option, otherwise FL
Studio will rewind forever.
Args
-
startStop
(int
): start-stop option:-
SS_Stop
(0
): Stop movement. -
SS_StartStep
(1
): Start movement, but only if FL Studio is in step editing mode. -
SS_Start
(2
); Start movement.
-
-
flags
(int
, optional): ??? refer to the FL Studio manual.
Included since API version 1.
fastForward
Fast-forwards the playback position.
Fast-forwarding should be considered as a toggle. All calls to this
function beginning fast-forwarding with the SS_Start
or SS_StartStep
should have a pair call where fast-forwarding is stopped using the
SS_Stop
option, otherwise FL Studio will fast-forward forever.
Args
-
startStop
(int
): start-stop option:-
SS_Stop
(0
): Stop movement. -
SS_StartStep
(1
): Start movement, but only if FL Studio is in step editing mode. -
SS_Start
(2
); Start movement.
-
-
flags
(int
, optional): ??? refer to the FL Studio manual.
Included since API version 1.
continuousMove
Sets playback speed, allowing a scrub-like functionality.
Scrubbing should be considered as a toggle. All calls to this
function beginning scrubbing with the SS_Start
or SS_StartStep
should have a pair call where scrubbing is stopped using the SS_Stop
option, otherwise FL Studio will scrub forever.
Args
-
speed
(int
): speed multiplier. Negative means reverse,0
is stopped, and1
is normal playback speed. -
startStop
(int
): start-stop option:-
SS_Stop
(0
): Stop movement. -
SS_StartStep
(1
): Start movement, but only if FL Studio is in step editing mode. -
SS_Start
(2
); Start movement.
-
Included since API version 1.
continuousMovePos
Sets playback speed, allowing a scrub-like functionality.
HELP WANTED
- How is this different to
continuousMove()
?
Scrubbing should be considered as a toggle. All calls to this
function beginning scrubbing with the SS_Start
or SS_StartStep
should have a pair call where scrubbing is stopped using the SS_Stop
option, otherwise FL Studio will scrub forever.
Args
-
speed
(int
): speed multiplier. Negative means reverse,0
is stopped, and1
is normal playback speed. -
startStop
(int
): start-stop option:-
SS_Stop
(0
): Stop movement. -
SS_StartStep
(1
): Start movement, but only if FL Studio is in step editing mode. -
SS_Start
(2
); Start movement.
-
Included since API version 2.
setPlaybackSpeed
Sets a playback speed multiplier.
This differs from the continuousMove
function as it only controls
speed when playback is active, rather than scrubbing through song or
pattern regardless of whether playback is active.
Args
-
speedMultiplier
(float
): speed:-
1.0
: Normal speed. -
0.25
: Minimum speed. -
4.0
: Maximum speed.
-
Included since API version 1.