Skip to content

Commit

Permalink
mec osc, add x/y offset to allow for unipolar output
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechnobear committed Apr 15, 2019
1 parent 126774a commit 6c45915
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 8 additions & 5 deletions mec-app/mecapi_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ class MecOSCCallback : public MecCmdCallback {
: prefs_(p),
transmitSocket_(IpEndpointName(p.getString("host", "127.0.0.1").c_str(), p.getInt("port", 3123))),
valid_(true),
touchOffset_(p.getInt("touch offset",1))
touchOffset_(p.getInt("touch offset",1)),
xOffset_(p.getDouble("x offset",0.5f)),
yOffset_(p.getDouble("y offset",0.5f))
{
if (valid_) {
LOG_0("mecapi_proc enabling for osc");
Expand All @@ -128,18 +130,17 @@ class MecOSCCallback : public MecCmdCallback {

void touchOn(int touchId, float note, float x, float y, float z) {
std::string topic = "/t3d/tch" + std::to_string(touchId+touchOffset_);
sendMsg(topic, touchId, note, x, y, z);
sendMsg(topic, touchId, note, x+xOffset_, y +yOffset_, z);
}

void touchContinue(int touchId, float note, float x, float y, float z) {
std::string topic = "/t3d/tch" + std::to_string(touchId+touchOffset_);
sendMsg(topic, touchId, note, x, y, z);
sendMsg(topic, touchId, note, x+xOffset_, y +yOffset_, z);
}

void touchOff(int touchId, float note, float x, float y, float z) {
std::string topic = "/t3d/tch" + std::to_string(touchId+touchOffset_);
sendMsg(topic, touchId, note, x, y, 0);

sendMsg(topic, touchId, note, x+xOffset_, y +yOffset_, z);
}

void control(int ctrlId, float v) {
Expand Down Expand Up @@ -168,6 +169,8 @@ class MecOSCCallback : public MecCmdCallback {
char buffer_[OUTPUT_BUFFER_SIZE];
bool valid_;
unsigned touchOffset_;
float yOffset_;
float xOffset_;
};

class MecMidiProcessor : public mec::Midi_Processor {
Expand Down
4 changes: 3 additions & 1 deletion resources/picoosc.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
"osc" : {
"host" : "127.0.0.1",
"port" : 3123,
"touch offset" : 1
"touch offset" : 1,
"x offset" : 0.5,
"y offset" : 0.5
},
"_console" : {
"throttle" : 0
Expand Down

0 comments on commit 6c45915

Please sign in to comment.