int main(int argc, char *argv[]) { int t; char a, b, x, y, k; scanf("%i", &t); while (t--) { getchar(); k = getchar(); getchar(); a = getchar(); a = pro(a); x = getchar(); getchar(); b = getchar(); b = pro(b); y = getchar(); if (x == k) { puts("YES"); } else if (y == k) { puts("NO"); } else if (a > b) { puts("YES"); } else { puts("NO"); } } return 0; }
void value_t::set(value_id_t value_id, const string_t& value) { pi_t::pro_t::item_t id_item(pi_t::pro_t::uint_t(value_id), NULL); const str_t& value_str = value.str(); pi_t::pro_t::item_t value_item(value_str, &id_item); pi_t::pro_t pro(&value_item); value_ = pi_ext_t::__build(pro); }
Operation * OperationFactory::CreateOperation(const char oper,int lhn,int rhn) { switch (oper) { case '+': { OperationAdd add(lhn,rhn); operation = &add; };break; case '-': { OperationSub sub(lhn,rhn); operation = ⊂ };break; case '*': { OperationProduct pro(lhn,rhn); operation = &pro; };break; default: break; } int number = operation->operation(); cout<<lhn<<oper<<rhn<<"="<<number<<endl; return operation; }
void KICAD_MANAGER_FRAME::OnNewProject( wxCommandEvent& aEvent ) { wxString default_dir = GetMruPath(); wxFileDialog dlg( this, _( "Create New Project" ), default_dir, wxEmptyString, ProjectFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); // Add a "Create a new directory" checkbox dlg.SetExtraControlCreator( &DIR_CHECKBOX::Create ); if( dlg.ShowModal() == wxID_CANCEL ) return; wxFileName pro( dlg.GetPath() ); // wxFileName automatically extracts an extension. But if it isn't // a .pro extension, we should keep it as part of the filename if( !pro.GetExt().IsEmpty() && pro.GetExt().ToStdString() != ProjectFileExtension ) pro.SetName( pro.GetName() + wxT( "." ) + pro.GetExt() ); pro.SetExt( ProjectFileExtension ); // enforce extension if( !pro.IsAbsolute() ) pro.MakeAbsolute(); // Append a new directory with the same name of the project file. if( static_cast<DIR_CHECKBOX*>( dlg.GetExtraControl() )->CreateNewDir() ) pro.AppendDir( pro.GetName() ); // Check if the project directory is empty if it already exists. wxDir directory( pro.GetPath() ); if( !pro.DirExists() ) { if( !pro.Mkdir() ) { wxString msg; msg.Printf( _( "Directory \"%s\" could not be created.\n\n" "Please make sure you have write permissions and try again." ), pro.GetPath() ); DisplayErrorMessage( this, msg ); return; } } else if( directory.HasFiles() ) { wxString msg = _( "The selected directory is not empty. It is recommended that you " "create projects in their own empty directory.\n\nDo you " "want to continue?" ); if( !IsOK( this, msg ) ) return; } CreateNewProject( pro ); LoadProject( pro ); }
void solver(){ int k=1; while(true){ if(ok(k))break; //printf("%s\n",map[k]); //getchar(); pro(k); } }
int main() { long sum,i; char s[1001]; while(scanf("%s",s)!=EOF) { if(strcmp(s,"0")==0) break; for(i=0,sum=0;i < strlen(s); i++) { sum += s[i]-'0'; } printf("%d\n",pro(sum)); } return 0; }
bool value_t::set(const pi_t& pi_value) { const value_id_t value_id = pi_value.s_ind(0).s_uint(); const str_t& value_str = pi_value.s_ind(1).s_str(); if(value_id == INVALID_VALUE_ID || value_str.size() == 0) { return false; } pi_t::pro_t::item_t id_item(pi_t::pro_t::uint_t(value_id), NULL); pi_t::pro_t::item_t value_item(value_str, &id_item); pi_t::pro_t pro(&value_item); value_ = pi_ext_t::__build(pro); return true; }
bool ProjectFileGenerator::remove(const QStringList &files) { QString output; QFile pro(filePath); if (pro.exists()) { if (pro.open(QIODevice::ReadOnly | QIODevice::Text)) { output = pro.readAll(); } else { qCritical("failed to open file: %s", qPrintable(pro.fileName())); return false; } } else { qCritical("Project file not found: %s", qPrintable(pro.fileName())); return false; } pro.close(); if (files.isEmpty()) return true; for (QStringListIterator i(files); i.hasNext(); ) { QString f = QFileInfo(i.next()).fileName(); QString str; QRegExp rx("*.h"); rx.setPatternSyntax(QRegExp::Wildcard); if (rx.exactMatch(f)) { str = "HEADERS += "; str += f; str += '\n'; } else { rx.setPattern("*.cpp"); if (rx.exactMatch(f)) { str = "SOURCES += "; str += f; str += '\n'; } } int idx = 0; if (!str.isEmpty() && (idx = output.indexOf(str)) >= 0 ) { output.remove(idx, str.length()); } } return FileWriter(filePath).write(output, true); }
bool ProjectFileGenerator::add(const QStringList &files) { QString output; QFile pro(filePath); if (!pro.exists()) { qCritical("Project file not found: %s", qPrintable(pro.fileName())); return false; } else { if (pro.open(QIODevice::ReadOnly | QIODevice::Text)) { output = pro.readAll(); } else { qCritical("failed to open file: %s", qPrintable(pro.fileName())); return false; } } pro.close(); for (QStringListIterator i(files); i.hasNext(); ) { const QString &f = i.next(); QString str; QRegExp rx("*.h"); rx.setPatternSyntax(QRegExp::Wildcard); if (rx.exactMatch(f)) { str = "HEADERS += "; str += f; str += '\n'; } else { rx.setPattern("*.cpp"); if (rx.exactMatch(f)) { str = "SOURCES += "; str += f; str += '\n'; } } if (!str.isEmpty() && !output.contains(str)) { if (!output.endsWith('\n')) { output += '\n'; } output += str; } } return FileWriter(filePath).write(output, true); }
void Test_BronKerbosch::setUp() { Graph_p pro(8); pro[addEdge(0,2,pro).first].label = "z"; pro[addEdge(0,4,pro).first].label = "u"; pro[addEdge(0,6,pro).first].label = "u"; pro[addEdge(0,7,pro).first].label = "z"; pro[addEdge(1,5,pro).first].label = "z"; pro[addEdge(1,6,pro).first].label = "z"; pro[addEdge(1,7,pro).first].label = "u"; pro[addEdge(2,4,pro).first].label = "z"; pro[addEdge(2,6,pro).first].label = "z"; pro[addEdge(2,7,pro).first].label = "u"; pro[addEdge(3,4,pro).first].label = "z"; pro[addEdge(3,5,pro).first].label = "z"; pro[addEdge(6,7,pro).first].label = "z"; this->p = pro; }
void Test_PG_Output::setUp() { Graph fst(4); fst[0].label = "h";fst[1].label = "e";fst[2].label = "e";fst[3].label = "e"; fst[0].id = 10;fst[1].id = 20;fst[2].id = 30;fst[3].id = 40; fst[addEdge(0,1,fst).first].label = "p"; fst[addEdge(1,2,fst).first].label = "m"; fst[addEdge(2,3,fst).first].label = "m"; fst[addEdge(3,0,fst).first].label = "m"; this->f = fst; Graph sec(5); sec[0].label = "h";sec[1].label = "e";sec[2].label = "e";sec[3].label = "e";sec[4].label = "e"; sec[0].id = 11;sec[1].id = 22;sec[2].id = 33;sec[3].id = 44;sec[4].id = 55; sec[addEdge(0,1,sec).first].label = "p"; sec[addEdge(1,2,sec).first].label = "m"; sec[addEdge(2,3,sec).first].label = "m"; sec[addEdge(3,0,sec).first].label = "m"; sec[addEdge(4,2,sec).first].label = "m"; this->s = sec; Graph_p pro(8); pro[0].edgeFst = boost::edge(3,0,fst).first; pro[0].edgeSec = boost::edge(3,0,sec).first; pro[1].edgeFst = boost::edge(2,3,fst).first; pro[1].edgeSec = boost::edge(4,2,sec).first; pro[2].edgeFst = boost::edge(2,3,fst).first; pro[2].edgeSec = boost::edge(2,3,sec).first; pro[3].edgeFst = boost::edge(2,3,fst).first; pro[3].edgeSec = boost::edge(1,2,sec).first; pro[4].edgeFst = boost::edge(1,2,fst).first; pro[4].edgeSec = boost::edge(4,2,sec).first; pro[5].edgeFst = boost::edge(1,2,fst).first; pro[5].edgeSec = boost::edge(2,3,sec).first; pro[6].edgeFst = boost::edge(1,2,fst).first; pro[6].edgeSec = boost::edge(1,2,sec).first; pro[7].edgeFst = boost::edge(0,1,fst).first; pro[7].edgeSec = boost::edge(0,1,sec).first; pro[addEdge(0,2,pro).first].label = "z"; pro[addEdge(0,4,pro).first].label = "u"; pro[addEdge(0,6,pro).first].label = "u"; pro[addEdge(0,7,pro).first].label = "z"; pro[addEdge(1,5,pro).first].label = "z"; pro[addEdge(1,6,pro).first].label = "z"; pro[addEdge(1,7,pro).first].label = "u"; pro[addEdge(2,4,pro).first].label = "z"; pro[addEdge(2,6,pro).first].label = "z"; pro[addEdge(2,7,pro).first].label = "u"; pro[addEdge(3,4,pro).first].label = "z"; pro[addEdge(3,5,pro).first].label = "z"; pro[addEdge(6,7,pro).first].label = "z"; this->p = pro; this->clique = {0,2,4}; }
void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) { wxString default_dir = GetMruPath(); wxFileDialog dlg( this, _( "Open Existing Project" ), default_dir, wxEmptyString, ProjectFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) return; wxFileName pro( dlg.GetPath() ); pro.SetExt( ProjectFileExtension ); // enforce extension if( !pro.IsAbsolute() ) pro.MakeAbsolute(); if( !pro.FileExists() ) return; LoadProject( pro ); }
bool evaluateProFile(const QString &fileName, bool verbose, QHash<QByteArray, QStringList> *varMap) { QFileInfo fi(fileName); if (!fi.exists()) return false; ProFile pro(fi.absoluteFilePath()); ProFileEvaluator visitor; visitor.setVerbose(verbose); if (!visitor.queryProFile(&pro)) return false; if (!visitor.accept(&pro)) return false; evaluateProFile(visitor, varMap, fi.absolutePath()); return true; }
void MainWindow::on_process_add_clicked() { Entity pro(true); QString a = ui->process_name->text(); QString s =ui->process_size->text(); pro.set_name(a); pro.set_size(s.toInt()); if(ui->first->isChecked()) { Allocation::FirstFit(memo,pro); } else if(ui->best->isChecked()) { Allocation::BestFit(memo,pro); } else if(ui->worst->isChecked()) { Allocation::WorstFit(memo,pro); } }
int main(int argc,char* argv[]) { Matrix A; Vector b; A = Matrix::random(m,n); b = Vector::random(m); std::cout<<"A : "<<std::endl<<A<<std::endl; std::cout<<"b : "<<std::endl<<b<<std::endl; problem pro(A,b); lmssolver lmssol(pro); lssolver lssol(pro); rlssolver rlssol(pro); // COPT::Printer::printType(A,std::cout); // COPT::Printer::printType(b,std::cout); std::cout<<"results of three solvers:"<<std::endl; lmssol.solve(); lssol.solve(); rlssol.solve(); }
int main() { int x,y,z, v; x=y=z=0; int b=0; if (x*y==3) { while (b) { y=y+2; z=z+x; v = foo(z) * bar(z,y); y = 3 * foo(2*x); } } else { x=x+3; x=x+1; } int param = 60; int i = ff(param); i = pro(i); ff(i); }
FVector ASkill::GetGroundLocationBeneathPoint(FVector point) { FHitResult hit; FVector start = point; FVector end = start; end.Z -= 100000.f; //get all game characters and projectiles currently in the world so we can ignore them later TArray<AActor*> ignoredActors; for (TActorIterator<AGameCharacter> chr(GetWorld()); chr; ++chr) ignoredActors.AddUnique(*chr); for (TActorIterator<AProjectile> pro(GetWorld()); pro; ++pro) ignoredActors.AddUnique(*pro); FCollisionQueryParams collisionParams; collisionParams.AddIgnoredActors(ignoredActors); if (GetWorld()->LineTraceSingleByChannel(hit, start, end, ECC_WorldStatic, collisionParams)) return hit.ImpactPoint; else return point; }
int main(){ input(); pro(); return 0; }
void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event ) { // Any open KIFACE's must be closed if they are not part of the new project. // (We never want a KIWAY_PLAYER open on a KIWAY that isn't in the same project.) // User is prompted here to close those KIWAY_PLAYERs: if( !Kiway.PlayersClose( false ) ) return; // evt_id can be one of: // ID_NEW_PROJECT, ID_NEW_PROJECT_FROM_TEMPLATE, ID_LOAD_PROJECT, and // wxID_ANY from 3 different places. int evt_id = event.GetId(); wxString title; ClearMsg(); bool newProject = ( evt_id == ID_NEW_PROJECT ) || ( evt_id == ID_NEW_PROJECT_FROM_TEMPLATE ); if( evt_id != wxID_ANY ) { int style; if( newProject ) { title = _( "Create New Project" ); style = wxFD_SAVE | wxFD_OVERWRITE_PROMPT; } else { title = _( "Open Existing Project" ); style = wxFD_OPEN | wxFD_FILE_MUST_EXIST; } wxString default_dir = GetMruPath(); wxFileDialog dlg( this, title, default_dir, wxEmptyString, ProjectFileWildcard, style ); if( dlg.ShowModal() == wxID_CANCEL ) return; //DBG( printf( "%s: wxFileDialog::GetPath=%s\n", __func__, TO_UTF8( dlg.GetPath() ) );) wxFileName pro( dlg.GetPath() ); pro.SetExt( ProjectFileExtension ); // enforce extension if( !pro.IsAbsolute() ) pro.MakeAbsolute(); if( newProject ) { // Check if the project directory is empty wxDir directory( pro.GetPath() ); if( directory.HasFiles() ) { wxString msg = _( "The selected directory is not empty. We recommend you " "create projects in their own clean directory.\n\nDo you " "want to create a new empty directory for the project?" ); if( IsOK( this, msg ) ) { // Append a new directory with the same name of the project file // and try to create it pro.AppendDir( pro.GetName() ); if( !wxMkdir( pro.GetPath() ) ) // There was a problem, undo pro.RemoveLastDir(); } } if( evt_id == ID_NEW_PROJECT ) { CreateNewProject( pro.GetFullPath() ); } else if( evt_id == ID_NEW_PROJECT_FROM_TEMPLATE ) { // Launch the template selector dialog CreateNewProject( pro.GetFullPath(), true ); } } SetProjectFileName( pro.GetFullPath() ); } wxString prj_filename = GetProjectFileName(); wxString nameless_prj = NAMELESS_PROJECT wxT( ".pro" ); wxLogDebug( wxT( "%s: %s" ), GetChars( wxFileName( prj_filename ).GetFullName() ), GetChars( nameless_prj ) ); // Check if project file exists and if it is not noname.pro if( !wxFileExists( prj_filename ) && !wxFileName( prj_filename ).GetFullName().IsSameAs( nameless_prj ) ) { wxString msg = wxString::Format( _( "KiCad project file '%s' not found" ), GetChars( prj_filename ) ); DisplayError( this, msg ); return; } // Either this is the first time kicad has been run or one of the projects in the // history list is no longer valid. This prevents kicad from automatically creating // a noname.pro file in the same folder as the kicad binary. if( wxFileName( prj_filename ).GetFullName().IsSameAs( nameless_prj ) && !newProject ) { m_active_project = false; m_MessagesBox->SetValue( _( "To proceed, you can use the File menu to start a new project." ) ); return; } else { m_active_project = true; m_MessagesBox->Clear(); } Prj().ConfigLoad( Pgm().SysSearch(), GeneralGroupName, s_KicadManagerParams ); title = wxT( "KiCad " ) + GetBuildVersion() + wxT( ' ' ) + prj_filename; if( !wxFileName( prj_filename ).IsDirWritable() ) title += _( " [Read Only]" ); else SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. SetTitle( title ); if( !prj_filename.IsSameAs( nameless_prj ) ) UpdateFileHistory( prj_filename, &Pgm().GetFileHistory() ); m_LeftWin->ReCreateTreePrj(); // Rebuild the list of watched paths. // however this is possible only when the main loop event handler is running, // so we use it to run the rebuild function. wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED, ID_INIT_WATCHED_PATHS ); wxPostEvent( this, cmd ); PrintPrjInfo(); }
void CProject::CalculateAmpVarPeriod(int freqpnt, int *freqdat, int what, CalcMode mode) { UpdatePEData(); // check if weights should be used if (!Period.GetUseWeight()) { if (Timestring.GetSelectedPoints()!=Timestring.GetWeightSum()) { if (Confirm(DIALOG_PERIOD_USE_WEIGHTS)==1) { Period.SetUseWeight(1); } } } // Set Frequencies for Amplitude Variations int i; for (i=0;i<freqpnt;i++) { Period[freqdat[i]].SetAmpVar(mode); } // what names should be used ? Period.SetUseID(what); // PROTOCOL // Write Calculation-header char tempprot[AMPVARMSGBUFFER]; for (i=0;i<AMPVARMSGBUFFER;i++) { tempprot[i]=0; } char txt[1024]; ostrstream pro(tempprot,AMPVARMSGBUFFER); pro<<PROTOCOL_AMPVAR_CALCULATE_HEADER<<endl; //WriteFrequenciesTabulated(pro,1); //sprintf(txt,PROTOCOL_ZEROPOINT,Period.GetZeropoint()); //pro<<txt<<endl; if (Period.GetUseWeight()) { pro<<PROTOCOL_PERIOD_USE_WEIGHTS<<endl; } pro<<PROTOCOL_AMPVAR_NAMES_SELECTED<<NameSet(what)<<endl; pro<<PROTOCOL_PERIOD_CALCULATION_STARTED<<Date()<<endl; pro<<char(0)<<flush; Waiting(1,1); // Calculate switch (Period.Calc(Timestring)) { case 0: { // Write Calculation-footer ostream &tmp=Write(); tmp<<pro.str(); tmp<<PROTOCOL_PERIOD_OUTPUT<<endl; // now write the protocol char txt1[AMPVARMSGBUFFER]; for (i=0;i<AMPVARMSGBUFFER;i++) { txt1[i]=0; } ostrstream pro1(txt1,AMPVARMSGBUFFER); // general data.. CTimeString &Timestring=GetTimeString(); CPeriod const &Period=GetPeriod(); int freqs=Period.GetFrequencies(); // now fill in the data... for (int fre=0;fre<freqs;fre++) { int fr=fre; if (Period[fr].GetActive()) { switch (Period[fr].GetAmpVariation()) { case NoVar: { sprintf(txt,PROTOCOL_AMPVAR_NOVAR, GetNumber(fr).chars(), GetFrequency(fr).chars(), Period[fr].GetAmplitude(-1), Period[fr].GetPhase(-1) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; break; } case AmpVar: { // first write out the header sprintf(txt,PROTOCOL_AMPVAR_AMPVAR_HEAD, GetNumber(fr).chars(), GetFrequency(fr).chars(), Period[fr].GetPhase(-1) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; // now write out the relevant data for (int na=0;na<Timestring.NumberOfNames(what);na++) { int id= Timestring.GetIndexName(what,na).GetID(); int points= Timestring.GetIndexName(what,na).GetPoints(); myString name= Timestring.GetIndexName(what,na).GetName(); if (points!=0) { sprintf(txt,PROTOCOL_AMPVAR_AMPVAR, name.chars(), Period[fr].GetAmplitude(id) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; } } break; } case PhaseVar: { // first write out the header sprintf(txt,PROTOCOL_AMPVAR_PHASEVAR_HEAD, GetNumber(fr).chars(), GetFrequency(fr).chars(), Period[fr].GetAmplitude(-1) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; // now write out the relevant data for (int na=0;na<Timestring.NumberOfNames(what);na++) { int id= Timestring.GetIndexName(what,na).GetID(); int points= Timestring.GetIndexName(what,na).GetPoints(); myString name= Timestring.GetIndexName(what,na).GetName(); if (points!=0) { sprintf(txt,PROTOCOL_AMPVAR_PHASEVAR, name.chars(), Period[fr].GetPhase(id) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; } } break; } case AllVar: { // first write out the header sprintf(txt,PROTOCOL_AMPVAR_ALLVAR_HEAD, GetNumber(fr).chars(), GetFrequency(fr).chars() ); // write out pro1<<txt<<endl; tmp<<txt<<endl; // now write out the relevant data for (int na=0;na<Timestring.NumberOfNames(what);na++) { int id= Timestring.GetIndexName(what,na).GetID(); int points= Timestring.GetIndexName(what,na).GetPoints(); myString name= Timestring.GetIndexName(what,na).GetName(); if (points!=0) { sprintf(txt,PROTOCOL_AMPVAR_ALLVAR, name.chars(), Period[fr].GetAmplitude(id), Period[fr].GetPhase(id) ); // write out pro1<<txt<<endl; tmp<<txt<<endl; } } break; } } } } // now write the rest.. sprintf(txt,PROTOCOL_PERIOD_RESULT, Period.GetZeropoint(), Period.GetResiduals(), Period.GetIterations()); pro1<<txt<<flush; tmp<<txt<<flush; // Have we reached Maximum Number Iterations? if (Period.GetIterations()>=Period.MaxIterations()) { InformUser(DIALOG_PERIOD_MAXIMUM_ITERATIONS); } // now display the data... DisplayAmpVarData(pro1.str()); break; } case 1:// Matrix cannot be inverted { InformUser(DIALOG_PERIOD_MATRIX_INVERSION); break; } case 2:// cancel pressed, may not be a stable solution { InformUser(DIALOG_PERIOD_CALCULATION_INTERRUPTED); break; } } Waiting(0); // Cleans Frequencies of Amplitude Variations for (i=0;i<freqpnt;i++) { Period[freqdat[i]].SetAmpVar(NoVar); } UpdatePEDisplays(); }
JNIEXPORT jboolean JNICALL Java_com_audio_jni_AudioPreprocessJni_preprocess( JNIEnv *env, jobject jobj, jstring jinpcm, jstring joutpcm, jint jsamRate, jint jBytesPerSample, jint jchannelNumber, jint jnoiseSuppress) { LOGD("Enter func : %s", __FUNCTION__); if (!jinpcm || !joutpcm) { LOGE("error filename is null"); return JNI_FALSE; } if(jchannelNumber!=1 && jchannelNumber!=2){ LOGE("error jchannelNumber is %d", jchannelNumber); return JNI_FALSE; } if(jBytesPerSample!=1 && jBytesPerSample!=2){ LOGE("error jBytesPerSample is %d", jBytesPerSample); return JNI_FALSE; } FILE *ifp, *ofp; // long iflen = 0, nSetup = 0; // spx_int32_t i; // spx_int32_t noisesuppress; // SpeexPreprocessState *st; size_t actual_len = 0; const char* utf8in = env->GetStringUTFChars(jinpcm, NULL); ifp = fopen(utf8in, "rb"); if (!ifp) { LOGE("%s no exit",utf8in); env->ReleaseStringUTFChars(jinpcm, utf8in); return JNI_FALSE; } const char* utf8out = env->GetStringUTFChars(joutpcm, NULL); ofp = fopen(utf8out, "wb"); if (!ofp) { LOGE("%s no exit",utf8out); env->ReleaseStringUTFChars(joutpcm, utf8out); return JNI_FALSE; } SoundPreprocessor pro(jsamRate, jBytesPerSample, jchannelNumber, jnoiseSuppress); // int nBytesPerSecond = jsamRate * jchannelNumber * jBytesPerSample; int bufSize = pro.getBytesPerFrame(); if(bufSize<=0){ LOGE("error getBytesPerFrame: %d",bufSize); env->ReleaseStringUTFChars(joutpcm, utf8out); return JNI_FALSE; } // fseek(ifp,0L,SEEK_END); // iflen = ftell(ifp); // fseek(ifp,0L,SEEK_SET); // // nSetup = iflen / m_nBytesPerFrame; //鍒嗛厤鍐呭瓨绌洪棿 int8_t *procbuf = new int8_t[bufSize]; if(!procbuf){ LOGE("no src memory"); return JNI_FALSE; } LOGD("func-: %s,,sampleRate: %d,,bytesPerSample: %d,,channel: %d,,bufSize: %d,,noiseSuppress: %d", __FUNCTION__, jsamRate, jBytesPerSample, jchannelNumber, bufSize, jnoiseSuppress); // st = speex_preprocess_state_init(m_nBytesPerFrame / sizeof(short), jsamRate); // i=1; // speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_DENOISE, &i); // noisesuppress = (spx_int32_t)jnoiseSuppress; // speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &noisesuppress); // spx_int32_t maxAttenuationNoise = 0, noisesuppress = 0; // speex_preprocess_ctl(st, SPEEX_PREPROCESS_GET_NOISE_SUPPRESS, &maxAttenuationNoise); // noisesuppress = -200;//maxAttenuationNoise / 2; // LOGD("func : %s,,max attenuation : %d,,noisesuppress: %d", __FUNCTION__, maxAttenuationNoise, noisesuppress); // if(noisesuppress<0){ // noisesuppress = -10; // speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &noisesuppress); // LOGD("func : %s,,noisesuppress: %d", __FUNCTION__, noisesuppress); // } // FILE *dmpfp = fopen("/sdcard/DCIM/pcm_data.txt", "wb"); for (;;) { //浠庢枃浠惰鍙栨暟鎹� actual_len = fread(procbuf, sizeof(int8_t), bufSize, ifp); if (feof(ifp)) { //鏁版嵁宸茬粡璇诲彇瀹屾瘯 break; } if(actual_len == bufSize){ pro.preprocess(procbuf, actual_len); }else{ LOGD("func : %s,,not process,,actual_len:%d,,bufSize:%d", __FUNCTION__,actual_len, bufSize); } //#define LN 16 // char str[LN]={0}; // for(int i=0; i<actual_len / 2; i++){ // sprintf(str,"%d,", procbuf[i]); // fwrite(str, 1, LN, dmpfp); // if(procBuf[i]>MAX_CH){ // if(i<50) // LOGD("func : %s,,maxV: %d", __FUNCTION__, procBuf[i]); // procbuf[i] = MAX_CH; // }else if(procBuf[i]<-(MAX_CH+1)){ // LOGD("func : %s,,minV: %d", __FUNCTION__, procBuf[i]); // procbuf[i] = -(MAX_CH+1); // } // } fwrite(procbuf, sizeof(int8_t), actual_len, ofp); } // fclose(dmpfp); //閲婃斁绌洪棿 delete []procbuf; //鍏抽棴鏂囦欢 fclose(ifp); fclose(ofp); // speex_preprocess_state_destroy(st); env->ReleaseStringUTFChars(jinpcm, utf8in); env->ReleaseStringUTFChars(joutpcm, utf8out); LOGD("Leave func : %s", __FUNCTION__); return JNI_TRUE; }
int main(int nArgs, char *args[]) { std::cout<<"Hello!"; TruckProducer pro(p); return 0; }
void CProject::GeneralCalcPeriod(DataMode mode) { if (!((mode==Observed)||(mode==Adjusted))) { MYERROR("Wrong calculation-mode..."<<(int)mode); return; } DataMode old=Timestring.GetDataMode(); Timestring.SetDataMode(mode); Period.SetUseData(mode); // check if weights should be used if (!Period.GetUseWeight()) { if (Timestring.GetSelectedPoints()!=Timestring.GetWeightSum()) { if (Confirm(DIALOG_PERIOD_USE_WEIGHTS)==1) { Period.SetUseWeight(1); } } } Waiting(1,1); // Write Calculation-header char tempprot[10240]; char txt[256]; ostrstream pro(tempprot,1024); pro<<PROTOCOL_PERIOD_CALCULATE_HEADER<<endl; //WriteFrequenciesTabulated(pro,1); //sprintf(txt,PROTOCOL_ZEROPOINT,Period.GetZeropoint()); //pro<<txt<<endl; if (Period.GetUseWeight()) { pro<<PROTOCOL_PERIOD_USE_WEIGHTS<<endl; } // if (mode==Observed) { pro<<PROTOCOL_PERIOD_USE_OBSERVED<<endl; } else { pro<<PROTOCOL_PERIOD_USE_ADJUSTED<<endl; } // pro<<PROTOCOL_PERIOD_CALCULATION_STARTED<<Date()<<endl; pro<<char(0)<<flush; // Calculate switch(Period.Calc(Timestring)) { case 0:// normal calculations done { // Write Calculation-footer ostream &tmp=Write(); tmp<<pro.str(); tmp<<PROTOCOL_PERIOD_OUTPUT<<endl; WriteFrequenciesTabulated(tmp,1); sprintf(txt,PROTOCOL_PERIOD_RESULT, Period.GetZeropoint(), Period.GetResiduals(), Period.GetIterations()); tmp<<txt<<endl; if (Period.GetIterations()>=Period.MaxIterations()) { InformUser(DIALOG_PERIOD_MAXIMUM_ITERATIONS); } break; } case 1:// Matrix cannot be inverted { InformUser(DIALOG_PERIOD_MATRIX_INVERSION); break; } case 2:// cancel pressed, may not be a stable solution { InformUser(DIALOG_PERIOD_CALCULATION_INTERRUPTED); break; } } Waiting(0); Timestring.SetDataMode(old); }