VCV Rack API v2
Loading...
Searching...
No Matches
rack Namespace Reference

Root namespace for the Rack API. More...

Namespaces

namespace  app
 Rack's custom UI widgets that control the Rack state and engine.
 
namespace  asset
 Handles common path locations.
 
namespace  audio
 Abstraction for all audio drivers in Rack.
 
namespace  color
 Utilities for NVGcolor
 
namespace  componentlibrary
 Library of Rack components: knobs, ports, lights, switches, buttons, etc.
 
namespace  dsp
 Digital signal processing routines and classes.
 
namespace  engine
 High-performance classes handling modules and voltage signals between them.
 
namespace  event
 Deprecated Rack v1 event namespace.
 
namespace  gamepad
 Gamepad/joystick/controller MIDI driver.
 
namespace  history
 Action history for UI undo/redo.
 
namespace  keyboard
 Computer keyboard MIDI driver.
 
namespace  library
 Synchronizes plugins with the VCV Library and handles VCV accounts with the vcvrack.com API.
 
namespace  logger
 Logs messages to a file or the terminal.
 
namespace  math
 Extends <cmath> with extra functions and types.
 
namespace  midi
 Abstraction for all MIDI drivers in Rack.
 
namespace  midiloopback
 
namespace  network
 Networking functions for HTTP requests, downloads, and URLs.
 
namespace  patch
 Handles the Rack patch file state.
 
namespace  plugin
 Loads and manages Rack plugins.
 
namespace  random
 Random number generation.
 
namespace  settings
 Process-scope globals, most of which are persisted across launches.
 
namespace  simd
 Abstraction of aligned types for SIMD computation.
 
namespace  string
 Supplemental std::string functions.
 
namespace  system
 Cross-platform functions for OS, file path, and filesystem routines.
 
namespace  tag
 Tags describing the function(s) of modules.
 
namespace  ui
 Common graphical user interface widgets.
 
namespace  widget
 Base UI widget types.
 
namespace  window
 Handles OS windowing, OpenGL, and NanoVG.
 

Classes

struct  Context
 Rack instance state. More...
 
struct  DeferWrapper
 Defers running code until the scope is destructed. More...
 
struct  Exception
 An exception explicitly thrown by Rack or a Rack plugin. More...
 
struct  Quantity
 A controller for manipulating a float value (which subclasses must store somehow) with limits and labels. More...
 
struct  SharedLock
 
struct  SharedMutex
 Allows multiple "reader" threads to obtain a lock simultaneously, but only one "writer" thread. More...
 
struct  WeakBase
 Base class for classes that allow WeakPtrs to be used. More...
 
struct  WeakHandle
 
struct  WeakPtr
 A weak pointer to a subclass of WeakBase. More...
 

Functions

template<typename To , typename From >
To bitCast (From from)
 Casts a primitive, preserving its bits instead of converting.
 
template<typename T >
T * construct ()
 C#-style property constructor Example:
 
template<typename T , typename F , typename V , typename... Args>
T * construct (F f, V v, Args... args)
 
template<typename F >
DeferWrapper< F > deferWrapper (F f)
 
template<typename C >
const C::mapped_type & get (const C &c, const typename C::key_type &key, const typename C::mapped_type &def=typename C::mapped_type())
 Given a std::map c, returns the value of the given key, or returns def if the key doesn't exist.
 
template<typename C >
const C::value_type & get (const C &c, typename C::size_type i, const typename C::value_type &def=typename C::value_type())
 Given a std::vector c, returns the value of the given index i, or returns def if the index is out of bounds.
 
ContextcontextGet ()
 Returns the global Context pointer.
 
void contextSet (Context *context)
 Sets the context for this thread.
 
DEPRECATED ContextappGet ()
 Deprecated.
 
template<class TModule , class TModuleWidget >
plugin::ModelcreateModel (std::string slug)
 Returns a Model that constructs a Module and ModuleWidget subclass.
 
template<class TWidget >
TWidget * createWidget (math::Vec pos)
 Creates a Widget subclass with its top-left at a position.
 
template<class TWidget >
TWidget * createWidgetCentered (math::Vec pos)
 Creates a Widget subclass with its center at a position.
 
template<class TPanel = app::SvgPanel>
TPanel * createPanel (std::string svgPath)
 Creates an SvgPanel and loads the SVG from the given path.
 
template<class TPanel = app::ThemedSvgPanel>
TPanel * createPanel (std::string lightSvgPath, std::string darkSvgPath)
 Creates a ThemedSvgPanel and loads the light/dark SVGs from the given paths.
 
template<class TParamWidget >
TParamWidget * createParam (math::Vec pos, engine::Module *module, int paramId)
 
template<class TParamWidget >
TParamWidget * createParamCentered (math::Vec pos, engine::Module *module, int paramId)
 
template<class TPortWidget >
TPortWidget * createInput (math::Vec pos, engine::Module *module, int inputId)
 
template<class TPortWidget >
TPortWidget * createInputCentered (math::Vec pos, engine::Module *module, int inputId)
 
template<class TPortWidget >
TPortWidget * createOutput (math::Vec pos, engine::Module *module, int outputId)
 
template<class TPortWidget >
TPortWidget * createOutputCentered (math::Vec pos, engine::Module *module, int outputId)
 
template<class TModuleLightWidget >
TModuleLightWidget * createLight (math::Vec pos, engine::Module *module, int firstLightId)
 
template<class TModuleLightWidget >
TModuleLightWidget * createLightCentered (math::Vec pos, engine::Module *module, int firstLightId)
 
template<class TParamWidget >
TParamWidget * createLightParam (math::Vec pos, engine::Module *module, int paramId, int firstLightId)
 Creates a param with a light and calls setFirstLightId() on it.
 
template<class TParamWidget >
TParamWidget * createLightParamCentered (math::Vec pos, engine::Module *module, int paramId, int firstLightId)
 
template<class TMenu = ui::Menu>
TMenu * createMenu ()
 
template<class TMenuLabel = ui::MenuLabel>
TMenuLabel * createMenuLabel (std::string text)
 
template<class TMenuItem = ui::MenuItem>
TMenuItem * createMenuItem (std::string text, std::string rightText="")
 
template<class TMenuItem = ui::MenuItem>
TMenuItem * createMenuItem (std::string text, std::string rightText, std::function< void()> action, bool disabled=false, bool alwaysConsume=false)
 Creates a MenuItem with an action that calls a lambda function.
 
template<class TMenuItem = ui::MenuItem>
TMenuItem * createCheckMenuItem (std::string text, std::string rightText, std::function< bool()> checked, std::function< void()> action, bool disabled=false, bool alwaysConsume=false)
 Creates a MenuItem with a check mark set by a lambda function.
 
template<class TMenuItem = ui::MenuItem>
TMenuItem * createBoolMenuItem (std::string text, std::string rightText, std::function< bool()> getter, std::function< void(bool state)> setter, bool disabled=false, bool alwaysConsume=false)
 Creates a MenuItem that controls a boolean value with a check mark.
 
template<typename T >
ui::MenuItemcreateBoolPtrMenuItem (std::string text, std::string rightText, T *ptr)
 Easy wrapper for createBoolMenuItem() to modify a bool pointer.
 
template<class TMenuItem = ui::MenuItem>
TMenuItem * createSubmenuItem (std::string text, std::string rightText, std::function< void(ui::Menu *menu)> createMenu, bool disabled=false)
 Creates a MenuItem that opens a submenu.
 
template<class TMenuItem = ui::MenuItem>
TMenuItem * createIndexSubmenuItem (std::string text, std::vector< std::string > labels, std::function< size_t()> getter, std::function< void(size_t val)> setter, bool disabled=false, bool alwaysConsume=false)
 Creates a MenuItem that when hovered, opens a submenu with several MenuItems indexed by an integer.
 
template<typename T >
ui::MenuItemcreateIndexPtrSubmenuItem (std::string text, std::vector< std::string > labels, T *ptr)
 Easy wrapper for createIndexSubmenuItem() that controls an integer index at a pointer address.
 
PRIVATE void rtaudioInit ()
 
PRIVATE void rtmidiInit ()
 

Variables

const std::string APP_NAME
 
const std::string APP_EDITION
 
const std::string APP_EDITION_NAME
 
const std::string APP_VERSION_MAJOR
 
const std::string APP_VERSION
 
const std::string APP_OS
 
const std::string APP_OS_NAME
 
const std::string APP_CPU
 
const std::string APP_CPU_NAME
 
const std::string API_URL
 

Detailed Description

Root namespace for the Rack API.

Function Documentation

◆ bitCast()

template<typename To , typename From >
To rack::bitCast ( From from)

Casts a primitive, preserving its bits instead of converting.

◆ construct() [1/2]

template<typename T >
T * rack::construct ( )

C#-style property constructor Example:

Foo *foo = construct<Foo>(&Foo::greeting, "Hello world", &Foo::legs, 2);

◆ construct() [2/2]

template<typename T , typename F , typename V , typename... Args>
T * rack::construct ( F f,
V v,
Args... args )

◆ deferWrapper()

template<typename F >
DeferWrapper< F > rack::deferWrapper ( F f)

◆ get() [1/2]

template<typename C >
const C::mapped_type & rack::get ( const C & c,
const typename C::key_type & key,
const typename C::mapped_type & def = typename C::mapped_type() )

Given a std::map c, returns the value of the given key, or returns def if the key doesn't exist.

Does not add the default value to the map.

Posted to https://stackoverflow.com/a/63683271/272642. Example:

std::map<std::string, int> m;
int v = get(m, "a", 3);

v is 3 because the key "a" does not exist

int w = get(m, "a");

w is 0 because no default value is given, so it assumes the default int.

◆ get() [2/2]

template<typename C >
const C::value_type & rack::get ( const C & c,
typename C::size_type i,
const typename C::value_type & def = typename C::value_type() )

Given a std::vector c, returns the value of the given index i, or returns def if the index is out of bounds.

◆ contextGet()

Context * rack::contextGet ( )

Returns the global Context pointer.

◆ contextSet()

void rack::contextSet ( Context * context)

Sets the context for this thread.

You must set the context when preparing each thread if the code uses the APP macro in that thread.

◆ appGet()

DEPRECATED Context * rack::appGet ( )
inline

Deprecated.

Use contextGet() or the APP macro to get the current Context.

◆ createModel()

template<class TModule , class TModuleWidget >
plugin::Model * rack::createModel ( std::string slug)

Returns a Model that constructs a Module and ModuleWidget subclass.

◆ createWidget()

template<class TWidget >
TWidget * rack::createWidget ( math::Vec pos)

Creates a Widget subclass with its top-left at a position.

◆ createWidgetCentered()

template<class TWidget >
TWidget * rack::createWidgetCentered ( math::Vec pos)

Creates a Widget subclass with its center at a position.

◆ createPanel() [1/2]

template<class TPanel = app::SvgPanel>
TPanel * rack::createPanel ( std::string svgPath)

Creates an SvgPanel and loads the SVG from the given path.

◆ createPanel() [2/2]

template<class TPanel = app::ThemedSvgPanel>
TPanel * rack::createPanel ( std::string lightSvgPath,
std::string darkSvgPath )

Creates a ThemedSvgPanel and loads the light/dark SVGs from the given paths.

◆ createParam()

template<class TParamWidget >
TParamWidget * rack::createParam ( math::Vec pos,
engine::Module * module,
int paramId )

◆ createParamCentered()

template<class TParamWidget >
TParamWidget * rack::createParamCentered ( math::Vec pos,
engine::Module * module,
int paramId )

◆ createInput()

template<class TPortWidget >
TPortWidget * rack::createInput ( math::Vec pos,
engine::Module * module,
int inputId )

◆ createInputCentered()

template<class TPortWidget >
TPortWidget * rack::createInputCentered ( math::Vec pos,
engine::Module * module,
int inputId )

◆ createOutput()

template<class TPortWidget >
TPortWidget * rack::createOutput ( math::Vec pos,
engine::Module * module,
int outputId )

◆ createOutputCentered()

template<class TPortWidget >
TPortWidget * rack::createOutputCentered ( math::Vec pos,
engine::Module * module,
int outputId )

◆ createLight()

template<class TModuleLightWidget >
TModuleLightWidget * rack::createLight ( math::Vec pos,
engine::Module * module,
int firstLightId )

◆ createLightCentered()

template<class TModuleLightWidget >
TModuleLightWidget * rack::createLightCentered ( math::Vec pos,
engine::Module * module,
int firstLightId )

◆ createLightParam()

template<class TParamWidget >
TParamWidget * rack::createLightParam ( math::Vec pos,
engine::Module * module,
int paramId,
int firstLightId )

Creates a param with a light and calls setFirstLightId() on it.

Requires ParamWidget to have a light member.

◆ createLightParamCentered()

template<class TParamWidget >
TParamWidget * rack::createLightParamCentered ( math::Vec pos,
engine::Module * module,
int paramId,
int firstLightId )

◆ createMenu()

template<class TMenu = ui::Menu>
TMenu * rack::createMenu ( )

◆ createMenuLabel()

template<class TMenuLabel = ui::MenuLabel>
TMenuLabel * rack::createMenuLabel ( std::string text)

◆ createMenuItem() [1/2]

template<class TMenuItem = ui::MenuItem>
TMenuItem * rack::createMenuItem ( std::string text,
std::string rightText = "" )

◆ createMenuItem() [2/2]

template<class TMenuItem = ui::MenuItem>
TMenuItem * rack::createMenuItem ( std::string text,
std::string rightText,
std::function< void()> action,
bool disabled = false,
bool alwaysConsume = false )

Creates a MenuItem with an action that calls a lambda function.

Example:

menu->addChild(createMenuItem("Load sample", "kick.wav",
    [=]() {
        module->loadSample();
    }
));

◆ createCheckMenuItem()

template<class TMenuItem = ui::MenuItem>
TMenuItem * rack::createCheckMenuItem ( std::string text,
std::string rightText,
std::function< bool()> checked,
std::function< void()> action,
bool disabled = false,
bool alwaysConsume = false )

Creates a MenuItem with a check mark set by a lambda function.

Example:

menu->addChild(createCheckMenuItem("Loop", "",
    [=]() {
        return module->isLoop();
    },
    [=]() {
        module->toggleLoop();
    }
));

◆ createBoolMenuItem()

template<class TMenuItem = ui::MenuItem>
TMenuItem * rack::createBoolMenuItem ( std::string text,
std::string rightText,
std::function< bool()> getter,
std::function< void(bool state)> setter,
bool disabled = false,
bool alwaysConsume = false )

Creates a MenuItem that controls a boolean value with a check mark.

Example:

menu->addChild(createBoolMenuItem("Loop", "",
    [=]() {
        return module->isLoop();
    },
    [=](bool loop) {
        module->setLoop(loop);
    }
));

◆ createBoolPtrMenuItem()

template<typename T >
ui::MenuItem * rack::createBoolPtrMenuItem ( std::string text,
std::string rightText,
T * ptr )

Easy wrapper for createBoolMenuItem() to modify a bool pointer.

Example:

menu->addChild(createBoolPtrMenuItem("Loop", "", &module->loop));

◆ createSubmenuItem()

template<class TMenuItem = ui::MenuItem>
TMenuItem * rack::createSubmenuItem ( std::string text,
std::string rightText,
std::function< void(ui::Menu *menu)> createMenu,
bool disabled = false )

Creates a MenuItem that opens a submenu.

Example:

menu->addChild(createSubmenuItem("Edit", "",
    [=](Menu* menu) {
        menu->addChild(createMenuItem("Copy", "", [=]() {copy();}));
        menu->addChild(createMenuItem("Paste", "", [=]() {paste();}));
    }
));

◆ createIndexSubmenuItem()

template<class TMenuItem = ui::MenuItem>
TMenuItem * rack::createIndexSubmenuItem ( std::string text,
std::vector< std::string > labels,
std::function< size_t()> getter,
std::function< void(size_t val)> setter,
bool disabled = false,
bool alwaysConsume = false )

Creates a MenuItem that when hovered, opens a submenu with several MenuItems indexed by an integer.

Example:

menu->addChild(createIndexSubmenuItem("Mode",
    {"Hi-fi", "Mid-fi", "Lo-fi"},
    [=]() {
        return module->getMode();
    },
    [=](int mode) {
        module->setMode(mode);
    }
));

◆ createIndexPtrSubmenuItem()

template<typename T >
ui::MenuItem * rack::createIndexPtrSubmenuItem ( std::string text,
std::vector< std::string > labels,
T * ptr )

Easy wrapper for createIndexSubmenuItem() that controls an integer index at a pointer address.

Example:

menu->addChild(createIndexPtrSubmenuItem("Mode",
    {"Hi-fi", "Mid-fi", "Lo-fi"},
    &module->mode
));

◆ rtaudioInit()

PRIVATE void rack::rtaudioInit ( )

◆ rtmidiInit()

PRIVATE void rack::rtmidiInit ( )

Variable Documentation

◆ APP_NAME

const std::string rack::APP_NAME
extern

◆ APP_EDITION

const std::string rack::APP_EDITION
extern

◆ APP_EDITION_NAME

const std::string rack::APP_EDITION_NAME
extern

◆ APP_VERSION_MAJOR

const std::string rack::APP_VERSION_MAJOR
extern

◆ APP_VERSION

const std::string rack::APP_VERSION
extern

◆ APP_OS

const std::string rack::APP_OS
extern

◆ APP_OS_NAME

const std::string rack::APP_OS_NAME
extern

◆ APP_CPU

const std::string rack::APP_CPU
extern

◆ APP_CPU_NAME

const std::string rack::APP_CPU_NAME
extern

◆ API_URL

const std::string rack::API_URL
extern