本文整理汇总了C++中MLSignal::row方法的典型用法代码示例。如果您正苦于以下问题:C++ MLSignal::row方法的具体用法?C++ MLSignal::row怎么用?C++ MLSignal::row使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MLSignal
的用法示例。
在下文中一共展示了MLSignal::row方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readToSignal
// read a ring buffer into the given row of the destination signal.
//
int MLProcRingBuffer::readToSignal(MLSignal& outSig, int samples, int row)
{
int lastRead = 0;
int skipped = 0;
int available = 0;
MLSample * outBuffer = outSig.getBuffer() + outSig.row(row);
void * trashBuffer = (void *)mTrashSignal.getBuffer();
MLSample * trashbufferAsSamples = reinterpret_cast<MLSample*>(trashBuffer);
static MLSymbol modeSym("mode");
int mode = (int)getParam(modeSym);
bool underTrigger = false;
MLSample triggerVal = 0.f;
samples = min(samples, (int)outSig.getWidth());
available = (int)PaUtil_GetRingBufferReadAvailable( &mBuf );
// return if we have not accumulated enough signal.
if (available < samples) return 0;
// depending on trigger mode, trash samples up to the ones we will return.
switch(mode)
{
default:
case eMLRingBufferNoTrash:
break;
case eMLRingBufferUpTrig:
while (available >= samples+1)
{
// read buffer
lastRead = (int)PaUtil_ReadRingBuffer( &mBuf, trashBuffer, 1 );
skipped += lastRead;
available = (int)PaUtil_GetRingBufferReadAvailable( &mBuf );
if(trashbufferAsSamples[0] < triggerVal)
{
underTrigger = true;
}
else
{
if (underTrigger == true) break;
underTrigger = false;
}
}
break;
case eMLRingBufferMostRecent:
if (available > samples)
{
// TODO modify pa ringbuffer instead of reading to trash buffer.
lastRead = (int)PaUtil_ReadRingBuffer( &mBuf, trashBuffer, available - samples );
// skipped += lastRead;
}
break;
}
lastRead = (int)PaUtil_ReadRingBuffer( &mBuf, outBuffer, samples );
// DEBUG
/*
const MLSymbol& myName = getName();
if (!myName.compare("body_position_x_out"))
{
available = PaUtil_GetRingBufferReadAvailable( &mBuf );
if ((skipped == 0) && (lastRead == 0))
{
debug() << "-";
}
else
{
debug() << getName() << " requested " << samples << " read " << lastRead << ", skipped " << skipped << ", avail. " << available << "\n";
}
}
*/
return lastRead;
}