void processAudio(AudioBuffer &buffer) { int size = buffer.getSize(); float y; rate = Rate(getParameterValue(PARAMETER_A)); depth = getParameterValue(PARAMETER_B); feedback = getParameterValue(PARAMETER_C); //calculate and update phaser sweep lfo... float d = _dmin + (_dmax-_dmin) * ((sin( _lfoPhase ) + 1.f)/2.f); _lfoPhase += rate; if( _lfoPhase >= M_PI * 2.f ) _lfoPhase -= M_PI * 2.f; //update filter coeffs for( int i=0; i<6; i++ ) _alps[i].Delay( d ); // for (int ch = 0; ch<buffer.getChannels(); ++ch) { float* buf = buffer.getSamples(0); for (int i = 0; i < size; i++) { //calculate output y = _alps[0].Update(_alps[1].Update(_alps[2].Update(_alps[3].Update(_alps[4].Update( _alps[5].Update( buf[i] + _zm1 * feedback )))))); _zm1 = y; buf[i] = buf[i] + y * depth; // } } }
Imu::Imu(ConfigFileWrapper& configFileWrapper) :_configFileWrapper(configFileWrapper) { _rate = Rate(); _angle = Angle(); _velocity = Velocity(); _accelZeroPitch = _configFileWrapper.getAccelZeroPitch(); _accelZeroRoll = _configFileWrapper.getAccelZeroRoll(); Thread::wait(500); _freeImu.init(true); Thread::wait(500); _barometerZeroFilter = new filter(100); _barometerFilter = new filter(50); _barometerZero = 0; zeroBarometer(); _kalmanXVelFilter = new Kalman(0.1, 32, 1, 0); _kalmanYVelFilter = new Kalman(0.1, 32, 1, 0); _kalmanZVelFilter = new Kalman(0.1, 32, 1, 0); DEBUG("IMU initialised\r\n"); }
//initialise to some usefull defaults... PhaserPatch() : _lfoPhase( 0.f ), depth( 1.f ), feedback( .7f ), _zm1( 0.f ){ registerParameter(PARAMETER_A, "Rate"); registerParameter(PARAMETER_B, "Depth"); registerParameter(PARAMETER_C, "Feedback"); registerParameter(PARAMETER_D, ""); Range( 440.f, 1600.f ); Rate( .5f ); }
Phaser::Phaser() : _fb( .7f ) , _lfoPhase( 0.f ) , _depth( 1.f ) , _zm1( 0.f ) , _SampleRate(CPresets::Presets.SampleRate) , _pi(DoublePi) { Range( 440.f, 1600.f ); Rate( .5f ); }
BasicTaker::Rate BasicTaker::effective_rate ( std::uint32_t rate, Issue const &issue, AccountID const& from, AccountID const& to) { assert (rate != 0); if (rate != QUALITY_ONE) { // We ignore the transfer if the sender is also the recipient since no // actual transfer takes place in that case. We also ignore if either // the sender or the receiver is the issuer. if (from != to && from != issue.account && to != issue.account) return Rate (rate); } return Rate (QUALITY_ONE); }
CyberglovePublisher::CyberglovePublisher() : n_tilde("~"), publish_rate(0.0), path_to_glove("/dev/ttyS0"), publishing(true) { // set publish frequency double publish_freq; n_tilde.param("publish_frequency", publish_freq, 20.0); publish_rate = Rate(publish_freq); // set path to glove n_tilde.param("path_to_glove", path_to_glove, std::string("/dev/ttyS0")); ROS_INFO("Opening glove on port: %s", path_to_glove.c_str()); int error = setup_glove( path_to_glove.c_str() ); //sleep 1s to be sure the glove had enough time to start sleep(1); if( error != 0 ) ROS_ERROR("Couldn't initialize the glove, is the glove plugged in?"); else { std::string prefix; std::string searched_param; //publishes raw JointState messages n_tilde.searchParam("cyberglove_prefix", searched_param); n_tilde.param(searched_param, prefix, std::string()); std::string full_topic = prefix + "/raw/joint_states"; cyberglove_raw_pub = n_tilde.advertise<sensor_msgs::JointState>(full_topic, 2); } //initialises joint names (the order is important) jointstate_raw_msg.name.push_back("G_ThumbRotate"); jointstate_raw_msg.name.push_back("G_ThumbMPJ"); jointstate_raw_msg.name.push_back("G_ThumbIJ"); jointstate_raw_msg.name.push_back("G_ThumbAb"); jointstate_raw_msg.name.push_back("G_IndexMPJ"); jointstate_raw_msg.name.push_back("G_IndexPIJ"); jointstate_raw_msg.name.push_back("G_IndexDIJ"); jointstate_raw_msg.name.push_back("G_MiddleMPJ"); jointstate_raw_msg.name.push_back("G_MiddlePIJ"); jointstate_raw_msg.name.push_back("G_MiddleDIJ"); jointstate_raw_msg.name.push_back("G_MiddleIndexAb"); jointstate_raw_msg.name.push_back("G_RingMPJ"); jointstate_raw_msg.name.push_back("G_RingPIJ"); jointstate_raw_msg.name.push_back("G_RingDIJ"); jointstate_raw_msg.name.push_back("G_RingMiddleAb"); jointstate_raw_msg.name.push_back("G_PinkieMPJ"); jointstate_raw_msg.name.push_back("G_PinkiePIJ"); jointstate_raw_msg.name.push_back("G_PinkieDIJ"); jointstate_raw_msg.name.push_back("G_PinkieRingAb"); jointstate_raw_msg.name.push_back("G_PalmArch"); jointstate_raw_msg.name.push_back("G_WristPitch"); jointstate_raw_msg.name.push_back("G_WristYaw"); }
LpfDelayPhaserPatch() : x1(0.0f), x2(0.0f), y1(0.0f), y2(0.0f), _lfoPhase( 0.f ), depth( 1.f ), feedback( .7f ),_zm1( 0.f ) { registerParameter(PARAMETER_A, "Delay"); registerParameter(PARAMETER_B, "Feedback"); registerParameter(PARAMETER_C, "Fc"); registerParameter(PARAMETER_D, "Dry/Wet"); setCoeffs(getLpFreq()/getSampleRate(), 0.6f) ; Range( 440.f, 1600.f ); Rate( .5f ); outBuf = new float[getBlockSize()]; }
void MPINode<Weight, NodeDistribution>::reportAll( report::ReportType type) const { std::vector<report::ReportValue> vec_values; if (type == report::RATE || type == report::STATE) { report::Report report(_pAlgorithm->getCurrentTime(), Rate(this->getActivity()), this->_nodeId, _pAlgorithm->getGrid(), type, vec_values, _rLocalNodes.size()); _pHandler->writeReport(report); } }
int Paint(HDC &hdc, int width, int height) { int x[BN], y[BN]; bool stop = false; int n = 0; while (stop == false) { if (GetAsyncKeyState(VK_ESCAPE)) { _getch(); stop = true; } // Cоздаем контекст HDC hmemDC = CreateCompatibleDC(hdc); // Cоздаем битмап HBITMAP hbmpTarget = CreateCompatibleBitmap(hdc, width, height); // Выбираем битмап в контекст ::SelectObject(hmemDC, hbmpTarget); //Записывает наш bmb в память BitBlt(hmemDC, 0, 0, width, height, hdc, 0, 0, SRCCOPY); for (int i = 0; i<BN; i++) { x[i] = rand() % width; y[i] = rand() % height; if (GetPixel(hmemDC, x[i], y[i]) == RGB(0, 0, 0)) { SetPixel(hdc, x[i], y[i], RGB(randColor(), randColor(), randColor())); n++; } else { SetPixel(hdc, x[i], y[i], RGB(0, 0, 0)); n--; } } PText(hdc, Rate(n, width, height)); DeleteDC(hmemDC); // контекст отжирает уйму ресурсов, поэтому не забудем его грохнуть DeleteObject(hbmpTarget); hmemDC = NULL; Sleep(12); } return n; };
int main() { //hwnd - дескриптор окна, в котором будем рисовать HWND hwnd = GetConsoleWindow();//получение консольного окна //hdc - дескриптор контекста устройства HDC hdc = GetDC(hwnd); //получаем дискриптор,свзянный с окном, в котором будем рисовать if (hdc) { int width = 800, height = 500; int n = Paint(hdc, width, height);//вызываем функцию рисования звезд double count = Rate(n, width, height);// количество звезд PText(hdc, count); ReleaseDC(hwnd, hdc); //освобождаем контекст } _getch(); return 0; }
void main(void){ printf("\n【复利计算程序】\n"); int m; printf("\n复利计算按 1\n单利计算按 2\n计算筹集的养老金按 3\n计算时间按 4\n计算您要的利率按 5\n计算本利和投资按 6\n\n"); do { scanf("%d",&m); if(m == 1) { principal(); } if(m == 2) { SimpleInterest(); } if(m == 3) { FutureMoney(); } if(m == 4) { Time(); } if(m == 5) { Rate(); } if(m == 6) { Manytimes(); } } while( m == 0); }
Emission_Rate::Emission_Rate (int id) : Class_Index (id) { Rate (0.0); Weight (0.0); }
AnimationTransitPtr setupAnimation(ChunkMaterial* const TheBoxMaterial) { std::vector<BoostPath> _ImagePaths; _ImagePaths.push_back(BoostPath("./Data/Anim001.jpg")); _ImagePaths.push_back(BoostPath("./Data/Anim002.jpg")); _ImagePaths.push_back(BoostPath("./Data/Anim003.jpg")); _ImagePaths.push_back(BoostPath("./Data/Anim004.jpg")); _ImagePaths.push_back(BoostPath("./Data/Anim005.jpg")); TextureSelectChunkRefPtr AnimSequenceTexture = TextureSelectChunk::create(); AnimSequenceTexture->setChoice(0); //Make the textures for(UInt32 i(0) ; i<_ImagePaths.size(); ++i) { ImageRefPtr AnimFrameImage = ImageFileHandler::the()->read(_ImagePaths[i].string().c_str()); TextureObjChunkRefPtr AnimFrameTexture = TextureObjChunk::create(); AnimFrameTexture->setImage(AnimFrameImage); AnimSequenceTexture->pushToTextures(AnimFrameTexture); } //Box Material MaterialChunkUnrecPtr TheMaterialChunk = MaterialChunk::create(); TheMaterialChunk->setAmbient(Color4f(0.4,0.4,0.4,1.0)); TheMaterialChunk->setDiffuse(Color4f(0.8,0.8,0.8,1.0)); TheMaterialChunk->setSpecular(Color4f(1.0,1.0,1.0,1.0)); //Texture Env Chunk TextureEnvChunkRefPtr TexEnv = TextureEnvChunk::create(); TexEnv->setEnvMode(GL_MODULATE); TheBoxMaterial->addChunk(AnimSequenceTexture); TheBoxMaterial->addChunk(TexEnv); TheBoxMaterial->addChunk(TheMaterialChunk); //Texture Keyframe Sequence KeyframeNumberSequenceUInt32RefPtr FrameChoiceKeyframes = KeyframeNumberSequenceUInt32::create(); Real32 Rate(0.05f); for(UInt32 i(0) ; i<AnimSequenceTexture->getMFTextures()->size(); ++i) { FrameChoiceKeyframes->addRawKeyframe(i,static_cast<Real32>(i)*Rate); } for(UInt32 i(0) ; i<AnimSequenceTexture->getMFTextures()->size(); ++i) { FrameChoiceKeyframes->addRawKeyframe(AnimSequenceTexture->getMFTextures()->size()-i-1, static_cast<Real32>(i+AnimSequenceTexture->getMFTextures()->size())*Rate); } //Animator KeyframeAnimatorUnrecPtr TutorialTextureAnimator = KeyframeAnimator::create(); TutorialTextureAnimator->setKeyframeSequence(FrameChoiceKeyframes); //Animation FieldAnimationUnrecPtr TutorialTextureAnimation = FieldAnimation::create(); TutorialTextureAnimation->setAnimator(TutorialTextureAnimator); TutorialTextureAnimation->setInterpolationType(Animator::STEP_INTERPOLATION); TutorialTextureAnimation->setCycling(-1); TutorialTextureAnimation->setAnimatedField(AnimSequenceTexture,TextureSelectChunk::ChoiceFieldId); return AnimationTransitPtr(TutorialTextureAnimation); }
//----------------------------------------------------------------------------- void TestCommandHandle::Execute() { if (!engine) { Output() << "Engine not set for 'test' command"; return; } if (fileName.empty()) { Output() << "FileName not set for 'test' command"; return; } char fen[16384]; int depth = 0; int line = 0; int maxSearchDepth = 0; int maxSeldepth = 0; int minSearchDepth = -1; int minSeldepth = -1; int passed = 0; int positions = 0; int seldepth = 0; int tested = 0; int totalDepth = 0; int totalSeldepth = 0; uint64_t nodes = 0; uint64_t qnodes = 0; uint64_t time = 0; uint64_t totalNodes = 0; uint64_t totalQnodes = 0; uint64_t totalTime = 0; FILE* fp = NULL; try { MoveFinder moveFinder; if (!(fp = fopen(fileName.c_str(), "r"))) { Output() << "Cannot open '" << fileName << "': " << strerror(errno); return; } engine->ClearStopFlags(); engine->ResetStatsTotals(); while (fgets(fen, sizeof(fen), fp)) { line++; char* f = fen; if (!*NextWord(f) || (*f == '#')) { continue; } positions++; if (skipCount && (positions <= skipCount)) { continue; } Output() << "--- Test " << (++tested) << " at line " << line << ' ' << f; NormalizeString(f); const char* next = engine->SetPosition(f); if (!next || !moveFinder.LoadFEN(f)) { break; } f += (next - f); // consume 'am' and 'bm' parameters std::set<std::string> avoid; std::set<std::string> best; while (f && *NextWord(f)) { // null terminate this parameter (parameters end with ; or end of line) char* end = strchr(f, ';'); if (end) { *end = 0; } if (!strncmp(f, "am ", 3)) { f += 3; while (*NextWord(f)) { std::string coord = moveFinder.ToCoordinates(f); if (coord.size()) { avoid.insert(coord); } else { break; } } } else if (!strncmp(f, "bm ", 3)) { f += 3; while (*NextWord(f)) { std::string coord = moveFinder.ToCoordinates(f); if (coord.size()) { best.insert(coord); } else { break; } } } // move 'f' to beginning of next parameter if (end) { f = (end + 1); continue; } break; } if (avoid.empty() && best.empty()) { Output() << "error at line " << line << ", no best or avoid moves specified"; break; } if (!noClear) { engine->ClearSearchData(); } if (printBoard) { engine->PrintBoard(); } const std::string bestmove = engine->Go(maxDepth, 0, maxTime); Output(Output::NoPrefix) << "bestmove " << bestmove; engine->GetStats(&depth, &seldepth, &nodes, &qnodes, &time); if (bestmove.empty() || (best.size() && !best.count(bestmove)) || (avoid.size() && avoid.count(bestmove))) { Output() << "--- FAILED! line " << line << " (" << Percent(passed, tested) << "%) " << f; } else { passed++; Output() << "--- Passed. line " << line << " (" << Percent(passed, tested) << "%) " << f; } if (depth > maxSearchDepth) { maxSearchDepth = depth; } if ((minSearchDepth < 0) || (depth < minSearchDepth)) { minSearchDepth = depth; } if (seldepth > maxSeldepth) { maxSeldepth = seldepth; } if ((minSeldepth < 0) || (seldepth < minSeldepth)) { minSeldepth = seldepth; } totalDepth += depth; totalNodes += nodes; totalQnodes += qnodes; totalSeldepth += seldepth; totalTime += time; if (engine->StopRequested() || (maxCount && (tested >= maxCount))) { break; } } Output() << "--- Completed " << tested << " test positions"; Output() << "--- Passed " << passed << " passed (" << Percent(passed, tested) << "%)"; Output() << "--- Time " << totalTime << " (" << Average(totalTime, static_cast<uint64_t>(tested)) << " avg)"; Output() << "--- Nodes " << totalNodes << ", " << Rate((totalNodes / 1000), totalTime) << " KNodes/sec"; Output() << "--- QNodes " << totalQnodes << " (" << Percent(totalQnodes, totalNodes) << "%)"; Output() << "--- Depth " << minSearchDepth << " min, " << static_cast<int>(Average(totalDepth, tested)) << " avg, " << maxSearchDepth << " max"; Output() << "--- SelDepth " << minSeldepth << " min, " << static_cast<int>(Average(totalSeldepth, tested)) << " avg, " << maxSeldepth << " max"; engine->ShowStatsTotals(); } catch (const std::exception& e) { Output() << "ERROR: " << e.what(); } catch (...) { Output() << "Unknown error!"; } if (fp) { fclose(fp); fp = NULL; } }
//----------------------------------------------------------------------------- void PerftCommandHandle::Execute() { if (!engine) { Output() << "Engine not set for '" << command << "' command"; return; } engine->ClearStopFlags(); if (fileName.empty()) { if (qperft) { engine->QPerft(maxDepth); } else { engine->Perft(maxDepth); } return; } FILE* fp = NULL; try { if (!(fp = fopen(fileName.c_str(), "r"))) { Output() << "Cannot open '" << fileName << "': " << strerror(errno); return; } const uint64_t start = Now(); uint64_t pcount = 0; uint64_t nodes = 0; uint64_t qnodes = 0; bool done = false; char fen[16384]; int positions = 0; for (int line = 1; !done && fgets(fen, sizeof(fen), fp); ++line) { char* f = fen; if (!*NextWord(f) || (*f == '#')) { continue; } positions++; if ((skip > 0) && (positions <= skip)) { continue; } Output() << fileName << " line " << line << ' ' << f; NormalizeString(f); if (!(f = const_cast<char*>(engine->SetPosition(f)))) { break; } while (f && *f) { // null terminate this parameter (parameters end with ; or end of line) char* end = strchr(f, ';'); if (end) { *end = 0; } // process "D<depth> <leafs>" parameters (e.g. D5 4865609) if ((*NextWord(f) == 'D') && isdigit(f[1])) { if (!Process(f, pcount, nodes, qnodes)) { done = true; break; } } // move 'f' to beginning of next parameter if (end) { f = (end + 1); continue; } break; } if ((count > 0) && (positions >= count)) { break; } } const uint64_t time = (Now() - start); if (qperft) { Output() << "Total QPerft " << pcount << ' ' << Rate((pcount / 1000), time) << " KNodes/sec"; Output() << "Total Snodes " << (nodes - qnodes) << ", Qnodes " << qnodes << " (" << Percent(qnodes, pcount) << "%)"; } else { Output() << "Total Perft " << pcount << ' ' << Rate((pcount / 1000), time) << " KLeafs/sec"; Output() << "Total Nodes " << nodes << ' ' << Rate((nodes / 1000), time) << " KNodes/sec"; } } catch (const std::exception& e) { Output() << "ERROR: " << e.what(); } catch (...) { Output() << "Unknown error!"; } if (fp) { fclose(fp); fp = NULL; } }
double* ram_systemSAN::device_sefiActivity::ReturnDistributionParameters(){ TheDistributionParameters[0] = Rate(); return TheDistributionParameters; }
double* ram_systemSAN::word_sefiActivity_case2::ReturnDistributionParameters(){ TheDistributionParameters[0] = Rate(); return TheDistributionParameters; }
double ram_systemSAN::word_sefiActivity_case2::SampleDistribution(){ return TheDistribution->Exponential(Rate()); }
double* ram_systemSAN::seuActivity_case1::ReturnDistributionParameters(){ TheDistributionParameters[0] = Rate(); return TheDistributionParameters; }
double* ram_systemSAN::random_failureActivity::ReturnDistributionParameters(){ TheDistributionParameters[0] = Rate(); return TheDistributionParameters; }
bool aimbot::Think(CUserCmd* cmd) { float best = std::numeric_limits<float>::quiet_NaN(); if (css()) { if (!GetMaterialParameters) GetMaterialParameters = (void (__cdecl*)(int, float&, float&))util::FindPattern("client", "\x55\x8B\xEC\x8B\x45\x08\x83\xC0\xBD"); if (!GetBulletTypeParameters) GetBulletTypeParameters = (void (__stdcall*)(int, float&, float&))util::FindPattern("client", "\x55\x8B\xEC\x56\x8B\x75\x08\x68????\x56\xE8????\x83\xC4\x08\x84\xC0" ); } if (!bf) bf = new BulletFilter(); target_id = 0; bf->hSelf = lp; Vector sp = lp->GetShootPos(); Vector tp = Vector(); CBaseEntity* w = lp->GetActiveWeapon(); if (gmod() && MENU_SPAWPROT == 3 && ALPHA(lp->GetMDLColor()) == 200) return 0; int lteam = lp->GetTeam(); int maxcl = (MENU_NPCAIMBT ? ents->GetHighestEntityIndex() : globals->max_clients); for (int i = 1; i <= maxcl; ++i) if (CBaseEntity* pl = ents->GetClientEntity(i)) { if (pl == lp) continue; //if (pl->IsDormant()) // continue; if (!pl->GetModel()) continue; bool npc = i > globals->max_clients; bool lowp = 1; if (npc) { const char* cclass = pl->GetClientClass()->m_pNetworkName; if (gmod()) { RecvTable* p = pl->GetClientClass()->m_pRecvTable->m_pProps[0].m_pDataTable; if ((strcmp(cclass, "CAI_BaseNPC") && (!p || strcmp(p->m_pNetTableName, "DT_AI_BaseNPC"))) || !pl->IsAlive()) continue; } if (tf2()) { if ( lowp = ( strcmp(cclass, "CObjectSentrygun") || ReadPtr<bool>(pl, m_bHasSapper) ) && ( strcmp(cclass, "CTFGrenadePipebombProjectile") || !ReadPtr<int>(pl, m_iType) || !ReadPtr<bool>(pl, m_bTouched) || !pl->IsDummyProjectile() || sp.DistTo(lp->GetAbsOrigin()) > 768.f ) ) continue; if (pl->GetTeam() == lteam) continue; } } else if (!DoStateCheck(pl)) continue; if (!pl->UpdateBones()) continue; float rate = Rate(lp, pl, npc); if (!lowp) rate *= 0.1f; if (rate > best) continue; if (css() && pl->GetOrigin().DistTo(sp) > 8192.f) continue; int aim = GetAimBone(pl); bool doscan = 1; if (pl->GetHitbox(aim)) { Vector box = pl->GetBoxPos(aim); if (BulletTrace(sp, box, pl)) { target_id = i; best = rate; tp = box; continue; } } if (doscan && MENU_BONESCAN) { int m = pl->Hitboxes(); for (int j = 0; j < m; ++j) { if (j == aim) continue; if (pl->GetHitbox(j)) { Vector box = pl->GetBoxPos(j); if (BulletTrace(sp, box, pl)) { target_id = i; best = rate; tp = box; continue; } } } } } if (target_id > 0) { CBaseEntity* pl = ents->GetClientEntity(target_id); if (!pl) return 0; if (target_id > globals->max_clients) // TODO: predict non-lag comepnsated stuff { tp -= pl->GetAbsOrigin(); tp += pl->GetOrigin() + pl->GetVelocity() * engine->GetNetChannel()->GetPing(); } cmd->viewangles = (tp - sp).Angle(); NormalizeAngles(cmd->viewangles); if (MENU_AUTOSHOT) add(cmd->buttons, IN_ATTACK); return 1; } return 0; }
Rate getRate() { I2C::read(DS_ADDRESS, 7, 1); uint8_t control = I2C::receive(); return Rate(control & 0x3); }