SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | List of all members
wonder::SourceController Class Reference

The main communication node that keeps track of all virtual sources and enables the host DAW to control one of them. More...

#include <SourceController.h>

Inheritance diagram for wonder::SourceController:
Inheritance graph
[legend]
Collaboration diagram for wonder::SourceController:
Collaboration graph
[legend]

Classes

class  Listener
 An interface for a listener that listens to various callbacks triggered by incoming messages or connection timeout alerts. More...
 

Public Member Functions

 SourceController (VisualStreamReceiver::Factory *vsFactory, Listener *listener, ConnectionTimer::Factory *timerFactory, XmlParser *xmlParser, int maxSources)
 Constructor. More...
 
virtual ~SourceController ()
 Destructor. More...
 
const SourcegetSource () const
 Returns the Source object that is controlled by this SourceController. More...
 
std::shared_ptr< const
SourceCollection
getSources () const
 Returns a (reference-counting) shared pointer to the SourceCollection object that is controlled by this SourceController. More...
 
bool setSource (const Source &source)
 Copies the parameters of a given Source object to the internal SourceCollection (overwriting the Source with the same ID) and sets the source's ID as the one controlled by this SourceController. More...
 
bool setID (int sourceID)
 Sets the ID of the source that is controlled by this SourceController. More...
 
void setParameterAndSendChange (int paramIndex, float normalizedValue)
 Sets a parameter of the source that is controlled by this SourceController and sends it to cWONDER (if its value's difference from the value that was sent last is relevant). More...
 
void setCoordinatesAndSendChange (float normalizedX, float normalizedY)
 Sets the coordinates of the source that is controlled by this SourceController and sends them to cWONDER (if the values' difference from the values that were sent last is relevant). More...
 
void updateSourceName (const std::string &newSourceName)
 Updates the name of the source that is controlled by this SourceController and sends out the corresponding OSC message (if the ID is locked). More...
 
void updateSourceColour (const Colour colour)
 Updates the colour of the source that is controlled by this SourceController and sends out the corresponding OSC message (if the ID is locked). More...
 
void setLinkedToWonder (bool linked, bool notifyPeers=true)
 Sets whether this SourceController shall communicate with WONDER ("linked to wonder") or not. More...
 
bool isLinkedToWonder () const
 Returns the linkedToWonder status. More...
 
bool setCWonderAddress (const std::string &ip, const std::string &port)
 Sets the address where outgoing OSC messages will be sent in "linked to WONDER" mode will be sent (i.e. More...
 
std::string getCWonderHost () const
 Returns the IP or hostname that is set for cWONDER. More...
 
std::string getCWonderPort () const
 Returns the port that is set for cWONDER. More...
 
void setIdIsLocked (bool isLocked)
 Sets the ID locked status. More...
 
bool idIsLocked () const
 Returns true if the source ID is locked. More...
 
ConnectionStates connectionStatus () const
 Returns the current status of the incoming connection. More...
 
std::string connectionStatusString () const
 Returns a string representation of the current status of the incoming "Visual Stream" connection. More...
 
int rcvPort () const
 Returns the port this instance is listening on. More...
 
const std::string getDataDestHostAndPort () const
 Returns the Address where the WONDER control message are sent to. More...
 
std::shared_ptr< const RoomgetRoom () const
 Returns a (reference-counting) shared pointer to the Room object stored internally. More...
 
void setRoom (const Room &room)
 Sets the internal Room object to the parameters of a given Room object. More...
 

Detailed Description

The main communication node that keeps track of all virtual sources and enables the host DAW to control one of them.

Constructor & Destructor Documentation

wonder::SourceController::SourceController ( VisualStreamReceiver::Factory vsFactory,
Listener listener,
ConnectionTimer::Factory timerFactory,
XmlParser xmlParser,
int  maxSources 
)

Constructor.

In order to be able to use own derived implementations, the main components are passed via this constructor.

Warning
Note that various additional parameters of the SourceController are defined within the file WonderHeader.h.
Parameters
vsFactoryA VisualStreamReceiver::Factory that will be used to create the VisualStreamReceiver that this SourceController will use to receive OSC messages.
listenerA listener listening to incoming parameter changes and connection timeouts. This will usually be a SpaopAudioProcessor.
timerFactoryA ConnectionTimer::Factory that will be used to create the ConnectionTimer that this SourceController will use to keep track of ping timeouts.
xmlParserAn XmlParser that this SourceController will use to parse incoming WONDER project XML strings.
maxSourcesthe maximum number of sources allowed by the system.
wonder::SourceController::~SourceController ( )
virtual

Destructor.

Member Function Documentation

ConnectionStates wonder::SourceController::connectionStatus ( ) const

Returns the current status of the incoming connection.

This is only significant if the SourceController is linked to WONDER. If it is not linked to WONDER, the returned status is always inactive.

Returns
the current status of the incoming connection.
See Also
enum ConnectionStates.
std::string wonder::SourceController::connectionStatusString ( ) const

Returns a string representation of the current status of the incoming "Visual Stream" connection.

This is only significant if the SourceController is linked to WONDER.

Returns
A string representation of the current status of the incoming "Visual Stream" connection.
std::string wonder::SourceController::getCWonderHost ( ) const

Returns the IP or hostname that is set for cWONDER.

This may be used for storing the cWONDER address settings.

Returns
The IP or hostname that is set for cWONDER.
std::string wonder::SourceController::getCWonderPort ( ) const

Returns the port that is set for cWONDER.

This may be used for storing the cWONDER address settings.

Returns
The port that is set for cWONDER.
const std::string wonder::SourceController::getDataDestHostAndPort ( ) const

Returns the Address where the WONDER control message are sent to.

In standalone mode, this is the address of the multicast group, in linked to WONDER mode, this is the address of cWONDER.

Returns
A String containing hostname/ip and port of the Address where the WONDER control message are sent to.
std::shared_ptr< const Room > wonder::SourceController::getRoom ( ) const

Returns a (reference-counting) shared pointer to the Room object stored internally.

Returns
a shared pointer to the Room object stored internally.
const Source & wonder::SourceController::getSource ( ) const

Returns the Source object that is controlled by this SourceController.

Returns
The Source object that is controlled by this SourceController.
std::shared_ptr< const SourceCollection > wonder::SourceController::getSources ( ) const

Returns a (reference-counting) shared pointer to the SourceCollection object that is controlled by this SourceController.

Returns
A (reference-counting) shared pointer to the SourceCollection object that is controlled by this SourceController.
bool wonder::SourceController::idIsLocked ( ) const

Returns true if the source ID is locked.

bool wonder::SourceController::isLinkedToWonder ( ) const

Returns the linkedToWonder status.

Returns
true, if this SourceController is set to communicate with WONDER.
See Also
setLinkedToWonder
int wonder::SourceController::rcvPort ( ) const

Returns the port this instance is listening on.

Returns
The port this instance is listening on.
void wonder::SourceController::setCoordinatesAndSendChange ( float  normalizedX,
float  normalizedY 
)

Sets the coordinates of the source that is controlled by this SourceController and sends them to cWONDER (if the values' difference from the values that were sent last is relevant).

For coordinate changes, this is to be prefered since it will only send one OSC message while two separate calls to setParameterAndSendChange might result in two messages.

Parameters
normalizedXThe new value for the x-coordinate, normalized within [0.0 , 1.0].
normalizedYThe new value for the y-coordinate, normalized within [0.0 , 1.0].
See Also
COORD_PRECISION
bool wonder::SourceController::setCWonderAddress ( const std::string &  ip,
const std::string &  port 
)

Sets the address where outgoing OSC messages will be sent in "linked to WONDER" mode will be sent (i.e.

the address of cWONDER).

Parameters
ipA valid (IPv4) ip string.
portA valid port number between 1024 and 65535.
Returns
true if the address has been set, false if the parameters were invalid.
bool wonder::SourceController::setID ( int  sourceID)

Sets the ID of the source that is controlled by this SourceController.

Changing the ID is only allowed while the ID is not locked.

See Also
setIdIsLocked, idIsLocked
Parameters
sourceIDThe new ID of the controlled source.
Returns
true, if the ID was set succesfully; false, if setting the ID was impossible (due to an active connection).
void wonder::SourceController::setIdIsLocked ( bool  isLocked)

Sets the ID locked status.

If the sourceID is locked, it cannot be changed, and listening to incoming messages is enabled. If it is not locked, the ID can be changed, but listening to incoming messages is disabled. On switching from !isLocked to isLocked, a /WONDER/source/activate message will be sent, on switching from isLocked to !isLocked, a /WONDER/source/deactivate message will be sent.

Parameters
isLockedtrue if changing the ID shall be disabled and listening to incoming messages enabled.
void wonder::SourceController::setLinkedToWonder ( bool  linked,
bool  notifyPeers = true 
)

Sets whether this SourceController shall communicate with WONDER ("linked to wonder") or not.

If it is linked to WONDER, source control messages (position, angle, etc) are sent to WONDER, visual stream connect message is sent to the multicaster. Otherwise (stand-alone-mode), all messages are sent to the plugin's peers via the multicast group.

Parameters
linkedtrue, if this plugin shall communicate to WONDER, false for stand-alone-mode.
notifyPeerstrue if a /WONDER/plugin/standalone message shall be sent to the multicast group to notify the peer plugins about the change.
void wonder::SourceController::setParameterAndSendChange ( int  paramIndex,
float  normalizedValue 
)

Sets a parameter of the source that is controlled by this SourceController and sends it to cWONDER (if its value's difference from the value that was sent last is relevant).

Depending on the parameter, the right message format is chosen.

Parameters
paramIndexA parameter index value as defined in the enum Source::AutomatedParameters.
normalizedValueThe new value for that parameter, normalized within [0.0 , 1.0].
See Also
COORD_PRECISION, ANGLE_PRECISION
void wonder::SourceController::setRoom ( const Room room)

Sets the internal Room object to the parameters of a given Room object.

Parameters
roomThe Room object that shall be copied into the internal Room object.
bool wonder::SourceController::setSource ( const Source source)

Copies the parameters of a given Source object to the internal SourceCollection (overwriting the Source with the same ID) and sets the source's ID as the one controlled by this SourceController.

This is meant to be used for restoring states from saved files (e.g. the audio-plugin's presets) and is only allowed while the the ID is not locked.

See Also
setIdIsLocked, idIsLocked
Returns
true on success - false if the Source object's parameters could not be copied because the source's ID was out of range or beauce the SourceController's was communicating.
Warning
Take extra care that you really want to copy all of a Source's paramters (e.g. including isActive()).
void wonder::SourceController::updateSourceColour ( const Colour  colour)

Updates the colour of the source that is controlled by this SourceController and sends out the corresponding OSC message (if the ID is locked).

Parameters
colourThe new colour of the source.
void wonder::SourceController::updateSourceName ( const std::string &  newSourceName)

Updates the name of the source that is controlled by this SourceController and sends out the corresponding OSC message (if the ID is locked).

Parameters
newSourceNameThe new name of the source.