Skip to content

Commit

Permalink
Improve JuceOSCUI to use OSC alias when they are used instead of the …
Browse files Browse the repository at this point in the history
…path.
  • Loading branch information
sletz committed Jun 14, 2024
1 parent 4cf2398 commit d07d323
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions architecture/faust/gui/APIUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,11 @@ class APIUI : public PathBuilder, public Meta, public UI
* @param p - the UI parameter index
* @param key - the UI parameter index
*
* @return the param metadata value associate to the key
* @return the param metadata value associate to the key or nullptr if the key is not found
*/
const char* getMetadata(int p, const char* key)
{
return (fMetaData[uint(p)].find(key) != fMetaData[uint(p)].end()) ? fMetaData[uint(p)][key].c_str() : "";
return (fMetaData[uint(p)].find(key) != fMetaData[uint(p)].end()) ? fMetaData[uint(p)][key].c_str() : nullptr;
}

/**
Expand Down
13 changes: 12 additions & 1 deletion architecture/faust/gui/JuceOSCUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,18 @@ class JuceOSCUI : private juce::OSCReceiver, private juce::OSCReceiver::Listener
// Keep all zones for update when OSC messages are received
if (fOSCItems.size() == 0) {
for (int p = 0; p < fAPIUI.getParamsCount(); ++p) {
fOSCItems.add(new oscItem(&fSender, this, fAPIUI.getParamAddress(p), fAPIUI.getParamZone(p)));
// If an osc metadata is used, take it
const char* value;
if ((value = fAPIUI.getMetadata(p, "osc"))) {
std::stringstream ss(value);
std::string item;
std::vector<std::string> tokens;
while (getline(ss, item, ' ')) { tokens.push_back(item); }
// First token is the address
fOSCItems.add(new oscItem(&fSender, this, tokens[0], fAPIUI.getParamZone(p)));
} else {
fOSCItems.add(new oscItem(&fSender, this, fAPIUI.getParamAddress(p), fAPIUI.getParamZone(p)));
}
}
}

Expand Down

0 comments on commit d07d323

Please sign in to comment.