本文整理汇总了C++中ofxOscMessage类的典型用法代码示例。如果您正苦于以下问题:C++ ofxOscMessage类的具体用法?C++ ofxOscMessage怎么用?C++ ofxOscMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ofxOscMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generateMessage
void Mesh::generateMessage(ofxOscMessage& message) {
message.setAddress("/mesh/positions");
for (auto p : points) {
message.addFloatArg(p.x);
message.addFloatArg(p.y);
}
}
示例2: 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 << ".";
}
示例3: 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);
}
}
示例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: 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);
}
}
示例6: addOscMessageArg
void addOscMessageArg(ofxOscMessage& message,
const ofFloatColor& value) {
message.addFloatArg(value.r);
message.addFloatArg(value.g);
message.addFloatArg(value.b);
message.addFloatArg(value.a);
}
示例7: 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));
}
}
}
示例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: 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;
}
示例10: getDeviceParametersRange
void Ableton::getDeviceParametersRange(ofxOscMessage &m)
{
int track = m.getArgAsInt32(0);
int device = m.getArgAsInt32(1);
if (tracks.count(track) != 0 && tracks[track]->getDevices().count(device) != 0) {
tracks[track]->getDevices()[device]->getParameterRanges(m);
}
}
示例11: oscSendCenter
void oniActorApp::oscSendCenter(XnPoint3D center, string addr, ofxOscMessage &m)
{
m.setAddress(addr);
m.addFloatArg(center.X);
m.addFloatArg(center.Y);
m.addFloatArg(center.Z);
sender.sendMessage(m);
m.clear();
}
示例12: 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;
}
示例13: 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;
}
示例14: 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;
}
示例15: 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();
}