summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/invoker/modality
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/plugins/invoker/modality')
-rw-r--r--src/uscxml/plugins/invoker/modality/MMIComponent.cpp28
-rw-r--r--src/uscxml/plugins/invoker/modality/MMIComponent.h52
-rw-r--r--src/uscxml/plugins/invoker/modality/UmundoComponent.cpp44
-rw-r--r--src/uscxml/plugins/invoker/modality/UmundoComponent.h26
-rw-r--r--src/uscxml/plugins/invoker/modality/miles/SpatialAudio.cpp280
-rw-r--r--src/uscxml/plugins/invoker/modality/miles/SpatialAudio.h46
6 files changed, 238 insertions, 238 deletions
diff --git a/src/uscxml/plugins/invoker/modality/MMIComponent.cpp b/src/uscxml/plugins/invoker/modality/MMIComponent.cpp
index 0655806..170f4bc 100644
--- a/src/uscxml/plugins/invoker/modality/MMIComponent.cpp
+++ b/src/uscxml/plugins/invoker/modality/MMIComponent.cpp
@@ -2,41 +2,41 @@
#include "uscxml/Interpreter.h"
namespace uscxml {
-
+
MMIComponent::MMIComponent() {
}
-
+
MMIComponent::~MMIComponent() {
};
-
+
Invoker* MMIComponent::create(Interpreter* interpreter) {
- MMIComponent* invoker = new MMIComponent();
- invoker->_interpreter = interpreter;
- return invoker;
+ MMIComponent* invoker = new MMIComponent();
+ invoker->_interpreter = interpreter;
+ return invoker;
}
Data MMIComponent::getDataModelVariables() {
- Data data;
- return data;
+ Data data;
+ return data;
}
void MMIComponent::send(SendRequest& req) {
-
+
}
void MMIComponent::cancel(const std::string sendId) {
- assert(false);
+ assert(false);
}
void MMIComponent::sendToParent(SendRequest& req) {
- req.invokeid = _invokeId;
- assert(false);
+ req.invokeid = _invokeId;
+ assert(false);
}
void MMIComponent::invoke(InvokeRequest& req) {
- _invokeId = req.invokeid;
-
+ _invokeId = req.invokeid;
+
}
} \ No newline at end of file
diff --git a/src/uscxml/plugins/invoker/modality/MMIComponent.h b/src/uscxml/plugins/invoker/modality/MMIComponent.h
index a83775f..96d796b 100644
--- a/src/uscxml/plugins/invoker/modality/MMIComponent.h
+++ b/src/uscxml/plugins/invoker/modality/MMIComponent.h
@@ -9,27 +9,27 @@ class Interpreter;
class MMIComponent : public Invoker {
public:
-
- enum State {
- PAUSED,
- RUNNING,
- IDLE,
- TERMINATED
+
+ enum State {
+ PAUSED,
+ RUNNING,
+ IDLE,
+ TERMINATED
};
MMIComponent();
- virtual ~MMIComponent();
- virtual Invoker* create(Interpreter* interpreter);
-
- virtual Data getDataModelVariables();
- virtual void send(SendRequest& req);
- virtual void cancel(const std::string sendId);
- virtual void invoke(InvokeRequest& req);
- virtual void sendToParent(SendRequest& req);
+ virtual ~MMIComponent();
+ virtual Invoker* create(Interpreter* interpreter);
+
+ virtual Data getDataModelVariables();
+ virtual void send(SendRequest& req);
+ virtual void cancel(const std::string sendId);
+ virtual void invoke(InvokeRequest& req);
+ virtual void sendToParent(SendRequest& req);
protected:
- std::string _invokeId;
- Interpreter* _interpreter;
+ std::string _invokeId;
+ Interpreter* _interpreter;
State _state;
};
@@ -39,31 +39,31 @@ protected:
class MMICoreMessage {
public:
- std::string source;
- std::string target;
- std::string data;
- std::string requestId;
+ std::string source;
+ std::string target;
+ std::string data;
+ std::string requestId;
};
class MMICtxMessage : public MMICoreMessage {
public:
- std::string context;
+ std::string context;
};
class MMIStartMessage : public MMICtxMessage {
public:
- std::string content;
- std::string contentURL;
+ std::string content;
+ std::string contentURL;
};
class MMISimpleStatusMessage : public MMICtxMessage {
public:
- std::string status;
+ std::string status;
};
class MMIStatusMessage : public MMISimpleStatusMessage {
public:
- std::string statusInfo;
+ std::string statusInfo;
};
/** Concrete MMI messages */
@@ -86,7 +86,7 @@ class MMIPrepareRequest : public MMIStartMessage {};
/***/
class MMIExtensionNotification : public MMICtxMessage {
- std::string name;
+ std::string name;
};
/***/
diff --git a/src/uscxml/plugins/invoker/modality/UmundoComponent.cpp b/src/uscxml/plugins/invoker/modality/UmundoComponent.cpp
index 22dd279..10f23d4 100644
--- a/src/uscxml/plugins/invoker/modality/UmundoComponent.cpp
+++ b/src/uscxml/plugins/invoker/modality/UmundoComponent.cpp
@@ -2,48 +2,48 @@
#include "uscxml/Interpreter.h"
namespace uscxml {
-
-UmundoComponent::UmundoComponent() {
+
+UmundoComponent::UmundoComponent() {
}
-
+
UmundoComponent::~UmundoComponent() {
- delete _invokedInterpreter;
+ delete _invokedInterpreter;
};
-
+
Invoker* UmundoComponent::create(Interpreter* interpreter) {
- UmundoComponent* invoker = new UmundoComponent();
- invoker->_parentInterpreter = interpreter;
- return invoker;
+ UmundoComponent* invoker = new UmundoComponent();
+ invoker->_parentInterpreter = interpreter;
+ return invoker;
}
Data UmundoComponent::getDataModelVariables() {
- Data data;
- return data;
+ Data data;
+ return data;
}
void UmundoComponent::send(SendRequest& req) {
- assert(false);
+ assert(false);
}
void UmundoComponent::cancel(const std::string sendId) {
- assert(false);
+ assert(false);
}
void UmundoComponent::sendToParent(SendRequest& req) {
- req.invokeid = _invokeId;
- _parentInterpreter->receive(req);
+ req.invokeid = _invokeId;
+ _parentInterpreter->receive(req);
}
void UmundoComponent::invoke(InvokeRequest& req) {
- _invokeId = req.invokeid;
- _invokedInterpreter = Interpreter::fromURI(req.src);
- DataModel* dataModel = _invokedInterpreter->getDataModel();
- if (dataModel != NULL) {
-
- }
- _invokedInterpreter->setInvoker(this);
- _invokedInterpreter->start();
+ _invokeId = req.invokeid;
+ _invokedInterpreter = Interpreter::fromURI(req.src);
+ DataModel* dataModel = _invokedInterpreter->getDataModel();
+ if (dataModel != NULL) {
+
+ }
+ _invokedInterpreter->setInvoker(this);
+ _invokedInterpreter->start();
}
} \ No newline at end of file
diff --git a/src/uscxml/plugins/invoker/modality/UmundoComponent.h b/src/uscxml/plugins/invoker/modality/UmundoComponent.h
index f2c76c4..69b3961 100644
--- a/src/uscxml/plugins/invoker/modality/UmundoComponent.h
+++ b/src/uscxml/plugins/invoker/modality/UmundoComponent.h
@@ -6,25 +6,25 @@
namespace uscxml {
class Interpreter;
-
+
class UmundoComponent : public MMIComponent {
public:
UmundoComponent();
- virtual ~UmundoComponent();
- virtual Invoker* create(Interpreter* interpreter);
-
- virtual Data getDataModelVariables();
- virtual void send(SendRequest& req);
- virtual void cancel(const std::string sendId);
- virtual void invoke(InvokeRequest& req);
- virtual void sendToParent(SendRequest& req);
+ virtual ~UmundoComponent();
+ virtual Invoker* create(Interpreter* interpreter);
+
+ virtual Data getDataModelVariables();
+ virtual void send(SendRequest& req);
+ virtual void cancel(const std::string sendId);
+ virtual void invoke(InvokeRequest& req);
+ virtual void sendToParent(SendRequest& req);
protected:
- std::string _invokeId;
- Interpreter* _invokedInterpreter;
- Interpreter* _parentInterpreter;
+ std::string _invokeId;
+ Interpreter* _invokedInterpreter;
+ Interpreter* _parentInterpreter;
};
-
+
}
#endif /* end of include guard: UMUNDOCOMPONENT_H_VMW54W1R */
diff --git a/src/uscxml/plugins/invoker/modality/miles/SpatialAudio.cpp b/src/uscxml/plugins/invoker/modality/miles/SpatialAudio.cpp
index 13091ae..acc5c4b 100644
--- a/src/uscxml/plugins/invoker/modality/miles/SpatialAudio.cpp
+++ b/src/uscxml/plugins/invoker/modality/miles/SpatialAudio.cpp
@@ -14,184 +14,184 @@ namespace uscxml {
#ifdef BUILD_AS_PLUGINS
PLUMA_CONNECTOR
-bool connect(pluma::Host& host){
- host.add( new SpatialAudioProvider() );
- return true;
+bool connect(pluma::Host& host) {
+ host.add( new SpatialAudioProvider() );
+ return true;
}
#endif
SpatialAudio::SpatialAudio() {
- _audioDevOpen = false;
- _audioDev = NULL;
- _audioDevIndex = -1;
- _pos = new float[3];
- _pos[0] = _pos[1] = _pos[2] = 0.0;
- _listener = new float[3];
- _listener[0] = _listener[1] = _listener[2] = 0.0;
+ _audioDevOpen = false;
+ _audioDev = NULL;
+ _audioDevIndex = -1;
+ _pos = new float[3];
+ _pos[0] = _pos[1] = _pos[2] = 0.0;
+ _listener = new float[3];
+ _listener[0] = _listener[1] = _listener[2] = 0.0;
}
-
+
SpatialAudio::~SpatialAudio() {
};
-
+
Invoker* SpatialAudio::create(Interpreter* interpreter) {
- SpatialAudio* invoker = new SpatialAudio();
- invoker->_interpreter = interpreter;
- return invoker;
+ SpatialAudio* invoker = new SpatialAudio();
+ invoker->_interpreter = interpreter;
+ return invoker;
}
Data SpatialAudio::getDataModelVariables() {
- Data data;
+ Data data;
// data.compound["foo"] = Data("32");
- return data;
+ return data;
}
void SpatialAudio::send(SendRequest& req) {
- if (!_audioDevOpen) {
- _audioDev = miles_audio_device_open(_audioDevIndex, 0, 22050, 2, 1, 0);
- if (_audioDev != NULL) {
- _audioDevOpen = true;
- float rolloffFactor = 0.2;
- miles_audio_device_control(_audioDev, MILES_AUDIO_DEVICE_CTRL_SET_ROLLOFF_FACTOR, &rolloffFactor);
- }
- }
-
- if (boost::iequals(req.name, "play")) {
- if (_audioDevOpen) {
- getPosFromParams(req.params, _pos);
+ if (!_audioDevOpen) {
+ _audioDev = miles_audio_device_open(_audioDevIndex, 0, 22050, 2, 1, 0);
+ if (_audioDev != NULL) {
+ _audioDevOpen = true;
+ float rolloffFactor = 0.2;
+ miles_audio_device_control(_audioDev, MILES_AUDIO_DEVICE_CTRL_SET_ROLLOFF_FACTOR, &rolloffFactor);
+ }
+ }
+
+ if (boost::iequals(req.name, "play")) {
+ if (_audioDevOpen) {
+ getPosFromParams(req.params, _pos);
// std::cout << "Source: ";
// for (int i = 0; i < 3; i++) {
// std::cout << _pos[i] << " ";
// }
// std::cout << std::endl;
-
- miles_audio_device_control(_audioDev, MILES_AUDIO_DEVICE_CTRL_SET_POSITION, _pos);
-
- char* buffer = (char*)malloc(_audioDev->chunk_size);
- // skip wav header
- _dataStream.seekg(44);
-
- while(_dataStream.readsome(buffer, _audioDev->chunk_size) != 0) {
- miles_audio_device_write(_audioDev, buffer, _audioDev->chunk_size);
- }
- free(buffer);
- }
- } else if (boost::iequals(req.name, "move.listener")) {
- if (_audioDevOpen) {
- getPosFromParams(req.params, _listener);
-
- std::cout << "Listener: ";
- for (int i = 0; i < 3; i++) {
- std::cout << _listener[i] << " ";
- }
- std::cout << std::endl;
-
- miles_audio_device_control(_audioDev, MILES_AUDIO_DEVICE_CTRL_SET_LISTENER_POS, _listener);
-
- }
- }
+
+ miles_audio_device_control(_audioDev, MILES_AUDIO_DEVICE_CTRL_SET_POSITION, _pos);
+
+ char* buffer = (char*)malloc(_audioDev->chunk_size);
+ // skip wav header
+ _dataStream.seekg(44);
+
+ while(_dataStream.readsome(buffer, _audioDev->chunk_size) != 0) {
+ miles_audio_device_write(_audioDev, buffer, _audioDev->chunk_size);
+ }
+ free(buffer);
+ }
+ } else if (boost::iequals(req.name, "move.listener")) {
+ if (_audioDevOpen) {
+ getPosFromParams(req.params, _listener);
+
+ std::cout << "Listener: ";
+ for (int i = 0; i < 3; i++) {
+ std::cout << _listener[i] << " ";
+ }
+ std::cout << std::endl;
+
+ miles_audio_device_control(_audioDev, MILES_AUDIO_DEVICE_CTRL_SET_LISTENER_POS, _listener);
+
+ }
+ }
}
void SpatialAudio::cancel(const std::string sendId) {
- assert(false);
+ assert(false);
}
void SpatialAudio::sendToParent(SendRequest& req) {
- req.invokeid = _invokeId;
- assert(false);
+ req.invokeid = _invokeId;
+ assert(false);
}
void SpatialAudio::invoke(InvokeRequest& req) {
- _invokeId = req.invokeid;
-
- if (req.src.length() > 0) {
- Arabica::io::URI url(req.src);
- if (!_interpreter->makeAbsolute(url)) {
- LOG(ERROR) << "Source attribute for audio invoker has relative URI " << req.src << " with no base URI set for interpreter";
- return;
- }
-
- URL scriptUrl(url.as_string());
- _dataStream << scriptUrl;
- }
-
- getPosFromParams(req.params, _pos);
-
- struct miles_audio_device_description *devices;
- int ndevs;
-
+ _invokeId = req.invokeid;
+
+ if (req.src.length() > 0) {
+ Arabica::io::URI url(req.src);
+ if (!_interpreter->makeAbsolute(url)) {
+ LOG(ERROR) << "Source attribute for audio invoker has relative URI " << req.src << " with no base URI set for interpreter";
+ return;
+ }
+
+ URL scriptUrl(url.as_string());
+ _dataStream << scriptUrl;
+ }
+
+ getPosFromParams(req.params, _pos);
+
+ struct miles_audio_device_description *devices;
+ int ndevs;
+
ndevs = miles_audio_device_get_supported_devices(&devices);
-
- for (int i = 0; i < ndevs; i++) {
+
+ for (int i = 0; i < ndevs; i++) {
if ((devices[i].capabilities & MILES_AUDIO_DEVICE_CAPABILITY_SPATIAL) &&
- (devices[i].capabilities & MILES_AUDIO_DEVICE_CAPABILITY_OUTPUT)) {
- _audioDevIndex = i;
- break;
- }
- }
+ (devices[i].capabilities & MILES_AUDIO_DEVICE_CAPABILITY_OUTPUT)) {
+ _audioDevIndex = i;
+ break;
+ }
+ }
}
- void SpatialAudio::getPosFromParams(std::map<std::string, std::list<std::string> >& params, float* position) {
- // vector explicitly given
- try {
- if (params.find("x") != params.end())
- position[0] = boost::lexical_cast<float>(params["x"].front());
- if (params.find("y") != params.end())
- position[1] = boost::lexical_cast<float>(params["y"].front());
- if (params.find("z") != params.end())
- position[2] = boost::lexical_cast<float>(params["z"].front());
- } catch (boost::bad_lexical_cast& e) {
- LOG(ERROR) << "Cannot interpret x, y or z as float value in params: " << e.what();
- }
-
- try {
- // right is an alias for x
- if (params.find("right") != params.end())
- position[0] = boost::lexical_cast<float>(params["right"].front());
- // height is an alias for y
- if (params.find("height") != params.end())
- position[1] = boost::lexical_cast<float>(params["height"].front());
- // front is an alias for z
- if (params.find("front") != params.end())
- position[2] = boost::lexical_cast<float>(params["front"].front());
- } catch (boost::bad_lexical_cast& e) {
- LOG(ERROR) << "Cannot interpret right, height or front as float value in params: " << e.what();
- }
-
- // do we have a position on a circle?
- try {
- if (params.find("circle") != params.end()) {
- float rad = posToRadian(params["circle"].front());
- position[0] = cosf(rad);
- position[2] = -1 * sinf(rad); // z axis increases to front
- }
- } catch (boost::bad_lexical_cast& e) {
- LOG(ERROR) << "Cannot interpret circle as float value in params: " << e.what();
- }
+void SpatialAudio::getPosFromParams(std::map<std::string, std::list<std::string> >& params, float* position) {
+ // vector explicitly given
+ try {
+ if (params.find("x") != params.end())
+ position[0] = boost::lexical_cast<float>(params["x"].front());
+ if (params.find("y") != params.end())
+ position[1] = boost::lexical_cast<float>(params["y"].front());
+ if (params.find("z") != params.end())
+ position[2] = boost::lexical_cast<float>(params["z"].front());
+ } catch (boost::bad_lexical_cast& e) {
+ LOG(ERROR) << "Cannot interpret x, y or z as float value in params: " << e.what();
+ }
+
+ try {
+ // right is an alias for x
+ if (params.find("right") != params.end())
+ position[0] = boost::lexical_cast<float>(params["right"].front());
+ // height is an alias for y
+ if (params.find("height") != params.end())
+ position[1] = boost::lexical_cast<float>(params["height"].front());
+ // front is an alias for z
+ if (params.find("front") != params.end())
+ position[2] = boost::lexical_cast<float>(params["front"].front());
+ } catch (boost::bad_lexical_cast& e) {
+ LOG(ERROR) << "Cannot interpret right, height or front as float value in params: " << e.what();
+ }
+
+ // do we have a position on a circle?
+ try {
+ if (params.find("circle") != params.end()) {
+ float rad = posToRadian(params["circle"].front());
+ position[0] = cosf(rad);
+ position[2] = -1 * sinf(rad); // z axis increases to front
+ }
+ } catch (boost::bad_lexical_cast& e) {
+ LOG(ERROR) << "Cannot interpret circle as float value in params: " << e.what();
+ }
// std::cout << _pos[0] << ":" << _pos[1] << ":" << _pos[2] << std::endl;
}
-
+
float SpatialAudio::posToRadian(std::string& position) {
- boost::trim(position);
- float rad = 0;
-
- if (position.size() > 3 && boost::iequals("deg", position.substr(position.length() - 3, 3))) {
- rad = boost::lexical_cast<float>(position.substr(0, position.size() - 3));
- rad = fmodf(rad, 360); // into range [0-360]
- rad /= 180; // into range [0-2]
- rad *= M_PI; // into range [0-2PI]
- rad -= M_PI_2; // 0 to top;
- rad *= -1; // make clockwise
- rad += 2 * M_PI; // make positive
- } else if (position.size() > 3 && boost::iequals("rad", position.substr(position.length() - 3, 3))) {
- rad = boost::lexical_cast<float>(position.substr(0, position.size() - 3));
- rad = fmodf(rad, M_PI * 2); // into range [0-2*PI]
- } else {
- LOG(ERROR) << "Cannot make sense of position value " << position << ": does not end in 'deg', 'rad'";
- }
- return rad;
+ boost::trim(position);
+ float rad = 0;
+
+ if (position.size() > 3 && boost::iequals("deg", position.substr(position.length() - 3, 3))) {
+ rad = boost::lexical_cast<float>(position.substr(0, position.size() - 3));
+ rad = fmodf(rad, 360); // into range [0-360]
+ rad /= 180; // into range [0-2]
+ rad *= M_PI; // into range [0-2PI]
+ rad -= M_PI_2; // 0 to top;
+ rad *= -1; // make clockwise
+ rad += 2 * M_PI; // make positive
+ } else if (position.size() > 3 && boost::iequals("rad", position.substr(position.length() - 3, 3))) {
+ rad = boost::lexical_cast<float>(position.substr(0, position.size() - 3));
+ rad = fmodf(rad, M_PI * 2); // into range [0-2*PI]
+ } else {
+ LOG(ERROR) << "Cannot make sense of position value " << position << ": does not end in 'deg', 'rad'";
+ }
+ return rad;
}
-
+
} \ No newline at end of file
diff --git a/src/uscxml/plugins/invoker/modality/miles/SpatialAudio.h b/src/uscxml/plugins/invoker/modality/miles/SpatialAudio.h
index bbbf478..7632f52 100644
--- a/src/uscxml/plugins/invoker/modality/miles/SpatialAudio.h
+++ b/src/uscxml/plugins/invoker/modality/miles/SpatialAudio.h
@@ -14,14 +14,14 @@ extern "C" {
namespace uscxml {
class Interpreter;
-
+
class SpatialAudio : public MMIComponent {
public:
SpatialAudio();
- virtual ~SpatialAudio();
- virtual Invoker* create(Interpreter* interpreter);
-
- virtual std::set<std::string> getNames() {
+ virtual ~SpatialAudio();
+ virtual Invoker* create(Interpreter* interpreter);
+
+ virtual std::set<std::string> getNames() {
std::set<std::string> names;
names.insert("spatial-audio");
names.insert("audio");
@@ -30,29 +30,29 @@ public:
return names;
}
- virtual Data getDataModelVariables();
- virtual void send(SendRequest& req);
- virtual void cancel(const std::string sendId);
- virtual void invoke(InvokeRequest& req);
- virtual void sendToParent(SendRequest& req);
+ virtual Data getDataModelVariables();
+ virtual void send(SendRequest& req);
+ virtual void cancel(const std::string sendId);
+ virtual void invoke(InvokeRequest& req);
+ virtual void sendToParent(SendRequest& req);
- void getPosFromParams(std::map<std::string, std::list<std::string> >& params, float* position);
- static float posToRadian(std::string& position);
+ void getPosFromParams(std::map<std::string, std::list<std::string> >& params, float* position);
+ static float posToRadian(std::string& position);
protected:
- std::string _invokeId;
- Interpreter* _invokedInterpreter;
-
- std::stringstream _dataStream;
-
- float* _pos;
- float* _listener;
- bool _audioDevOpen;
- int _audioDevIndex;
- struct miles_audio_device* _audioDev;
+ std::string _invokeId;
+ Interpreter* _invokedInterpreter;
+
+ std::stringstream _dataStream;
+
+ float* _pos;
+ float* _listener;
+ bool _audioDevOpen;
+ int _audioDevIndex;
+ struct miles_audio_device* _audioDev;
};
-
+
}
#endif /* end of include guard: SPATIALAUDIO_H_EH11SAQC */