SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OscSender.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Martin Hansen
3  *
4  * This file is part of SPAOP (Spatial Audio Object Positioner).
5  *
6  * SPAOP is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * SPAOP is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPAOP. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OSCSENDER_H_INCLUDED
21 #define OSCSENDER_H_INCLUDED
22 
23 #include <iostream>
24 #include <stdint.h>
25 #include "Source.h"
26 #include "Room.h"
27 
28 namespace wonder {
29 
43 class OscSender
44 {
45 public:
46 
48  virtual ~OscSender(){}
49 
58  virtual void setAddress(const std::string &newHost, const std::string &newPort) = 0;
59 
66  virtual std::string url() const = 0;
67 
74  virtual std::string hostname() const = 0;
75 
82  virtual std::string port() const = 0;
83 
88  virtual int getTtl() const = 0;
89 
95  virtual void setTtl(uint8_t ttl) = 0;
96 
103  virtual std::string getIface() const = 0;
104 
110  virtual void setIfaceByIp(const std::string& ip) = 0;
111 
121  virtual void sendSourceActivate(int sourceID) = 0;
122 
132  virtual void sendSourceDeactivate(int sourceID) = 0;
133 
143  virtual void sendSourceType(int sourceID, int type) = 0;
144 
155  virtual void sendSourcePosition(int sourceID, float x, float y) = 0;
156 
171  virtual void sendSourcePosition(int sourceID, float x, float y,
172  float duration) = 0;
173 
200  virtual void sendSourcePosition(int sourceID, float x, float y,
201  float duration, float timestamp) = 0;
202 
215  virtual void sendSourceAngle(int sourceID, float angle) = 0;
216 
227  virtual void sendSourceName(int sourceID, const std::string& name) = 0;
228 
240  virtual void sendSourceColor(int sourceID, uint8_t r, uint8_t g, uint8_t b) = 0;
241 
251  virtual void sendSourceColor(int sourceID, Colour colour){
252  sendSourceColor(sourceID, colour.r, colour.g, colour.b);
253  }
254 
266  virtual void sendSourceRotatingDirection(int sourceID, int inverted) = 0;
267 
279  virtual void sendSourceScalingDirection(int sourceID, int inverted) = 0;
280 
290  virtual void sendSourceDopplerEffect(int sourceID, int on) = 0;
291 
303  virtual void sendListenerPosition(int listenerID, float x, float y) = 0;
304 
318  virtual void sendGlobalRenderpolygon(const std::string& roomName,
319  int noOfVertices,
320  Room::Vertex* vertices) = 0;
321 
326  virtual void sendStreamVisualConnect() = 0;
327 
336  virtual void sendStreamVisualConnect(const std::string& name) = 0;
337 
349  virtual void sendStreamVisualConnect(const std::string& host,
350  const std::string& port) = 0;
351 
361  virtual void sendStreamVisualDisconnect() = 0;
362 
368  virtual void sendStreamVisualPing(int count) = 0;
369 
376  virtual void sendStreamVisualPong(int count) = 0;
377 
388  virtual void sendReply(const std::string& replyToMessage, int state,
389  const std::string& message) = 0;
390 
400  virtual void sendProjectCreateWithScore(const std::string& projectName) = 0;
401 
411  virtual void sendProjectCreate(const std::string& projectName) = 0;
412 
422  virtual void sendProjectLoad(const std::string& projectName) = 0;
423 
427  virtual void sendProjectSave() = 0;
428 
434  virtual void sendProjectSave(const std::string& projectName) = 0;
435 
446  virtual void sendPluginStandalone(const bool standAlone) = 0;
447 
453  void sendFullSourceInfo(const Source& src)
454  {
455  const int id_ = src.getID();
456  sendSourceType(id_, src.getType());
457  sendSourcePosition(id_, src.getXPos(), src.getYPos());
458  sendSourceAngle(id_, src.getAngle());
459  sendSourceColor(id_, src.getRed(), src.getGreen(), src.getBlue());
461  sendSourceName(id_, src.getName());
462  }
463 };
464 
465 }
466 
467 #endif // OSCSENDER_H_INCLUDED
virtual std::string url() const =0
Returns an url representing the destination address where this OscSender will send to...
virtual void sendProjectLoad(const std::string &projectName)=0
Sends the /WONDER/project/load message.
An abstract class describing the interface for a class that sends out the WONDER-specific OSC-message...
Definition: OscSender.h:43
virtual int getTtl() const =0
Returns the time-to-live value for messages sent by this sender.
virtual void sendSourceDeactivate(int sourceID)=0
Sends the /WONDER/source/deactivate message.
virtual void sendGlobalRenderpolygon(const std::string &roomName, int noOfVertices, Room::Vertex *vertices)=0
Sends the /WONDER/global/renderpolygon message.
virtual void sendProjectCreateWithScore(const std::string &projectName)=0
Sends the /WONDER/project/createWithScore message.
virtual void sendSourceColor(int sourceID, uint8_t r, uint8_t g, uint8_t b)=0
Sends the /WONDER/source/color message, changing the colour to be used for that source in any GUI...
virtual void setTtl(uint8_t ttl)=0
Sets the time-to-live value for messages sent by this sender.
virtual std::string hostname() const =0
Returns the hostname (or IP) of the destination address where this OscSender will send to...
virtual void sendSourceScalingDirection(int sourceID, int inverted)=0
Sends the /WONDER/source/scalingDirection message, changing the scaling direction of the source...
int getID() const
Returns the WONDER source ID.
Definition: Source.cpp:238
virtual void sendSourceDopplerEffect(int sourceID, int on)=0
Sends the /WONDER/source/dopplerEffect message, switching the doppler effect for this source on or of...
virtual void sendListenerPosition(int listenerID, float x, float y)=0
Sends the /WONDER/listener/position message, changing the position of the listener which is used to d...
uint8_t b
The blue value.
Definition: Colours.h:32
virtual std::string getIface() const =0
Returns the name of the network interface that will be used for sending messages. ...
float getAngle() const
Returns the angle of a plain source in degree (irrelevant for point sources).
Definition: Source.cpp:225
A struct describing a vertex with its three coordinates.
Definition: Room.h:40
virtual void sendReply(const std::string &replyToMessage, int state, const std::string &message)=0
Sends the /WONDER/reply message.
virtual void sendSourceActivate(int sourceID)=0
Sends the /WONDER/source/activate message.
uint8_t getGreen() const
Returns the green value of this source's colour (as in RGB).
Definition: Source.cpp:290
int getType() const
Returns 0, if this is a "plane" source, or 1, it's a point source.
Definition: Source.cpp:210
virtual void sendStreamVisualPong(int count)=0
Sends the /WONDER/stream/visual/pong message.
virtual void setAddress(const std::string &newHost, const std::string &newPort)=0
Sets the destination address where this OscSender will send to.
std::string getName() const
Returns the source's name.
Definition: Source.cpp:258
virtual void sendProjectSave()=0
Sends the /WONDER/project/save message without a parameter.
uint8_t r
The red value.
Definition: Colours.h:30
virtual void sendProjectCreate(const std::string &projectName)=0
Sends the /WONDER/project/create message.
A struct representing a (RGB) colour.
Definition: Colours.h:28
uint8_t g
The green value.
Definition: Colours.h:31
virtual void setIfaceByIp(const std::string &ip)=0
Sets the network interface to use for sending to this address by its IP.
virtual void sendPluginStandalone(const bool standAlone)=0
Sends the /WONDER/plugin/standalone message.
virtual void sendStreamVisualPing(int count)=0
Sends the /WONDER/stream/visual/ping message.
virtual ~OscSender()
Destructor.
Definition: OscSender.h:48
virtual void sendSourceAngle(int sourceID, float angle)=0
Sends the /WONDER/source/angle message.
virtual void sendSourceType(int sourceID, int type)=0
Sends the /WONDER/source/type message.
bool dopplerIsEnabled() const
Returns true, if the doppler effect is enabled.
Definition: Source.cpp:230
virtual void sendSourceName(int sourceID, const std::string &name)=0
Sends the /WONDER/source/name message, changing the source's name.
virtual void sendSourcePosition(int sourceID, float x, float y)=0
Sends the /WONDER/source/position message.
uint8_t getBlue() const
Returns the blue value of this source's colour (as in RGB).
Definition: Source.cpp:300
float getYPos() const
Returns the y-axis coordinate of this source.
Definition: Source.cpp:220
A class for objects representing a WONDER source with all its properties.
Definition: Source.h:60
virtual void sendSourceRotatingDirection(int sourceID, int inverted)=0
Sends the /WONDER/source/rotationDirection message, changing the rotation direction of the source...
virtual void sendStreamVisualDisconnect()=0
Sends the /WONDER/stream/visual/disconnect message.
float getXPos() const
Returns the x-axis coordinate of this source.
Definition: Source.cpp:215
void sendFullSourceInfo(const Source &src)
Sends out all source-related information for one Source object (type, position, angle, colour, doppler effect setting and name).
Definition: OscSender.h:453
virtual void sendStreamVisualConnect()=0
Sends the /WONDER/stream/visual/connect message.
virtual std::string port() const =0
Returns the destination port (or service name) where this OscSender will send to. ...
uint8_t getRed() const
Returns the red value of this source's colour (as in RGB).
Definition: Source.cpp:280
virtual void sendSourceColor(int sourceID, Colour colour)
Sends the /WONDER/source/color message, changing the colour to be used for that source in any GUI...
Definition: OscSender.h:251