本文整理汇总了C++中ofFloatPixels::setImageType方法的典型用法代码示例。如果您正苦于以下问题:C++ ofFloatPixels::setImageType方法的具体用法?C++ ofFloatPixels::setImageType怎么用?C++ ofFloatPixels::setImageType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofFloatPixels
的用法示例。
在下文中一共展示了ofFloatPixels::setImageType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void update() {
#ifdef USE_AUDIO
//Speaker sampling code
speakerFbo.begin();
renderScene(shader, speakerXyzMap, speakerConfidenceMap);
speakerFbo.end();
//Read back the fbo, and average it on the CPU
speakerFbo.readToPixels(speakerPixels);
speakerPixels.setImageType(OF_IMAGE_GRAYSCALE);
ofxOscMessage brightnessMsg;
brightnessMsg.setAddress("/audio/brightness");
float* pix = speakerPixels.getData();
for(int i = 0; i < n_speakers; i++){
float avg = 0;
for(int j = 0; j < n_samples; j++){
avg += *pix++;
}
avg /= n_samples;
brightnessMsg.addFloatArg(avg);
}
oscSender.sendMessage(brightnessMsg);
float elapsedTime = ofGetElapsedTimef();
// copied from shader --- 8< ---
float t = elapsedTime / 30.; // duration of each stage
float stage = floor(t); // index of current stage
float i = t - stage; // progress in current stage
// copied from shader --- 8< ---
if(stage != previousStage) {
ofxOscMessage msg;
msg.setAddress("/audio/scene_change_event");
msg.addIntArg(stage == 0 ? 0 : 2);
oscSender.sendMessage(msg);
}
previousStage = stage;
if(stage == 0) {
float lighthouseAngle = ofGetElapsedTimef() / TWO_PI;
lighthouseAngle += 0; // set offset here
ofxOscMessage msg;
msg.setAddress("/audio/lighthouse_angle");
msg.addFloatArg(fmodf(lighthouseAngle, 1));
oscSender.sendMessage(msg);
}
#endif
}