MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / oscMessageReceived

Method oscMessageReceived

Source/OscController.cpp:118–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118void OscController::oscMessageReceived(const juce::OSCMessage& msg)
119{
120 std::string address = msg.getAddressPattern().toString().toStdString();
121
122 if (address == "/jockey/sync") //support for handshake with Jockey OSC app
123 {
124 std::string outputAddress = msg[0].getString().toStdString();
125 std::vector<std::string> tokens = ofSplitString(outputAddress, ":");
126 if (tokens.size() == 2)
127 {
128 mOutAddress = tokens[0];
129 mOutPort = ofToInt(tokens[1]);
130 ConnectOutput();
131 }
132 return;
133 }
134
135 if (msg.size() == 0)
136 return; // Code beyond this point expects at least one parameter.
137
138 if (address.rfind("/bespoke/console", 0) == 0)
139 {
140 if (msg[0].isString())
141 TheSynth->OnConsoleInput(msg[0].getString().toStdString());
142 return;
143 }
144
145 bool is_percentage = false;
146 std::string control_prefix = "/bespoke/control/";
147 std::string control_scaled_prefix = "/bespoke/control_scaled/";
148 if (address.rfind(control_prefix, 0) == 0 || address.rfind(control_scaled_prefix, 0) == 0)
149 {
150 std::string control_path;
151 if (address.rfind(control_prefix, 0) == 0)
152 {
153 control_path = address.substr(control_prefix.length());
154 }
155 else if (address.rfind(control_scaled_prefix, 0) == 0)
156 {
157 is_percentage = true;
158 control_path = address.substr(control_scaled_prefix.length());
159 }
160 control_path = juce::URL::removeEscapeChars(control_path).toStdString();
161
162 IUIControl* control = control = TheSynth->FindUIControl(control_path);
163 if (control != nullptr)
164 {
165 if (msg[0].isFloat32() || msg[0].isInt32())
166 {
167 float new_value = msg[0].isFloat32() ? msg[0].getFloat32() : msg[0].getInt32();
168 DropdownList* dropdown = dynamic_cast<DropdownList*>(control);
169 if (is_percentage)
170 control->SetFromMidiCC(new_value, gTime, false);
171 else if (dropdown)
172 dropdown->SetIndex(new_value, gTime, true);
173 else
174 control->SetValue(new_value, gTime);
175 }

Callers

nothing calls this directly

Calls 15

ofSplitStringFunction · 0.85
ofToIntFunction · 0.85
ofClampFunction · 0.85
ofGetWidthFunction · 0.85
ofGetHeightFunction · 0.85
ofVec2fClass · 0.85
sizeMethod · 0.80
OnConsoleInputMethod · 0.80
lengthMethod · 0.80
LogEventMethod · 0.80
SetMinimizedMethod · 0.80
MinimizedMethod · 0.80

Tested by

no test coverage detected