-
Notifications
You must be signed in to change notification settings - Fork 1
GetStarted
Either:
- download the torpedo.cpp and torpedo.hpp source files from github
- clone the Torpedo project to get the torpedo.cpp and torpedo.hpp files and also the demo modules
copy the torpedo.cpp and torpedo.hpp files into your plugin project.
#include the torpedo.hpp file into your module source
Create a Torpedo output port in your module and wrap it around one of your defined outputs.
Torpedo::RawOutputPort outPort = Torpedo::RawOutputPort(this, OUTPUT_TOR);
the first parameter is a reference to your module, the second parameter is the integer index to the output that you want to use.
Call the port's process method once every sample, usually in your module's step method
outPort.process();
When you want to send a message call the send method of your port
std::string appId ("DEMO");
std::string msg ("Hello World!");
outPort.send(appId, msg);
Declare a subclass of a Torpedo input port and override its received method
struct myInputPort : Torpedo::RawInputPort {
myInputPort(Module *module, unsigned int portNum):Torpedo::RawInputPort(module, portNum) {}
void received(std::string appId, std::string message) override;
};
myInputPort::received(std::string appId, std::string message) {
// Put your code here to check the appId and react to the message if you wish
}
Create an instance of your input port in your module and wrap it around one of your defined inputs.
myInputPort inPort = myInputPort(this, INPUT_TOR);
the first parameter is a reference to your module, the second parameter is the integer index to the input that you want to use.
Call the port's process method once every sample, usually in your module's step method
inPort.process();