本文整理汇总了C++中OutputBuffer::writeToken方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputBuffer::writeToken方法的具体用法?C++ OutputBuffer::writeToken怎么用?C++ OutputBuffer::writeToken使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputBuffer
的用法示例。
在下文中一共展示了OutputBuffer::writeToken方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
bool ComplexDomainFlux::process(Ports<InputBuffer*>& inp, Ports<OutputBuffer*>& outp)
{
assert(inp.size()==1);
InputBuffer* in = inp[0].data;
assert(outp.size()==1);
OutputBuffer* out = outp[0].data;
if ((out->tokenno()==0) && (in->tokenno()!=-2))
in->prependZeros(2);
if (!in->hasTokens(3)) return false;
const int N = in->info().size/2;
ArrayXcd inPredPredRotator(N);
ArrayXcd inPredRotator(N);
rotatorOp<double> op;
{
Map<ArrayXcd> inPredPredData((complex<double>*) in->token(0),N);
inPredPredRotator = inPredPredData.unaryExpr(op);
}
while (in->hasTokens(3))
{
Map<ArrayXcd> inPredData((complex<double>*) in->token(1),N);
Map<ArrayXcd> inData((complex<double>*) in->token(2), N);
inPredRotator = inPredData.unaryExpr(op);
double* output = out->writeToken();
*output++ = (inData - (inPredData * (inPredRotator * inPredPredRotator.conjugate()))).abs().sum();
in->consumeToken();
inPredPredRotator.swap(inPredRotator);
}
return true;
}
示例2: process
bool Flux::process(Ports<InputBuffer*>& inp, Ports<OutputBuffer*>& outp)
{
assert(inp.size()==1);
InputBuffer* in = inp[0].data;
assert(outp.size()==1);
OutputBuffer* out = outp[0].data;
if ((out->tokenno()==0) && (in->tokenno()!=-1))
in->prependZeros(1);
if (!in->hasTokens(2))
return false;
const int N = in->info().size;
double lastNorm = 0.0;
double nextNorm = Map<VectorXd>(in->token(0),N).norm();
while (in->hasTokens(2))
{
Map<VectorXd> last(in->token(0),N);
lastNorm = nextNorm;
Map<VectorXd> next(in->token(1),N);
nextNorm = next.norm();
double* output = out->writeToken();
if (lastNorm*nextNorm==0)
*output = 0.0;
else if (m_onlyIncrease)
*output = (next-last).unaryExpr(filterNegativeOp<double>()).squaredNorm() / (lastNorm*nextNorm);
else
*output = (next - last).squaredNorm() / (lastNorm * nextNorm);
in->consumeToken();
}
return true;
}
示例3: process
bool SpectralCrestFactorPerBand::process(Ports<InputBuffer*>& inp, Ports<OutputBuffer*>& outp)
{
assert(inp.size()==1);
InputBuffer* in = inp[0].data;
if (in->empty()) return false;
assert(outp.size()==1);
OutputBuffer* out = outp[0].data;
int nbBands = m_band.size();
double* tmp = new double[in->info().size];
while (!in->empty())
{
double* inData = in->readToken();
double* output = out->writeToken();
for (int k=0;k<nbBands;++k)
{
bandinfo& bi = m_band[k];
double* data = &inData[bi.start];
int datalen = bi.length();
if (bi.group>1) // grpsize > 1
{
data = tmp;
datalen /= bi.group;
double* ptr = &inData[bi.start];
for (int d=0;d<datalen;d++) {
double s = 0;
for (int g=0;g<bi.group;g++)
s += *ptr++;
data[d] = s;
}
}
double am = 0;
double maxdata = data[0];
for (int i=0;i<datalen;i++)
{
am += data[i];
if (data[i]>maxdata) {
maxdata = data[i];
}
}
if (am!=0) {
output[k] = maxdata * datalen / am;
continue;
}
output[k] = maxdata / EPS;
}
in->consumeToken();
}
delete [] tmp;
return true;
}
示例4: assert
bool AC2LPC::process(Ports<InputBuffer*>& inp, Ports<OutputBuffer*>& outp)
{
assert(inp.size()==1);
InputBuffer* in = inp[0].data;
assert(outp.size()==1);
OutputBuffer* out = outp[0].data;
assert(out->info().size==m_nbCoeffs);
assert(in->info().size>m_nbCoeffs);
while (!in->empty())
{
ac2lpc(in->readToken(),out->writeToken(),m_nbCoeffs);
in->consumeToken();
}
return true;
}
示例5: process
bool Difference::process(Ports<InputBuffer*>& inp, Ports<OutputBuffer*>& outp)
{
assert(inp.size()==1);
InputBuffer* in = inp[0].data;
if (in->empty()) return false;
assert(outp.size()==1);
OutputBuffer* out = outp[0].data;
const int N = in->info().size - 1;
while (!in->empty())
{
double* inData = in->readToken();
double* outData = out->writeToken();
for (int i=0;i<N;i++)
outData[i] = inData[i+1] - inData[i];
in->consumeToken();
}
return true;
}
示例6: process
bool Cepstrum::process(Ports<InputBuffer*>& inp, Ports<OutputBuffer*>& outp)
{
assert(inp.size()==1);
InputBuffer* in = inp[0].data;
if (in->empty())
return false;
assert(outp.size()==1);
OutputBuffer* out = outp[0].data;
safeLogOp<double> slop;
VectorXd outDct;
while (!in->empty())
{
Map<VectorXd> inData(in->readToken(),in->info().size);
outDct.noalias() = m_dctPlan * inData.unaryExpr(slop);
memcpy(out->writeToken(),outDct.data() + m_ignoreFirst, out->info().size*sizeof(double));
in->consumeToken();
}
return true;
}
示例7: process
bool SpecificLoudness::process(Ports<InputBuffer*>& inp, Ports<OutputBuffer*>& outp)
{
assert(inp.size()==1);
InputBuffer* in = inp[0].data;
if (in->empty()) return false;
assert(outp.size()==1);
OutputBuffer* out = outp[0].data;
const int N = in->info().size;
const int M = out->info().size;
while (!in->empty())
{
Map<VectorXd> inData(in->readToken(),N);
double* outData = out->writeToken();
for (int i=0;i<NB_BARK_BANDS;i++)
outData[i] = pow(inData.segment(m_bkBdLimits[i],m_bkBdLimits[i+1]-m_bkBdLimits[i]).sum(),0.23);
in->consumeToken();
}
return true;
}
示例8: process
bool FrameTokenizer::process(Ports<InputBuffer*>& inp, Ports<OutputBuffer*>& outp)
{
assert(inp.size()==1);
InputBuffer* in = inp[0].data;
assert(outp.size()==1);
OutputBuffer* out = outp[0].data;
assert(in->size()==1);
if ((out->tokenno()==0) && (in->tokenno()!=-m_blockSize/2))
in->prependZeros(m_blockSize/2);
if (!in->hasTokens(m_blockSize))
return false;
while (in->hasTokens(m_blockSize)) {
in->read(out->writeToken(),m_blockSize);
in->consumeTokens(m_stepSize);
}
return true;
}
示例9: process
bool MelFilterBank::process(Ports<InputBuffer*>& inp, Ports<OutputBuffer*>& outp)
{
assert(inp.size()==1);
InputBuffer* in = inp[0].data;
if (in->empty()) return false;
assert(outp.size()==1);
OutputBuffer* out = outp[0].data;
while (!in->empty()) {
Map<VectorXd> inData(in->readToken(),in->info().size);
double* outData = out->writeToken();
for (int f=0;f<m_filters.size();f++)
{
RowVectorXd& filter = m_filters[f];
outData[f] = filter * inData.segment(m_filterStart[f],filter.size());
}
in->consumeToken();
}
return true;
}
示例10: process
bool AdvancedFrameTokenizer::process(YAAFE::Ports<YAAFE::InputBuffer*>& inp, YAAFE::Ports<YAAFE::OutputBuffer*>& outp)
{
assert(inp.size()==1);
InputBuffer* in = inp[0].data;
assert(outp.size()==1);
OutputBuffer* out = outp[0].data;
assert(in->size()==1);
if ((out->tokenno()==0) && (in->tokenno()!=-m_blockSize/2))
in->prependZeros(m_blockSize/2);
if (!in->hasTokens(m_blockSize))
return false;
while (in->hasTokens(m_blockSize)) {
in->read(out->writeToken(),m_blockSize);
int nextInputToken = (int) floor(out->tokenno() * m_outStepSize * in->info().sampleRate / m_outSampleRate + 0.5);
in->consumeTokens(nextInputToken - m_blockSize/2 - in->tokenno());
}
return true;
}