void vfo::writeB(int freq) { QString myStr; int cnt = 0; int stgChrs; myStr.setNum(freq); stgChrs = myStr.size() -1; ui->lbl_Bhz->setText(""); // Clear the screen for VFO B ui->lbl_Bkhz->setText(""); ui->lbl_Bmhz->setText(""); for (cnt = stgChrs; cnt > -1; cnt--) { if (stgChrs - cnt < 3) ui->lbl_Bhz->setText(myStr.at(cnt)+ui->lbl_Bhz->text()); else if (stgChrs - cnt < 6) ui->lbl_Bkhz->setText(myStr.at(cnt)+ui->lbl_Bkhz->text()); else ui->lbl_Bmhz->setText(myStr.at(cnt)+ui->lbl_Bmhz->text()); } if (selectedVFO == 'B') { setBandButton(freq); } if (ptt) { if (selectedVFO != 'A') { emit setFreq(freq, ptt); qDebug() << "Using vfoB, freq = " << freq << ", ptt = " << ptt; } } else if (selectedVFO == 'B') { emit setFreq(freq, ptt); qDebug() << "Using vfoB, freq = " << freq << ", ptt = " << ptt; } }
void setSystemIO(char inData[10]) //Set a channel in PWM/ON-OFF Mode based on RX data string { int status = 0; int i = 1; int channelID = 0; while(inData[i] != 'X') { int temp = inData[i] - '0'; channelID = channelID*10 + temp; i++; if(i>6) { return; } } int j = i + 1; while(inData[j] != '\r') { int num = inData[j] - '0'; status = status*10 + num; j++; if(j>10) { return; } } switch(inData[0]) { //Call functions based in received commands case 'p' : setPWM(channelID, status); break; case 's' : switchIO(channelID, status); break; case 'f' : setFreq(channelID, status); break; default : break; } }
void TextureBuilder::createModules() { QSharedPointer<ModuleDescriptor> mod; foreach (mod,_modDesc) { auto modPtr = mod.data(); if (this->useRandomFactors() && modPtr->enableRandom() ) { modPtr->setBias(this->applyRandomFactor(modPtr->bias()) ); modPtr->setDispl(this->applyRandomFactor(modPtr->displ()) ); modPtr->setExp(this->applyRandomFactor(modPtr->exp()) ); modPtr->setFreq(this->applyRandomFactor(modPtr->freq()) ); modPtr->setLac(this->applyRandomFactor(modPtr->lac()) ); modPtr->setLbound(this->applyRandomFactor(modPtr->lBound()) ); modPtr->setPers(this->applyRandomFactor(modPtr->pers()) ); modPtr->setPow(this->applyRandomFactor(modPtr->pow()) ); modPtr->setRough(this->applyRandomFactor(modPtr->rough()) ); modPtr->setScale(this->applyRandomFactor(modPtr->scale()) ); modPtr->setValue(this->applyRandomFactor(modPtr->value()) ); modPtr->setX(this->applyRandomFactor(modPtr->x()) ); modPtr->setY(this->applyRandomFactor(modPtr->y()) ); modPtr->setZ(this->applyRandomFactor(modPtr->z()) ); } mod.data()->setModules(_modules); auto ptr = mod.data()->makeModule(); qDebug() << "Module " << modPtr->name() << " After module creation..."; modPtr->dumpModule(); _modules.insert(mod.data()->name(), ptr); }
//============================================================= // METHOD : SPI // DESCR. : constructor, initalizes SPI and sets mode to master, // sets the SCK and MOSI Pins to output and sets the SCK frequenzy // to freq. //============================================================= SPI::SPI( int freq ) { // only using master mode in the project so slave mode is not part of this SPI driver. DDRB = 0b00000111; // sets MOSI as output and SCK as output rest as input on port B. SPCR = 0b01010000; // enable SPI and set mode to master setFreq(freq); }
void CookbookEq::setFreqAndQ(float freq, float q) { if (!Equal(_freq, freq) || !Equal(_q, q)) { _q = q; setFreq(freq); } }
void DutyUnit::nr4Change(const unsigned newNr4, const unsigned long cc) { setFreq((newNr4 << 8 & 0x700) | (getFreq() & 0xFF), cc); if (newNr4 & 0x80) { nextPosUpdate = (cc & ~1) + period; setCounter(); } }
void DutyUnit::nr4Change(unsigned const newNr4, unsigned long const cc) { setFreq((newNr4 << 8 & 0x700) | (freq() & 0xFF), cc); if (newNr4 & 0x80) { nextPosUpdate_ = (cc & ~1ul) + period_ + 4; setCounter(); } }
void YMVoice::handlePitchBend(int bendRange) { int range = bendRange/10; if (currentFreq - range > 100) { setFreq(currentFreq-range); } }
void radio_button_clicked4(GtkWidget *button, gpointer data) { gboolean active = gtk_toggle_button_get_active(radiobutton4); if(active) { printf("Button4 %i \t",active); setFreq(33); } }
static t_int *bowedbar_perform(t_int *w) { t_bowedbar *x = (t_bowedbar *)(w[1]); float bp = x->x_bp; float bpos = x->x_bpos; float bv = x->x_bv; float GAIN = x->x_GAIN; float integration_const_ = x->x_integration_const_; float fr = x->x_freq; t_float *out = (t_float *)(w[2]); long n = w[3]; float temp, input, data; long k; if(fr != x->fr_save) { setFreq(x, fr); x->fr_save = fr; } x->bowTabl.slope = bp; x->slope = bp; setStrikePosition(x, bpos); while(n--) { data = 0.0; input = 0.0; if(integration_const_ == 0.0) x->velinput = 0.0; else x->velinput = integration_const_ * x->velinput; for(k=0; k<x->NR_MODES; k++) { x->velinput += GAIN * x->delay[k].lastOutput; } input = bv - x->velinput; input = input * BowTabl_lookup(&x->bowTabl, input); input = input/(float)x->NR_MODES; for(k=0; k<x->NR_MODES; k++) { BiQuad_tick(&x->bandpass_[k], input*x->gains[k] + GAIN * x->delay[k].lastOutput); DLineN_tick(&x->delay[k], x->bandpass_[k].lastOutput); data += x->bandpass_[k].lastOutput; } *out++ = data * 4.0; } return w + 4; }
void Blink1Input::fromJson( QJsonObject obj) { setName( obj.value("name").toString() ); setType(obj.value("type").toString()); setArg1(obj.value("arg1").toString()); setArg2(obj.value("arg2").toString()); setDate(obj.value("date").toDouble()); setFreq(obj.value("freq").toDouble()); setFreqCounter(obj.value("freqCounter").toDouble()); setPatternName(obj.value("patternName").toString()); }
KKioDrop& KKioDrop::operator = ( const KKioDrop& other ) { *_kurl=*other._kurl; setFreq( other.freq() ); if( other._protocol ) _protocol = other._protocol->getKIOProtocol(); _ssl = other._ssl; return *this; }
void update() { long int f; if (tx) { f = freq; if (shiftSwitch) f += shift; setFreq(f); display(f); lcdCmd(0x8f); lcdData('T'); } else { setFreq(freq - IF); display(freq); lcdCmd(0x8f); lcdData('R'); } }
SineWaveOsc::SineWaveOsc() { table = new float[MAX_SAMPLES]; outBuffer = new float[MAX_SAMPLES]; index = 0.0; freq = 440.0; setFreq(freq); for(int i = 0; i < MAX_SAMPLES;i++) { table[i] = sin(2 * M_PI * (float) i/MAX_SAMPLES); outBuffer[i] = 0.0; } }
void WaveTableObject::tick(){ for(int i = 0; i < MAX_OUT_BUF_SIZ; i++){ if(readBufferConnected) { setFreq(readBuffer[readIndex]); readIndex = (readIndex + 1) % MAX_SAMPLES; } float val; if(hasHitControl) val = 0.0f; else val = mySine->tick(); outBuffer[outIndex] = val; outIndex = (outIndex + 1) % MAX_SAMPLES; } }
int TunerFrame::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QFrame::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: fieldChanged((*reinterpret_cast< double(*)>(_a[1]))); break; case 1: setFreq((*reinterpret_cast< double(*)>(_a[1]))); break; case 2: adjustFreq((*reinterpret_cast< double(*)>(_a[1]))); break; default: ; } _id -= 3; } return _id; }
boolean Osc::charEv( char code ) { switch ( code ) { #ifdef INTERN_CONSOLE case 'd': // set detuning amount console.getSByte( CONSTR("detune"), &this->detune ); setDetune( detune ); break; case 'f': // input an ideal frequency { double newFreq; if ( console.getDouble( CONSTR("freq"), &newFreq ) ) setFreq( newFreq ); break; } #endif #ifdef CONSOLE_OUTPUT case chrInfo: // display object info to console super::charEv( code ); case chrInLnfo: // display object info inline to console console.infoDouble( CONSTR("freq"), realFreq() ); console.infoInt( CONSTR("detune"), detune ); break; #endif case '!': // perform a reset super::charEv('!'); setDetune(0); extFactor = 1.0; break; default: return super::charEv( code ); } return true; }
void initPLL(long int f) { long int reg; cbi(PORTC, DATA); cbi(PORTC, CLK); cbi(PORTC, LE); // set function latch reg = 0x438086; setPLL(reg); // init R-counter reg = (2UL<<16) + ((fref/F_RASTER)<<2); setPLL(reg); setFreq(f); reg = 0x438082; setPLL(reg); }
bool DisplayStateA::parseSuitableMessage(const CanFrame &frame) { bool update = false; update = setRb (frame[2] & (1 << 7)) || update; update = setRbs (frame[2] & (1 << 6)) || update; update = setVk (frame[2] & (1 << 5)) || update; update = setPull (frame[2] & (1 << 3)) || update; update = setOtpr (frame[2] & (1 << 2)) || update; update = setOc (frame[2] & (1 << 1)) || update; update = setK20 (frame[2] & (1 << 0)) || update; update = setFreq (frame[3] & (1 << 7)) || update; if (frame[3] & (1 << 6)) update = update || setDriveMode (WORKING); else if (frame[2] & (1 << 4)) update = update || setDriveMode (SHUNTING); else update = update || setDriveMode (TRAIN); return update; }
SinOsc::SinOsc(float freq, float volume) { phase = 0.0f; setFreq(freq); setVolume(volume); }
int main(int argc, char **argv){ fprintf(stderr,"NGSrelate buildtime: (%s:%s)\n",__DATE__,__TIME__); if(argc==1){// if no arguments, print info on program info(); return 0; } //below for catching ctrl+c, and dumping files struct sigaction sa; sigemptyset (&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = handler; sigaction(SIGPIPE, &sa, 0); sigaction(SIGINT, &sa, 0); //initial values char *bfile = NULL; char *binfile = NULL; char *outfiles = NULL; double a,k0,k1,k2; a=k0=k1=-1; k2=0; int calcA = 1; //filter opts double minMaf = 0.01; char *freqfile =NULL; // reading arguments argv++; while(*argv){ if(strcmp(*argv,"-beagle")==0 ) bfile=*++argv; else if(strcmp(*argv,"-bin")==0 ) binfile=*++argv; else if(strcmp(*argv,"-freqfile")==0 ) freqfile=*++argv; else if(strcmp(*argv,"-outnames")==0 ) outfiles=*++argv; else if(strcmp(*argv,"-minMaf")==0 ) minMaf = atoi(*++argv); else if(strcmp(*argv,"-a")==0 ) a = atof(*++argv); else if(strcmp(*argv,"-k0")==0 ) k0 = atof(*++argv); else if(strcmp(*argv,"-k1")==0 ) k1 = atof(*++argv); else if(strcmp(*argv,"-k2")==0 ) k2 = atof(*++argv); else if(strcmp(*argv,"-calcA")==0 ) calcA = atoi(*++argv); else{ fprintf(stderr,"Unknown arg:%s\n",*argv); info(); return 0; } ++argv; } if(bfile==NULL&&binfile==NULL){ fprintf(stderr,"Please supply input data file: -beagle OR -bin"); info(); }else if(bfile!=NULL&&binfile!=NULL){ fprintf(stderr,"Please supply input data file: -beagle OR -bin"); info(); } if(outfiles==NULL){ if(bfile!=NULL) outfiles=bfile; else outfiles = binfile; fprintf(stderr,"Will use: %s as prefix for output\n",outfiles); } FILE *flog=openFile(outfiles,".log"); clock_t t=clock();//how long time does the run take time_t t2=time(NULL); std::vector<perChr> pd; if(bfile!=NULL){ bgl d=readBeagle(bfile); fprintf(stderr,"Input beaglefile has dim: nsites=%d nind=%d\n",d.nSites,d.nInd); pd = makeDat(d); gzFile dfile = openFileGz(outfiles,".bin.gz","wb"); for(uint i=0;i<pd.size();i++) marshall_dump(dfile,pd[i]); gzclose(dfile); }else{ gzFile dfile = getGz(binfile,"rb"); pd = marshall_read(dfile); gzclose(dfile); } //calculate frequencies for(uint i=0;i<pd.size();i++) setFreq(pd[i]); // printStuff(pd); //set seed srand(seed); //below is the main looping trhought the iterations. FILE *fp =openFile(outfiles,".freq"); for(int i=0;i<pd[0].nSites;i++) fprintf(fp,"%f ",exp(pd[0].freq[i])); fclose(fp); double *freq = NULL; if(freqfile!=NULL){ freq = readDouble(freqfile,pd[0].nSites); fprintf(stderr,"freq=%f\n",freq[0]); } para p; p.pair[0] = 0;p.pair[1] = 1; p.a=a;p.k0=k0;p.k1=k1;p.k2=k2; fprintf(stderr,"pa=%f pk0=%f\n",p.a,p.k0); hmm res = analysis(pd[0],freq,p,calcA); gzFile bo = openFileGz(outfiles,".bres.gz","wb"); fdump(bo,res,pd[0].name); //deallocate memory for(int i=0;1&&i<dumpedFiles.size();i++){ fprintf(stderr,"dumpedfiles are: %s\n",dumpedFiles[i]); free(dumpedFiles[i]); } fprintf(stderr, "\t[ALL done] cpu-time used = %.2f sec\n", (float)(clock() - t) / CLOCKS_PER_SEC); fprintf(stderr, "\t[ALL done] walltime used = %.2f sec\n", (float)(time(NULL) - t2)); // print to log file fprintf(flog, "\t[ALL done] cpu-time used = %.2f sec\n", (float)(clock() - t) / CLOCKS_PER_SEC); fprintf(flog, "\t[ALL done] walltime used = %.2f sec\n", (float)(time(NULL) - t2)); fclose(flog); gzclose(bo); return 0; }
void DutyUnit::nr3Change(const unsigned newNr3, const unsigned long cc) { setFreq((getFreq() & 0x700) | newNr3, cc); }
void DutyUnit::nr3Change(unsigned newNr3, unsigned long cc) { setFreq((freq() & 0x700) | newNr3, cc); }
void runTest(unsigned int startFreq, unsigned int targetFreq, unsigned int coreID) { double startBenchTime=0; double targetBenchTime=0; unsigned long lowBoundTime=0; unsigned long highBoundTime=0; unsigned long time =0; unsigned long startLoopTime = 0; unsigned long lateStartLoopTime = 0; unsigned long endLoopTime = 0; /* Build the confidence interval of the sample mean */ double startBenchSD=0; double targetBenchSD=0; unsigned long startLowBoundTime=0; unsigned long startHighBoundTime=0; unsigned long targetLowBoundTime=0; unsigned long targetHighBoundTime=0; unsigned long targetQ1=0; unsigned long targetQ3=0; setFreq(coreID,targetFreq); waitCurFreq(coreID,targetFreq); targetBenchTime = measureLoop(NB_BENCH_META_REPET); fprintf(stdout,"Bench %d %.2f\n",targetFreq, targetBenchTime); targetBenchSD = sd(NB_BENCH_META_REPET, targetBenchTime, times); // Build the inter-quartile range for the target frequency interQuartileRange(NB_BENCH_META_REPET, times, &targetQ1, &targetQ3); setFreq(coreID,startFreq); waitCurFreq(coreID,startFreq); startBenchTime = measureLoop(NB_BENCH_META_REPET); fprintf(stdout,"Bench %d %.2f\n",startFreq, startBenchTime); startBenchSD = sd(NB_BENCH_META_REPET, startBenchTime, times); // Build the confidence interval for the target frequency confidenceInterval(NB_BENCH_META_REPET, targetBenchTime, targetBenchSD, &targetLowBoundTime, &targetHighBoundTime); fprintf(stdout,"targetLowbound : %lu ; targetHighbound : %lu\n", targetLowBoundTime,targetHighBoundTime); fprintf(stdout,"targetQ1 : %lu ; targetQ3 : %lu\n", targetQ1, targetQ3); // Build the confidence interval for the start frequency confidenceInterval(NB_BENCH_META_REPET, startBenchTime, startBenchSD, &startLowBoundTime, &startHighBoundTime); fprintf(stdout,"startLowbound : %lu ; startHighbound : %lu\n", startLowBoundTime,startHighBoundTime); // Check if the confidence intervals overlap if ( startLowBoundTime >= targetHighBoundTime || targetLowBoundTime >= startHighBoundTime ) { fprintf(stdout,"Confidence intervals do not overlap, alternatives are statistically different with selected confidence level\n"); } else if( startLowBoundTime < targetHighBoundTime || targetLowBoundTime > startHighBoundTime ) { if( ( startBenchTime >= targetLowBoundTime && startBenchTime <= targetHighBoundTime ) || ( targetBenchTime >= startLowBoundTime && targetBenchTime <= startHighBoundTime ) ) { fprintf(stdout,"Warning: confidence intervals overlap considerably, alternatives are equal with selected confidence level\n"); return; }else { fprintf(stdout,"Warning: confidence intervals overlap, we can not state any thing, need to do the t-test\n"); } } //lowBoundTime = targetLowBoundTime ; //highBoundTime = targetHighBoundTime; // Now we use the inter-quartile range lowBoundTime = targetQ1; highBoundTime = targetQ3; sync(); loop(); warmup_cpuid(); { unsigned int i = 0; unsigned int j = 0; unsigned int it = 0; unsigned int niters = 0; char validated = 0; double validateBenchTime=0; double validateBenchSD=0; unsigned long validateLowBoundTime=0; unsigned long validateHighBoundTime=0; for (it=0;it<NB_REPORT_TIMES;it++){ do { startLoopTime = 0; lateStartLoopTime = 0; endLoopTime = 0; niters = 0; #ifdef _DUMP resetDump(); #endif sync_rdtsc1(startLoopTime); setFreq(coreID,targetFreq); sync_rdtsc1(lateStartLoopTime); do { time = loop(); #ifdef _DUMP writeDump(time); #endif } while ( ( time < lowBoundTime || time > highBoundTime ) && ++niters < NB_TRY_REPET_LOOP ); sync_rdtsc2(endLoopTime); // Validation validated = 1; times[0] = time; measurements[it]= endLoopTime - startLoopTime; measurements_late[it]= endLoopTime - lateStartLoopTime; measurements_timestamps[it]= endLoopTime ; for ( i = 1 ; i < NB_VALIDATION_REPET ; i++ ) { times[i] = loop(); #ifdef _DUMP writeDump(times[i]); #endif } // Build a confidence interval for the new time value validateBenchTime = average(NB_VALIDATION_REPET, times); validateBenchSD = sd(NB_VALIDATION_REPET, validateBenchTime, times); confidenceInterval(NB_VALIDATION_REPET, validateBenchTime, validateBenchSD, &validateLowBoundTime, &validateHighBoundTime); if ( validateHighBoundTime < targetLowBoundTime || validateLowBoundTime > targetHighBoundTime ) { validated = 0; if (j%20==19) { setFreq(coreID,targetFreq); waitCurFreq(coreID,targetFreq); targetBenchTime = measureLoop(NB_BENCH_META_REPET); targetBenchSD = sd(NB_BENCH_META_REPET, targetBenchTime, times); // Build the inter-quartile range for the target frequency interQuartileRange(NB_BENCH_META_REPET, times, &targetQ1, &targetQ3); confidenceInterval(NB_BENCH_META_REPET, targetBenchTime, targetBenchSD, &targetLowBoundTime, &targetHighBoundTime); lowBoundTime = targetQ1; highBoundTime = targetQ3; } } setFreq(coreID,startFreq); waitCurFreq(coreID,startFreq); wait(NB_WAIT_US); }while(!validated && ++j < NB_TRY_REPET); if ( j >= NB_TRY_REPET || validated == 0 ){ it--; } #if NB_REPORT_TIMES == 1 fprintf(stdout,"Number of iterations to solution : %d ; Number of attempts : %d\n", niters, j+1); if ( j >= NB_TRY_REPET || validated == 0 ) fprintf(stdout,"Warning: The computed change time may not be accurate\n"); fprintf(stdout,"LastTime : %lu ; validateLowbound : %lu ; validateHighbound : %lu\n", time, validateLowBoundTime,validateHighBoundTime); #endif }} #if NB_REPORT_TIMES == 1 fprintf(stdout,"Change time (with write) : %lu\n" ,endLoopTime-startLoopTime); fprintf(stdout,"Change time : %lu\n" ,endLoopTime-lateStartLoopTime); fprintf(stdout,"Write cost : : %lu\n" ,lateStartLoopTime-startLoopTime); #else int i=0; for (i=0;i<NB_REPORT_TIMES;i++){ fprintf(stdout,"%lu\t%llu\t%lu\n",measurements[i],measurements_timestamps[i]-measurements_timestamps[0],measurements_late[i]); } #endif }
// length, freq, color is 0 < 1 void epiNode::setRandom(){ setLength( ofRandom(0,1) ); setFreq( ofRandom(0, 20000) ); }