libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AlgAudio::Canvas Class Reference

#include <Canvas.hpp>

Inheritance diagram for AlgAudio::Canvas:

Classes

struct  IOID
 
struct  IOIDWithMode
 

Public Types

enum  DataConnectionMode { DataConnectionMode::Relative, DataConnectionMode::Absolute }
 

Public Member Functions

void BlockReordering (bool enable)
 
void Connect (IOID from, IOID to)
 
void ConnectData (IOID from, IOID to, DataConnectionMode m)
 
LateReturn< std::shared_ptr
< Module > > 
CreateModule (std::string id)
 
void Disconnect (IOID from, IOID to)
 
void DisconnectData (IOID from, IOID to)
 
std::list< std::shared_ptr
< Module > > 
GetConnectedModules (std::shared_ptr< Module > m)
 
bool GetDirectAudioConnectionExists (IOID from, IOID to)
 
std::pair< bool,
DataConnectionMode
GetDirectDataConnectionExists (IOID from, IOID to)
 
std::shared_ptr< GroupGetGroup () const
 
std::shared_ptr< Module::InletGetInletByIOID (IOID) const
 
std::shared_ptr< Module::OutletGetOutletByIOID (IOID) const
 
void RecalculateOrder ()
 
void RemoveModule (std::shared_ptr< Module >)
 
bool TestNewConnectionForLoop (IOID from, IOID to)
 
virtual ~Canvas ()
 

Static Public Member Functions

static LateReturn
< std::shared_ptr< Canvas > > 
CreateEmpty (std::shared_ptr< Canvas > parent)
 

Public Attributes

std::map< IOID, std::list< IOID > > audio_connections
 
std::map< IOID, std::list
< IOIDWithMode > > 
data_connections
 
std::set< std::shared_ptr
< Module > > 
modules
 
std::shared_ptr< Moduleowner_hint = nullptr
 

Detailed Description

A Canvas represents a collection of interconnected modules. The Canvas manages connections between them, calculates topological ordering and detects loops. It also sends control data between modules. The Canvas is strictly an abstract representation. Each file consists of a single top-level Canvas. Subpatches maintain their own instance of a Canvas.

The widget CanvasView is specialised for displaying canvas contents.

See also
CanvasView

Member Enumeration Documentation

Enumerator
Relative 

A relative link between sliders keeps their fractional position the same. (Setting one param to half it's range will set the other one to half the other one's range, regardless of the parram value in such position.)

Absolute 

An absolute link between sliders keeps their values the same. (Setting\ one param to zero will set the other to zero too, regardless of zero's position in param's range.

Constructor & Destructor Documentation

virtual AlgAudio::Canvas::~Canvas ( )
virtual

Member Function Documentation

void AlgAudio::Canvas::BlockReordering ( bool  enable)

If set to true, no synth reordering will happen from now on. When set to false, synths will be topologically reordered immediatelly, and then after each new connection. This is useful if you are performing a lot of new connections at once, for example when loading a save file, and wish to avoid unnecesary order calculations after each of them.

See also
RecalculateOrder
void AlgAudio::Canvas::Connect ( IOID  from,
IOID  to 
)

Creates a new audio connection between an outlet and an inlet.

void AlgAudio::Canvas::ConnectData ( IOID  from,
IOID  to,
DataConnectionMode  m 
)

Creates a new data connection between an outlet and an inlet.

static LateReturn<std::shared_ptr<Canvas> > AlgAudio::Canvas::CreateEmpty ( std::shared_ptr< Canvas parent)
static

Creates a new instance of a Canvas with no modules inside.

Parameters
parentThe parent canvas, or nullptr if this canvas is top-level. The parent canvas must be known in order for modules like SubpatchExit to properly detect parent Subpatch module.
LateReturn<std::shared_ptr<Module> > AlgAudio::Canvas::CreateModule ( std::string  id)

Creates a new module according to the given template id, and places the new module instance on this Canvas.

This is the proper way of adding new modules.

void AlgAudio::Canvas::Disconnect ( IOID  from,
IOID  to 
)

Removes an audio connection between an outlet and an inlet, if it exists.

void AlgAudio::Canvas::DisconnectData ( IOID  from,
IOID  to 
)

Removes a data connection between an outlet and an inlet, if it exists.

std::list<std::shared_ptr<Module> > AlgAudio::Canvas::GetConnectedModules ( std::shared_ptr< Module m)

Returns a list of modules that have an inlet directly connected to any of the outlets of the module given as argument.

bool AlgAudio::Canvas::GetDirectAudioConnectionExists ( IOID  from,
IOID  to 
)

Returns true iff the specified connection already exists.

std::pair<bool, DataConnectionMode> AlgAudio::Canvas::GetDirectDataConnectionExists ( IOID  from,
IOID  to 
)

Returns true iff the specified data connection already exists. The returned pair also provides DataConnectionMode for the queried connection.

std::shared_ptr<Group> AlgAudio::Canvas::GetGroup ( ) const
inline

Returns the SC server group corresponding to this canvas. The returned pointer will never be null.

std::shared_ptr<Module::Inlet > AlgAudio::Canvas::GetInletByIOID ( IOID  ) const

Searches for an inlet by its IOID.

Returns
a shared_ptr to that inlet instance, or nullptr if not found.
std::shared_ptr<Module::Outlet> AlgAudio::Canvas::GetOutletByIOID ( IOID  ) const

Searches for an outlet by its IOID.

Returns
a shared_ptr to that outlet instance, or nullptr if not found.
void AlgAudio::Canvas::RecalculateOrder ( )

Updates SC server synth ordering. Calculates a topological ordering for the graph of interconnections, and sends the result to SC so that it can reorder synths.

void AlgAudio::Canvas::RemoveModule ( std::shared_ptr< Module )

Removes a particular module instance from the Canvas.

bool AlgAudio::Canvas::TestNewConnectionForLoop ( IOID  from,
IOID  to 
)

Returns true iff a new audio connection suggested by method arguments would create a cycle in connections graph.

Member Data Documentation

std::map<IOID, std::list<IOID> > AlgAudio::Canvas::audio_connections
std::map<IOID, std::list<IOIDWithMode> > AlgAudio::Canvas::data_connections

The list of all data connections.

std::set<std::shared_ptr<Module> > AlgAudio::Canvas::modules

The set of all modules that are placed onto (and maintained by) this Canvas.

std::shared_ptr<Module> AlgAudio::Canvas::owner_hint = nullptr

It this canvas is managed by a module, it should set this pointer to itself, so that everyone else can easlily can tell who owns this module.


The documentation for this class was generated from the following file: