本文整理汇总了C++中ofxOscMessage::getNumArgs方法的典型用法代码示例。如果您正苦于以下问题:C++ ofxOscMessage::getNumArgs方法的具体用法?C++ ofxOscMessage::getNumArgs怎么用?C++ ofxOscMessage::getNumArgs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofxOscMessage
的用法示例。
在下文中一共展示了ofxOscMessage::getNumArgs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleMessage
bool tuioVisBase::handleMessage(ofxOscMessage m) {
string address = m.getAddress();
// special cases first:
if (address=="/tuio/2dcur" && m.getNumArgs()==7 && m.getArgType(0)==OFXOSC_TYPE_STRING && m.getArgAsString(0)=="set") {
tuioCursor tc;
tc.s = m.getArgAsInt32(1);
tc.x = m.getArgAsFloat(2);
tc.y = m.getArgAsFloat(3);
tc.dx = m.getArgAsFloat(4);
tc.dy = m.getArgAsFloat(5);
tc.m = m.getArgAsFloat(6);
tc.age = 0;
return cursorCallback(tc);
}
else if (address=="/tuio/2Dcur" && m.getNumArgs()==2 && m.getArgType(0)==OFXOSC_TYPE_STRING && m.getArgAsString(0)=="fseq") {
return frameCallback(m.getArgAsInt32(1));
}
else if (linearCallbacks.find(address) != linearCallbacks.end() && m.getNumArgs()==1) {
return linearCallback(address, m.getArgAsFloat(0));
}
else if (colorCallbacks.find(address) != colorCallbacks.end() && m.getNumArgs()==3) {
return colorCallback(address, m.getArgAsFloat(0), m.getArgAsFloat(1), m.getArgAsFloat(2));
}
// message not handled:
else return false;
}
示例2: setOscDebugMessage
void testApp::setOscDebugMessage(ofxOscMessage message)
{
std::stringstream stream;
stream << "OSC messages";
if (!showOscDebugPosition)
{
stream << " (Not showing position messages)";
}
stream << " :\n";
stream << "[address]: " << message.getAddress() << ", ";
for (int i = 0; i < message.getNumArgs(); ++i) {
stream << "[" << (i+1) << "]: ";
if (message.getArgType(i) == OFXOSC_TYPE_INT32) {
stream << message.getArgAsInt32(i);
}
else if (message.getArgType(i) == OFXOSC_TYPE_STRING) {
stream << message.getArgAsString(i);
}
else if (message.getArgType(i) == OFXOSC_TYPE_FLOAT) {
stream << message.getArgAsFloat(i);
}
if (i != message.getNumArgs()-1) {stream << ", ";};
}
stream << ", time: ";
stream << ofGetElapsedTimef();
m_debugMessage = stream.str();
}
示例3: fillPresetListFromMessage
void ofxRemoteUIClient::fillPresetListFromMessage(ofxOscMessage m){
int n = m.getNumArgs();
//check if server has no presets at all
if (m.getNumArgs() == 1){
if(m.getArgAsString(0) == OFXREMOTEUI_NO_PRESETS){ //if no prests, server sends only one with this value
//we know there's no presets
}
}
presetNames.clear();
for(int i = 0; i < n; i++){
presetNames.push_back( m.getArgAsString(i));
}
}
示例4: onTracksVolumeChanged
///--------------------------------------------------------------
void AbletonManager::onTracksVolumeChanged(ofxOscMessage &m)
{
/**
* Response for track volume (amplitude) changes:
* /live/track/meterblock
* N triplets with:
* (int) track number
* (int) channel (0=left, 1=right)
* (float) volume (0..1)
*/
int track, channel;
float volume;
int numArgs = m.getNumArgs();
for (int i=0; i<numArgs; i+=3)
{
track = m.getArgAsInt32(i);
channel = m.getArgAsInt32(i+1);
volume = m.getArgAsFloat(i+2);
if (channel == 1) continue; // Skip right channel messages
if (track >= sceneNumObjects) continue; // Skip if this track index is larger than the number of objects in scene
ofNotifyEvent(eventsVolumeChanged[track], volume, this);
}
}
示例5: onClipPlayingPositionChanged
///--------------------------------------------------------------
void AbletonManager::onClipPlayingPositionChanged(ofxOscMessage &m)
{
/**
* Response for clip position changes:
* /clip/playing_position
* N triplets with:
* (int) track
* (int) clip
* (float) track position (0..1)
*/
int track;
float position;
int numArgs = m.getNumArgs();
for (int i=0; i<numArgs; i+=3)
{
track = m.getArgAsInt32(i);
// clip = m.getArgAsInt32(i+1);
position = m.getArgAsFloat(i+2);
if (track >= sceneNumObjects) continue;
ofNotifyEvent(eventsClipPositionChanged[track], position, this);
}
}
示例6: getDeviceList
void Ableton::getDeviceList(ofxOscMessage &m)
{
int numArgs = m.getNumArgs();
int track = m.getArgAsInt32(0);
if (tracks.count(track) == 0)
{
AbletonTrack *newTrack = new AbletonTrack("track "+ofToString(track), track, numScenes, &sender);
tracks[track] = newTrack;
newTrack->getControl()->setCollapsible(true);
if (track == 0) {
control.attachWidget(newTrack->getControl());
}
else {
tracks[track-1]->getControl()->attachWidget(newTrack->getControl());
}
}
for (int i = 1; i < numArgs; i+=2)
{
int device = m.getArgAsInt32(i);
string name = m.getArgAsString(i+1);
if (tracks[track]->getDevices().count(device) == 0)
{
AbletonDevice *newDevice = new AbletonDevice(name, track, device, &sender);
tracks[track]->addDevice(device, newDevice);
}
requestDeviceParameters(track, device);
requestDeviceParametersRange(track, device);
}
}
示例7: messageToCommandArgs
static CommandArgs messageToCommandArgs(const ofxOscMessage& message) {
CommandArgs args;
for (int i = 0; i < message.getNumArgs(); ++i) {
auto arg = messageArgToCommandArg(message, i);
args.add(arg);
}
return args;
}
示例8:
//--------------------------------------------------------------
void ofApp::getMessage22(ofxOscMessage m){
int msgnum;
msgnum = m.getNumArgs();
if(msgnum==2){
velx_ave = m.getArgAsInt32(0);
vely_ave = m.getArgAsInt32(1);
}
}
示例9: matchTypes
// are this two objects compatible?
bool OscController::matchTypes(string controlName, ofxOscMessage message) {
ofAbstractParameter& p = controls[controlName]->getParameter();
// vezer can send these types of messages:
// float, int, bool, color and... string?
if(message.getNumArgs() == 3){
if(p.type() == typeid(ofParameter<ofColor>).name()
&& message.getArgType(0) == OFXOSC_TYPE_INT32){
return true;
}
else if(p.type() == typeid(ofParameter<ofFloatColor>).name()
&& message.getArgType(0) == OFXOSC_TYPE_FLOAT){
return true;
}
}
else if(message.getNumArgs() == 1){
if(p.type() == typeid(ofParameter<int>).name()
&& message.getArgType(0) == OFXOSC_TYPE_INT32){
return true;
}
else if(p.type() == typeid(ofParameter<float>).name()
&& message.getArgType(0) == OFXOSC_TYPE_FLOAT){
return true;
}
else if(p.type() == typeid(ofParameter<bool>).name()
&& message.getArgType(0) == OFXOSC_TYPE_INT32){
return true;
}
////////////////////////////////////////////////////////////////
// testing:
// floats will be converted to bool if parameter type is bool
else if(p.type() == typeid(ofParameter<bool>).name()
&& message.getArgType(0) == OFXOSC_TYPE_FLOAT){
return true;
}
// floats will be converted to ints if parameter type is int
else if(p.type() == typeid(ofParameter<int>).name()
&& message.getArgType(0) == OFXOSC_TYPE_FLOAT){
return true;
}
////////////////////////////////////////////////////////////////
}
return false;
}
示例10: parseInfoMessage
void ofxDuration::parseInfoMessage(const ofxOscMessage& m){
ofLogVerbose("ofxDuration::parseInfoMessage") << "Received track information from Duration, #args " << m.getNumArgs();
tracks.clear();
trackNames.clear();
//pairs of two strings per track, name and type
for(int i = 0; i < m.getNumArgs()-1; i+=2){
if(m.getArgType(i ) == OFXOSC_TYPE_STRING &&
m.getArgType(i+1) == OFXOSC_TYPE_STRING)
{
string trackType = m.getArgAsString(i );
string trackName = m.getArgAsString(i+1);
ofxDurationTrack t;
t.type = trackType;
t.name = trackName;
t.lastUpdatedTime = ofGetElapsedTimef();
ofLogVerbose("ofxDuration::parseInfoMessage") << "Adding track " << t.type << " : " << t.name;
if(trackType == "Curves" || trackType == "LFO"){
//consume two more args for min and max
if(i+3 < m.getNumArgs() &&
m.getArgType(i+2) == OFXOSC_TYPE_FLOAT &&
m.getArgType(i+3) == OFXOSC_TYPE_FLOAT)
{
t.range = ofRange(m.getArgAsFloat(i+2), m.getArgAsFloat(i+3));
ofLogVerbose("ofxDuration::parseInfoMessage") << " track range is " << t.range;
i+=2;
}
}
//only add unique names
if(tracks.find(t.name) == tracks.end()){
trackNames.push_back(t.name);
tracks[t.name] = t;
}
else{
ofLogNotice("ofxDuration::parseInfoMessage") << "Duplicate track name received: " << t.name;
}
}
}
ofLogVerbose("ofxDuration::parseInfoMessage") << "Created " << tracks.size() << " tracks";
}
示例11: getAverageFromChannels
//--------------------------------------------------------------
float ofApp::getAverageFromChannels(ofxOscMessage& msg) {
float avg = 0;
int channels = msg.getNumArgs();
for(int i = 0; i < channels; i++) {
avg += msg.getArgAsFloat(i);
}
avg /= channels;
return avg;
}
示例12: getHighestFromChannels
float ofApp::getHighestFromChannels(ofxOscMessage& msg) {
float highest = 0;
int channels = msg.getNumArgs();
for(int i = 0; i < channels; i++) {
float channelValue = msg.getArgAsFloat(i);
if(channelValue > highest) highest = channelValue;
}
return highest;
}
示例13: getOscMessageValue
ofVec3f getOscMessageValue(const ofxOscMessage& message) {
auto size = message.getNumArgs();
if (size == 3) {
return ofVec3f(message.getArgAsFloat(0),
message.getArgAsFloat(1),
message.getArgAsFloat(2));
} else {
logInvalidSize(message);
return ofVec3f(0);
}
}
示例14: parseMessage
void AbletonGui::parseMessage(ofxOscMessage & msg)
{
string address = msg.getAddress();
if (address == addressRoot) {
for (int idx = 0; idx < min((int)sliders.size(), msg.getNumArgs()); idx++) {
sliders[idx]->setValue(msg.getArgAsFloat(idx));
}
}
else if (activeAddresses.count(address) >0) {
activeAddresses[address]->setValue(msg.getArgAsFloat(0));
}
}
示例15: dumpOSC
string messenger::dumpOSC(ofxOscMessage m) {
string msg_string;
msg_string = m.getAddress();
for (int i=0; i<m.getNumArgs(); i++ ) {
msg_string += " ";
if(m.getArgType(i) == OFXOSC_TYPE_INT32)
msg_string += ofToString( m.getArgAsInt32(i));
else if(m.getArgType(i) == OFXOSC_TYPE_FLOAT)
msg_string += ofToString( m.getArgAsFloat(i));
else if(m.getArgType(i) == OFXOSC_TYPE_STRING)
msg_string += m.getArgAsString(i);
}
return msg_string;
}