本文整理汇总了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(¶ms);
tree->Generate(/*startTime*/0.0,duration, ¶mLists);
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");
//.........这里部分代码省略.........