示例#1
0
void Pitch2Chroma::myProcess(realvec& inVec, realvec& outVec)
{
  mrs_natural t,o;
  outVec.setval(0.);
  for(o=0; o<onObservations_; o++)
    for(t=0; t<inSamples_; t++)
      for(int i=0; i<NrOfNotes_; ++i)
        for(int j=(mrs_natural)StartAndEndIndex_(i,0); j<=(mrs_natural)StartAndEndIndex_(i,1); j++)
          outVec(o,t) += NoteToChromaTransform_(o,i)*
                         PitchToNoteTransform_(i,j)*inVec(j,t);

  if (outVec.sum() != 0)
    outVec /= outVec.sum();
}
static void NormInPlace (realvec& vector)
{
  mrs_real sum = vector.sum ();
  if (sum > 0)
    vector	/= sum;
  return;
}