void CGridIcon::ShowPrecent(Point _point) { if(!m_pPercent && m_pItem) { m_pPercent = Text::create(); m_pPercent->setFontSize(16); m_pPercent->setColor(getNameColor(part_precent)); m_pPercent->enableOutline(getLineColor(part_precent)); m_pPercent->setPosition(Point(_customSize.width * _point.x, _customSize.height * _point.y)); addChild(m_pPercent); } if(m_pPercent && m_pItem) m_pPercent->setText(INT_TO_STRING(m_pItem->getBookPercent())); }
void CGridIcon::ShowLevel(Point _point) { if(!m_pLevel && m_pItem) { m_pLevel = Text::create(); m_pLevel->setFontSize(18); m_pLevel->setColor(getNameColor(part_level)); m_pLevel->setPosition(Point(_customSize.width * _point.x, _customSize.height * _point.y)); addChild(m_pLevel); } if(m_pLevel && m_pItem) m_pLevel->setText(INT_TO_STRING(m_pItem->getScore())); }
void Console::printFrameRate() { print(INT_TO_STRING(eagle.getCoreFrameRate()) + " fps"); }
/** @brief Translate an osrfMessage into a jsonObject. @param msg Pointer to the osrfMessage to be translated. @return Pointer to a newly created jsonObject. The resulting jsonObject is a JSON_HASH with a classname of "osrfMessage", and the following keys: - "threadTrace" - "locale" - "type" - "payload" (only for STATUS, REQUEST, and RESULT messages) The data for "payload" is also a JSON_HASH, whose structure depends on the message type: For a STATUS message, the payload's classname is msg->status_name. The keys are "status" (carrying msg->status_text) and "statusCode" (carrying the status code as a string). For a REQUEST message, the payload's classname is "osrfMethod". The keys are "method" (carrying msg->method_name) and "params" (carrying a jsonObject to pass any parameters to the method call). For a RESULT message, the payload's classname is "osrfResult". The keys are "status" (carrying msg->status_text), "statusCode" (carrying the status code as a string), and "content" (carrying a jsonObject to return any results from the method call). The calling code is responsible for freeing the returned jsonObject. */ jsonObject* osrfMessageToJSON( const osrfMessage* msg ) { jsonObject* json = jsonNewObjectType(JSON_HASH); jsonObjectSetClass(json, "osrfMessage"); jsonObject* payload; char sc[64]; osrf_clearbuf(sc, sizeof(sc)); INT_TO_STRING(msg->thread_trace); jsonObjectSetKey(json, "threadTrace", jsonNewObject(INTSTR)); if (msg->sender_locale != NULL) { jsonObjectSetKey(json, "locale", jsonNewObject(msg->sender_locale)); } else if (current_locale != NULL) { jsonObjectSetKey(json, "locale", jsonNewObject(current_locale)); } else { jsonObjectSetKey(json, "locale", jsonNewObject(default_locale)); } switch(msg->m_type) { case CONNECT: jsonObjectSetKey(json, "type", jsonNewObject("CONNECT")); break; case DISCONNECT: jsonObjectSetKey(json, "type", jsonNewObject("DISCONNECT")); break; case STATUS: jsonObjectSetKey(json, "type", jsonNewObject("STATUS")); payload = jsonNewObject(NULL); jsonObjectSetClass(payload, msg->status_name); jsonObjectSetKey(payload, "status", jsonNewObject(msg->status_text)); snprintf(sc, sizeof(sc), "%d", msg->status_code); jsonObjectSetKey(payload, "statusCode", jsonNewObject(sc)); jsonObjectSetKey(json, "payload", payload); break; case REQUEST: jsonObjectSetKey(json, "type", jsonNewObject("REQUEST")); payload = jsonNewObject(NULL); jsonObjectSetClass(payload, "osrfMethod"); jsonObjectSetKey(payload, "method", jsonNewObject(msg->method_name)); jsonObjectSetKey( payload, "params", jsonObjectDecodeClass( msg->_params ) ); jsonObjectSetKey(json, "payload", payload); break; case RESULT: jsonObjectSetKey(json, "type", jsonNewObject("RESULT")); payload = jsonNewObject(NULL); jsonObjectSetClass(payload,"osrfResult"); jsonObjectSetKey(payload, "status", jsonNewObject(msg->status_text)); snprintf(sc, sizeof(sc), "%d", msg->status_code); jsonObjectSetKey(payload, "statusCode", jsonNewObject(sc)); jsonObjectSetKey(payload, "content", jsonObjectDecodeClass( msg->_result_content )); jsonObjectSetKey(json, "payload", payload); break; } return json; }
//-------------------------------------------------------------- void testApp::setup(){ sliderArea = ofRectangle(0, 0, ofGetWindowWidth() / 2, ofGetWindowHeight()); /////////////////////////////// // Audio Stuff /////////////////////////////// // initialize ofSoundStreamSetup ofSoundStreamSetup(2, 0, this, 44100, 256, 4); const int NUM_STEPS = 8; // synth paramters are like instance variables -- they're values you can set later, by // cally synth.setParameter() ControlGenerator bpm = synth.addParameter("tempo",100).min(50).max(300); ControlGenerator transpose = synth.addParameter("transpose", 0).min(-6).max(6); // ControlMetro generates a "trigger" message at a given bpm. We multiply it by four because we // want four 16th notes for every beat ControlGenerator metro = ControlMetro().bpm(4 * bpm); // ControlStepper increments a value every time it's triggered, and then starts at the beginning again // Here, we're using it to move forward in the sequence ControlGenerator step = ControlStepper().end(NUM_STEPS).trigger(metro); // ControlSwitcher holds a list of ControlGenerators, and routes whichever one the inputIndex is pointing // to to its output. ControlSwitcher pitches = ControlSwitcher().inputIndex(step); ControlSwitcher cutoffs = ControlSwitcher().inputIndex(step); ControlSwitcher glides = ControlSwitcher().inputIndex(step); // stick a bunch of random values into the pitch and cutoff lists for(int i = 0; i < NUM_STEPS; i++){ ControlGenerator pitchForThisStep = synth.addParameter("step" + INT_TO_STRING(i) + "Pitch", randomFloat(10, 80)).min(10).max(80); pitches.addInput(pitchForThisStep); ControlGenerator cutoff = synth.addParameter("step" + INT_TO_STRING(i) + "Cutoff", 500).min(30).max(1500); cutoffs.addInput(cutoff); ControlGenerator glide = synth.addParameter("step" + INT_TO_STRING(i) + "Glide", 0).min(0).max(0.1); glides.addInput(glide); } // Define a scale according to steps in a 12-note octave. This is a pentatonic scale. Like using // just the black keys on a piano vector<float> scale; scale.push_back(0); scale.push_back(2); scale.push_back(3); scale.push_back(5); scale.push_back(7); scale.push_back(10); // ControlSnapToScale snaps a float value to the nearest scale value, no matter what octave its in ControlGenerator midiNote = transpose + ControlSnapToScale().setScale(scale).input(pitches); ControlGenerator frequencyInHertz = ControlMidiToFreq().input(midiNote); // now that we've done all that, we have a frequency signal that's changing 4x per beat Generator tone = RectWave().freq( frequencyInHertz.smoothed().length(glides) ); // create an amplitude signal with an ADSR envelope, and scale it down a little so it's not scary loud Generator amplitude = ADSR(0.01, 0.1, 0,0).trigger(metro) * 0.3; // create a filter, and feed the cutoff sequence in to it LPF24 filter = LPF24().cutoff(cutoffs).Q(0.1); filter.input(tone * amplitude); // rout the output of the filter to the synth's main output synth.setOutputGen( filter ); // build a slider for each parameter vector<ControlParameter> synthParameters = synth.getParameters(); for(int i = 0; i < synthParameters.size(); i++){ sliders.push_back(ParameterSlider(synthParameters.at(i))); } }