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


C++ TreeNode::Synthesize方法代码示例

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


在下文中一共展示了TreeNode::Synthesize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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