本文整理汇总了C++中Patch::connectModulators方法的典型用法代码示例。如果您正苦于以下问题:C++ Patch::connectModulators方法的具体用法?C++ Patch::connectModulators怎么用?C++ Patch::connectModulators使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Patch
的用法示例。
在下文中一共展示了Patch::connectModulators方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeNote
unsigned long writeNote(Note* note, Wave* wave, unsigned long position, double releasePoint)
{
unsigned long sampleCount = note->getSampleCountFor(sampleRate);
// if key is negative, the note is considered a rest, so only silence is written
if(note->getKey() < 0)
{
for(unsigned long i=position; i<(position+sampleCount); i++)
{
wave->setSample(0.0, 0.0, i);
}
return position+sampleCount;
}
Patch* patch = patches[note->getPatchId()];
Operator* op = patch->getRootOperator();
patch->connectModulators();
op->setBaseKey(note->getKey());
op->setBaseOctave(note->getOctave());
op->reset();
map<string, vector<Parameter> > allParams = note->getParameters();
for(map<string, vector<Parameter> >::iterator iter = allParams.begin(); iter != allParams.end(); ++iter)
{
vector<Parameter> operatorParams = iter->second;
for(vector<Parameter>::iterator iter2 = operatorParams.begin(); iter2 != operatorParams.end(); ++ iter2)
{
patch->setOperatorParameter(iter->first, (*iter2).parameterId, (*iter2).value);
}
}
op->updateFrequency();
map<string, Operator*> ops = patch->getOperators();
for(OperatorIterator iter = ops.begin(); iter!= ops.end(); ++iter)
{
Operator* o = iter->second;
o->getEnvelope()->setReleasePoint(releasePoint);
o->getPitchEnvelope()->setReleasePoint(releasePoint);
}
for(unsigned long i=position; i<(position+sampleCount); i++)
{
double left = op->getValueLeft((double)(i-position) / wave->getSampleRate());
double right = op->getValueRight((double)(i-position) / wave->getSampleRate());
if(left>1.0) left = 1.0;
if(left<-1.0) left = -1.0;
if(right>1.0) right = 1.0;
if(right<-1.0) right = -1.0;
int fadeOutPoint = position + sampleCount - fadeOutSamples;
if(i >= (unsigned int)fadeOutPoint)
{
double fadeOut = 1.0 - (double)(i - fadeOutPoint) / fadeOutSamples;
left *= fadeOut;
right *= fadeOut;
}
wave->setSample(left, right, i);
}
return position+sampleCount;
}