| 63 | } |
| 64 | |
| 65 | void BasicPitchCNN::frameInference(const float* inData, |
| 66 | std::vector<float>& outContours, |
| 67 | std::vector<float>& outNotes, |
| 68 | std::vector<float>& outOnsets) |
| 69 | { |
| 70 | // Checks on parameters |
| 71 | assert(outContours.size() == NUM_FREQ_IN); |
| 72 | assert(outNotes.size() == NUM_FREQ_OUT); |
| 73 | assert(outOnsets.size() == NUM_FREQ_OUT); |
| 74 | |
| 75 | // Copy data in aligned input array for inference |
| 76 | std::copy(inData, inData + NUM_HARMONICS * NUM_FREQ_IN, mInputArray.begin()); |
| 77 | |
| 78 | _runModels(); |
| 79 | |
| 80 | // Fill output vectors |
| 81 | std::copy(mCNNOnsetOutput.getOutputs(), mCNNOnsetOutput.getOutputs() + NUM_FREQ_OUT, outOnsets.begin()); |
| 82 | |
| 83 | std::copy(mNotesCircularBuffer[(size_t) _wrapIndex(mNoteIdx + 1, mNumNoteStored)].begin(), |
| 84 | mNotesCircularBuffer[(size_t) _wrapIndex(mNoteIdx + 1, mNumNoteStored)].end(), |
| 85 | outNotes.begin()); |
| 86 | |
| 87 | std::copy(mContoursCircularBuffer[(size_t) _wrapIndex(mContourIdx + 1, mNumContourStored)].begin(), |
| 88 | mContoursCircularBuffer[(size_t) _wrapIndex(mContourIdx + 1, mNumContourStored)].end(), |
| 89 | outContours.begin()); |
| 90 | |
| 91 | // Increment index for different circular buffers |
| 92 | mContourIdx = (mContourIdx == mNumContourStored - 1) ? 0 : mContourIdx + 1; |
| 93 | mNoteIdx = (mNoteIdx == mNumNoteStored - 1) ? 0 : mNoteIdx + 1; |
| 94 | mConcat2Idx = (mConcat2Idx == mNumConcat2Stored - 1) ? 0 : mConcat2Idx + 1; |
| 95 | } |
| 96 | |
| 97 | void BasicPitchCNN::_runModels() |
| 98 | { |
no outgoing calls