/ VST Home / Technical Documentation

[3.8.1] Transport Control

On this page:

Related pages:


Introduction

This interface Vst:: ITransportControl allows a plug-in to request transport-related actions from the host.

Typical use cases include:

  • Jumping (locating) to a position
  • Starting or stopping playback or recording
  • Adjusting loop/cycle regions
  • Enabling or disabling cycle playback

All calls must be made from the UI thread. Hosts may accept or deny requests depending on their internal policies or the current editing mode (e.g., offline rendering, write-protected state, etc.).

EnumeratorDescription
LocateLocate transport to a new position. Requires a valid TransportPosition.
PlaybackStartStart playback at the current position.
PlaybackStopStop playback and keep the current position.
LocateAndPlaybackStartLocate to the specified position and start playback (position required).
PlaybackStopAndLocateStop playback and locate to the specified position (position required).
RecordOnPlaybackStartStart recording and playback at the current position.
LocateAndRecordOnPlaybackStartLocate to the specified position and start recording and playback (position required).
RecordOffStop recording and continue playback.
RecordOffPlaybackStopStop recording and playback and keep the current position.
RecordOffPlaybackStopAndLocateStop recording and playback, then locate to the specified position (position required).
SetCycleStartSets the first sample included in the cycle region (position required).
SetCycleEndSets the sample position immediately after the end of the cycle region (exclusive end position, position required). The cycle length in samples is end - start. For example, SetCycleStart(100) and SetCycleEnd(200) define a cycle of 100 samples. Sample positions included in the cycle are {100 ... 199}, while sample position 200 is outside the cycle.
CycleOnEnable looping/cycle mode.
CycleOffDisable looping/cycle mode.

Example

In mycontroller.cpp

bool mycontroller::startPlayback ()
{
    // the hostContext was given in the function ComponentBase::initialize (FUnknown* context)
    if (!hostContext)
        return false;

    Vst::ITransportControl* transportControl = nullptr;
    hostContext->queryInterface (Vst::ITransportControl::iid, (void**)&transportControl);

	if (transportControl && transportControl->isActionSupported (Vst::ITransportControl::PlaybackStart) == kResultTrue)
	{
        transportControl->requestAction (Vst::ITransportControl::PlaybackStart);
        return true;
    }
    return false;
}