本文整理汇总了C++中ofxOscMessage::getArgAsFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ ofxOscMessage::getArgAsFloat方法的具体用法?C++ ofxOscMessage::getArgAsFloat怎么用?C++ ofxOscMessage::getArgAsFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofxOscMessage
的用法示例。
在下文中一共展示了ofxOscMessage::getArgAsFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleTouchPadMessage
void ofApplication::handleTouchPadMessage(ofxOscMessage &m)
{
string a = m.getAddress();
int a_len = a.length();
int r_len = string("/oF/multiPad/").length();
if (a_len > r_len)
{
string mRouteStr = a.substr(r_len, a_len-r_len);
int touchIndex = atoi(&mRouteStr.at(0));
int delim_pos = mRouteStr.find("/");
if (delim_pos != string::npos)
{
// z-message
if (mRouteStr.at(mRouteStr.length()-1) == 'z')
{
bool on = m.getArgAsFloat(0) != 0.0;
if (!on){
touchMap.erase(touchIndex);
}
}
}
else
{
// x-y are swapped in touchOSC landscape
touchMap[touchIndex] = ofVec2f(m.getArgAsFloat(1), m.getArgAsFloat(0));
}
}
}
示例2: oscReceiveProcessMessage
//----------
void OscManager::oscReceiveProcessMessage(string address, ofxOscMessage &msg) {
ParameterBase::Type type = inputTrackers[address]->getType();
if (type == ParameterBase::BOOL) {
((Parameter<bool> *) inputTrackers[address]->parameter)->set(msg.getArgAsInt32(0)==1);
}
else if (type == ParameterBase::STRING) {
((Parameter<string> *) inputTrackers[address]->parameter)->set(msg.getArgAsString(0));
}
else if (type == ParameterBase::INT) {
((Parameter<int> *) inputTrackers[address]->parameter)->set((int) msg.getArgAsFloat(0));
}
else if (type == ParameterBase::FLOAT) {
((Parameter<float> *) inputTrackers[address]->parameter)->set(msg.getArgAsFloat(0));
}
else if (type == ParameterBase::VEC2F) {
((Parameter<ofVec2f> *) inputTrackers[address]->parameter)->set(ofVec2f(msg.getArgAsFloat(0), msg.getArgAsFloat(1)));
}
else if (type == ParameterBase::VEC3F) {
((Parameter<ofVec3f> *) inputTrackers[address]->parameter)->set(ofVec3f(msg.getArgAsFloat(0), msg.getArgAsFloat(1), msg.getArgAsFloat(2)));
}
else if (type == ParameterBase::VEC4F) {
((Parameter<ofVec4f> *) inputTrackers[address]->parameter)->set(ofVec4f(msg.getArgAsFloat(0), msg.getArgAsFloat(1), msg.getArgAsFloat(2), msg.getArgAsFloat(3)));
}
}
示例3: makeMarkerFromOSC
static ofMultiTaction::Marker makeMarkerFromOSC(const ofxOscMessage &m)
{
ofMultiTaction::Marker marker;
marker.id = m.getArgAsInt32(0);
marker.code = m.getArgAsInt32(1);
marker.x = m.getArgAsFloat(2);
marker.y = m.getArgAsFloat(3);
marker.rotation = m.getArgAsFloat(3);
return marker;
}
示例4: 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);
}
}
示例5: handleOscMessage
void DelaunayVisualization::handleOscMessage(ofxOscMessage m){
string address = m.getAddress();
const string delaunayColorHS = "/showrunner/delaunay/colorhs";
const string delaunayColorB = "/showrunner/delaunay/colorb";
if(address == delaunayColorHS){
colorH=m.getArgAsFloat(0)*255;
colorS=m.getArgAsFloat(1)*255;
}else if(address == delaunayColorB){
colorB= m.getArgAsFloat(0)*255;
}
}
示例6: 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));
}
}
示例7: 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);
}
}
示例8: 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();
}
示例9: 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);
}
}
示例10: handleControlMessage
//--------------------------------------------------------------
void DonutCop::handleControlMessage(const ofxOscMessage &m) {
ofBuffer data = m.getArgAsBlob(0);
_maxSprinkles = m.getArgAsInt32(1);
_minSprinkles = m.getArgAsInt32(2);
_maxNewSprinkles = m.getArgAsInt32(3);
_maxVelocity = m.getArgAsFloat(4);
_maxAcceleration = m.getArgAsFloat(5);
// Calculate left and right IDs
int val;
int maxId = 0;
leftId = 256;
rightId = -1;
for (int i = 0; i < data.size(); ++i) {
val = (int)(data.getData()[i]);
if (val > id && val < leftId) {
leftId = val;
}
if (val < id && val > rightId) {
rightId = val;
}
if (val > maxId) {
maxId = val;
}
}
if (leftId == 256) {
leftId = 0;
}
if (rightId == -1) {
rightId = maxId;
}
ofLogVerbose() << "My left ID is " << leftId << " and my right ID is " << rightId << ".";
}
示例11: parseOSC
void AnimatedSinus::parseOSC(ofxOscMessage &m){
// string msg = m.getAddress();
// string cmd ;
//
// int ces = msg.find_first_of("/");
//
// if (ces != -1) {
// if (ces == 0){
// msg = msg.substr(ces+1);
// cmd = msg;
// ces = msg.find_first_of("/");
// if (ces != -1) {
// cmd = msg.substr(0, ces);
// msg = msg.substr(ces);
// }
// }
// else{
// cmd = msg.substr(0, ces);
// msg = msg.substr(ces);
// }
// }
vector<string> osc = getOSCcmd(m.getAddress());
string cmd = osc[0];
string msg = osc[1];
if (cmd == "sin"){
osc = getOSCcmd(msg);
string cmd = osc[0];
string msg = osc[1];
if (cmd == "freq"){
freq = ofMap(m.getArgAsFloat(0), 0., 1., 0., 500.);
}
else if (cmd == "nbPoint"){
nbPoint = m.getArgAsInt32(0);
}
else if (cmd == "speed"){
speed = ofMap(m.getArgAsFloat(0), 0., 1., 0., 50.);
}
else if (cmd == "height"){
height = m.getArgAsFloat(0);
}
else if (cmd == "posY"){
posY = ofMap(m.getArgAsFloat(0), 0., 1., -1., 1.);
}
}
}
示例12: getFromEarChannels
float ofApp::getFromEarChannels(ofxOscMessage& msg) {
float avg = 0;
avg += msg.getArgAsFloat(0);
avg += msg.getArgAsFloat(3);
avg /= 2;
return avg;
}
示例13: getFromForeheadChannels
float ofApp::getFromForeheadChannels(ofxOscMessage& msg) {
float avg = 0;
avg += msg.getArgAsFloat(1);
avg += msg.getArgAsFloat(2);
avg /= 2;
return avg;
}
示例14: makeFingerFromOSC
static ofMultiTaction::Finger makeFingerFromOSC(const ofxOscMessage &m)
{
ofMultiTaction::Finger finger;
finger.id = m.getArgAsInt32(0);
finger.x = m.getArgAsFloat(1);
finger.y = m.getArgAsFloat(2);
return finger;
}
示例15: 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;
}