当前位置: 首页>>代码示例>>C++>>正文


C++ ParameterList::AddParameter方法代码示例

本文整理汇总了C++中ParameterList::AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterList::AddParameter方法的具体用法?C++ ParameterList::AddParameter怎么用?C++ ParameterList::AddParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParameterList的用法示例。


在下文中一共展示了ParameterList::AddParameter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main (int argc, char * const argv[]) {
    // insert code here...
//    std::cout << "Hello, World!\n";
   int  stime;
  long ltime;

  /* get the current calendar time */
  ltime = time(NULL);
  stime = (unsigned) ltime/2;
  srand(stime);


   TreeNode* tree;
   ParameterList params;
   
   tree=new TreeNode(0);
   
   /*
   
enum Parameter
{
   eAmplitude=0,
   eCenterFrequency,
   eBandwidth,
   eLength,
   eSkip,
   eRandomness,
   eMutation,
   eGrainStart,
   eShift,
   eNumParams
};

   for(int i=0;i<100;i++)
   {
      printf("value of randfloatexp2(%f)=%f\n",(float)i/99.0,randfloatexp2((float)i/99.0));
      printf("value of exp2cursor(%f)=%f\n",(float)i/99.0, exp2cursor((float)i/99.0));

   }
*/
   //we need to add each parameter manually, to set it's mins and maxes.
   //nodte that because this program was hacked together in a week that these parameters need to be
   //added in the order of their enum (enumeration).
   
   float startFreq = 1000.0;
   float spacing = 20.0;

   params.SetNumTopLayers(kMaxLayers-1);


/*for sax*/	
	params.AddParameter(eBreathPressure,127.0,0.005,128.0);
	params.AddParameter(eBlowPosition,64.0,0.0005,128.0);
	params.AddParameter(eReedStiffness,64.0,0.0005,128.0);
	params.AddParameter(eReedAperature,64.0,0.0005,128.0);
	params.AddParameter(eCenterFrequency,200,35.0,3600.0);
	params.AddParameter(eVibratoFrequency,5.735*128.0/12.0,0.005,128.0); //these are set wrt the way Saxofony.cpp handles controlChange
	params.AddParameter(eVibratoGain,0.1*2*128,0.005,128.0);
	params.AddParameter(eNoiseGain,0.2*128/0.4,0.005,128.0);
	params.AddParameter(eMaxBlowLength,5.0,0.01,45.0); //in seconds
	params.AddParameter(eMaxRestLength,0.3,0.001,3.0);
	params.AddParameter(eInstrumentNum,1.0,0.001,22.99); //shakers has 23 instruments (0-22)
 /* for noise band*/

   params.AddParameter(eAmplitude,0.3,0.005,1.0);
   params.AddParameter(eBandwidth,0.3,0.01,0.9);
   params.AddParameter(eMultiInstNum,0.001,0.0001,15.0);//for multisynthesizer


	
//   params.AddParameter(eRandomness,0.0,0.000001,1.0);
  // params.AddParameter(eLength,0.5,0.000001,20.0);//in seconds.
   
   float duration = 60*1;
   std::vector<ParameterList*> paramLists;
   paramLists.push_back(&params);
   tree->Generate(/*startTime*/0.0,duration, &paramLists);
   
   tree->PrintFile("firsttest.txt",stime);
   tree->PrintLayerFile("layertest.txt",stime);
   tree->PrintGridFile("grridtest.txt",stime);
   
   //synth
   StereoBuffer16* mix = new StereoBuffer16();
   mix->Create((duration+4)*44100);
   
   int numLayers = tree->GetMaxLayerNum();

    
    std::vector<std::thread> threads;
    std::map<std::thread::id, TreeSynthesizer*> synths;
    std::mutex synthsLock;
   for(int i=0;i<numLayers+1;i++)
   {
       
      threads.push_back(std::thread([&, i](){
          char layerfilename[20];
          char paramfilename[20];
          strcpy(layerfilename,"layerXX.wav");
          strcpy(paramfilename,"layerXX.wav");
//.........这里部分代码省略.........
开发者ID:mchinen,项目名称:treemusic,代码行数:101,代码来源:main.cpp

示例2: main

/**
 * The main function.
 */
int main(int argc, char **argv){
  boost::log::core::get()->set_filter(trivial::severity >= trivial::debug); //setting log level
  BOOST_LOG_TRIVIAL(info) << "  ComPWA Copyright (C) 2013  Mathias Michel ";
  BOOST_LOG_TRIVIAL(info) << "  This program comes with ABSOLUTELY NO WARRANTY; for details see license.txt";
  BOOST_LOG_TRIVIAL(info) << std::endl;

  DalitzKinematics* kin = dynamic_cast<DalitzKinematics*>(DalitzKinematics::createInstance("J/psi","gamma","pi0","pi0"));
	//DPKinematics kin("J/psi","gamma","pi0","pi0");
	//DPKinematics kin("D0","gamma","K-","K+");
	//static dataPoint* point = dataPoint::instance(kin);

  bool resultGen = true;

  std::string file="test/3Part-4vecs_1M_PDG.root";

	const char* pPath = getenv("COMPWA_DIR");
	std::string path = "";
	try{
	  path = std::string(pPath);
	}catch(std::logic_error& ex){
	  BOOST_LOG_TRIVIAL(error)<<"Environment Variable COMPWA_DIR not set?"<<std::endl;
	}
	std::string resoFile=path+"/test/JPSI_ypipi.xml";
    boost::property_tree::ptree pt;
    read_xml(resoFile, pt, boost::property_tree::xml_parser::trim_whitespace);

  BOOST_LOG_TRIVIAL(info)<< "Load Modules";
  std::shared_ptr<RootReader> myReader(new RootReader(file, "data"));
  std::shared_ptr<RootReader> myPHSPReader(new RootReader(file, "mc"));
  std::shared_ptr<AmpSumIntensity> amps(
		  new AmpSumIntensity(
				  "amp",
				  normStyle::none,
				  std::shared_ptr<Efficiency>(new UnitEfficiency()), nFitEvents)
  );
  amps->Configure(pt);

  // Initiate parameters
  ParameterList par;
  std::shared_ptr<Estimator::SliceFitUB::SliceFitUB> esti;
  amps->FillParameterList(par); //perfect startvalues
  esti = std::static_pointer_cast<Estimator::SliceFitUB::SliceFitUB>(
      Estimator::SliceFitUB::SliceFitUB::createInstance(
				  amps, myReader, myPHSPReader, par, nStartEvent,
				  nFitEvents, nBins, nF0, nF2
		  )
  );


  //unsigned int nSlices = nBins-(nBins/20.);
  ParameterList slicePars;
  //for(unsigned int i=0; i<nSlices; i++){
 //   std::string sliceName = "S"+std::to_string(i);
    std::shared_ptr<DoubleParameter> tmpA = std::shared_ptr<DoubleParameter>(new DoubleParameter("P0",0.75,0.1,100.));
    std::shared_ptr<DoubleParameter> tmpB = std::shared_ptr<DoubleParameter>(new DoubleParameter("P1",1.,-15,15));
    std::shared_ptr<DoubleParameter> tmpC = std::shared_ptr<DoubleParameter>(new DoubleParameter("P2",0.,0,15));
    std::shared_ptr<DoubleParameter> tmpD = std::shared_ptr<DoubleParameter>(new DoubleParameter("P3",0.1,-15,15));
    std::shared_ptr<DoubleParameter> tmpE = std::shared_ptr<DoubleParameter>(new DoubleParameter("P4",1.,0,50));
    //std::shared_ptr<DoubleParameter> tmpF = std::shared_ptr<DoubleParameter>(new DoubleParameter("P5",1.,-10,10));
    tmpA->FixParameter(true);
    //tmpC->FixParameter(true);
    //tmpE->FixParameter(true);
    //tmpB->FixParameter(true);
    //tmpD->FixParameter(true);
    tmpB->SetError(1.);
    tmpC->SetError(1.);
    tmpD->SetError(1.);
    tmpE->SetError(1.);
    //tmpA->UseBounds(true);
    //tmpB->UseBounds(true);
    //tmpC->UseBounds(true);
    //tmpD->UseBounds(true);
    //tmpE->UseBounds(true);
    slicePars.AddParameter(tmpA);
    slicePars.AddParameter(tmpB);
    slicePars.AddParameter(tmpC);
    slicePars.AddParameter(tmpD);
    slicePars.AddParameter(tmpE);
    //slicePars.AddParameter(tmpF);


    TH2D* phspA = new TH2D("phspTOT","phspTOT",100,0,10,100,0,10);
    TH2D* phspB = new TH2D("phspSpin0","phspSpin0",100,0,10,100,0,10);
    TH2D* phspD = new TH2D("phspSpin2","phspSpin2",100,0,10,100,0,10);
    TH2D* phspC = new TH2D("phspAll","phspAll",100,0,10,100,0,10);
    std::complex<double> reso[2];
    reso[0]=std::complex<double>(10,0);
    reso[1]=std::complex<double>(0,0);
    std::complex<double> resoC[2];
    resoC[0]=std::complex<double>(0,0);
    resoC[1]=std::complex<double>(20,0);
    std::complex<double> resoTOT[2];
    resoTOT[0]=std::complex<double>(0,0);
    resoTOT[1]=std::complex<double>(0,0);
    std::complex<double> resoFull[2];
    resoFull[0]=std::complex<double>(22,0);
    resoFull[1]=std::complex<double>(15,0);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的ParameterList::AddParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。